]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix uninitialized register read problem.
authorJames E Wilson <wilson@specifixinc.com>
Fri, 19 Aug 2005 21:16:20 +0000 (14:16 -0700)
committerJim Wilson <wilson@gcc.gnu.org>
Fri, 19 Aug 2005 21:16:20 +0000 (14:16 -0700)
* builtins.c (expand_builtin_return_addr): Set
current_function_accesses_prior_frames when count != 0.  Use
frame_pointer_rtx when count == 0.
* function.h (struct function): Add accesses_prior_frames field.
(current_function_accesses_prior_frames): Define.
* reload1.c (init_elim_table): Check
current_function_accesses_prior_frames.
* doc/tm.texi (INITIAL_FRAME_ADDRESS_RTX): Update docs.

From-SVN: r103294

gcc/ChangeLog
gcc/builtins.c
gcc/doc/tm.texi
gcc/function.h
gcc/reload1.c

index 8d37b8824297a05c8071bc30a4ff2c5fd003515d..8f7da8ec897dc6556723c3c44590919dab41b924 100644 (file)
@@ -1,3 +1,14 @@
+2005-08-19  James E Wilson  <wilson@specifix.com>
+
+       * builtins.c (expand_builtin_return_addr): Set
+       current_function_accesses_prior_frames when count != 0.  Use
+       frame_pointer_rtx when count == 0.
+       * function.h (struct function): Add accesses_prior_frames field.
+       (current_function_accesses_prior_frames): Define.
+       * reload1.c (init_elim_table): Check
+       current_function_accesses_prior_frames.
+       * doc/tm.texi (INITIAL_FRAME_ADDRESS_RTX): Update docs.
+
 2005-08-19  Diego Novillo  <dnovillo@redhat.com>
 
        * tree-cfgcleanup.c (cleanup_tree_cfg): Fix flowgraph change
index d02b1c3a00eb2c54d0f73cee2c5d87a030990ce2..9975b751ef2a8816ab4369540abe6a6d18f02a14 100644 (file)
@@ -485,7 +485,22 @@ expand_builtin_return_addr (enum built_in_function fndecl_code, int count)
 #ifdef INITIAL_FRAME_ADDRESS_RTX
   rtx tem = INITIAL_FRAME_ADDRESS_RTX;
 #else
-  rtx tem = hard_frame_pointer_rtx;
+  rtx tem;
+
+  /* For a zero count, we don't care what frame address we return, so frame
+     pointer elimination is OK, and using the soft frame pointer is OK.
+     For a non-zero count, we require a stable offset from the current frame
+     pointer to the previous one, so we must use the hard frame pointer, and
+     we must disable frame pointer elimination.  */
+  if (count == 0)
+    tem = frame_pointer_rtx;
+  else 
+    {
+      tem = hard_frame_pointer_rtx;
+
+      /* Tell reload not to eliminate the frame pointer.  */
+      current_function_accesses_prior_frames = 1;
+    }
 #endif
 
   /* Some machines need special handling before we can access
index 164bae10f651f1e855c503851a449e2426e46eac..16b48ff87a436c7513fa76952dbf9ee8eede55d3 100644 (file)
@@ -2812,14 +2812,11 @@ machines.  See @file{function.c} for details.
 
 @defmac INITIAL_FRAME_ADDRESS_RTX
 A C expression whose value is RTL representing the address of the initial
- stack frame. This address is passed to @code{RETURN_ADDR_RTX} and 
-@code{DYNAMIC_CHAIN_ADDRESS}.
-If you don't define this macro, the default is to return 
-@code{hard_frame_pointer_rtx}.
-This default is usually correct unless @code{-fomit-frame-pointer} is in 
-effect.
-Define this macro in order to make @code{__builtin_frame_address (0)} and 
-@code{__builtin_return_address (0)} work even in absence of a hard frame pointer.
+stack frame. This address is passed to @code{RETURN_ADDR_RTX} and 
+@code{DYNAMIC_CHAIN_ADDRESS}.  If you don't define this macro, a reasonable
+default value will be used.  Define this macro in order to make frame pointer
+elimination work in the presence of @code{__builtin_frame_address (count)} and 
+@code{__builtin_return_address (count)} for @code{count} not equal to zero.
 @end defmac
 
 @defmac DYNAMIC_CHAIN_ADDRESS (@var{frameaddr})
index 11b97c1fc2b69cdeaaba3f0fdd985d17fb63e367..c1482ac328e659d59871ab2a8528bc489066ab22 100644 (file)
@@ -394,6 +394,10 @@ struct function GTY(())
      either as a subroutine or builtin.  */
   unsigned int calls_alloca : 1;
 
+  /* Nonzero if function being compiled called builtin_return_addr or
+     builtin_frame_address with non-zero count.  */
+  unsigned int accesses_prior_frames : 1;
+
   /* Nonzero if the function calls __builtin_eh_return.  */
   unsigned int calls_eh_return : 1;
 
@@ -483,6 +487,7 @@ extern int trampolines_created;
 #define current_function_returns_pointer (cfun->returns_pointer)
 #define current_function_calls_setjmp (cfun->calls_setjmp)
 #define current_function_calls_alloca (cfun->calls_alloca)
+#define current_function_accesses_prior_frames (cfun->accesses_prior_frames)
 #define current_function_calls_eh_return (cfun->calls_eh_return)
 #define current_function_is_thunk (cfun->is_thunk)
 #define current_function_args_info (cfun->args_info)
index 08e939bba901c40941461b87f3ddaf6f00df1b30..dbe26d4441b757baab188c02c4ed323c55585a5f 100644 (file)
@@ -3492,6 +3492,7 @@ init_elim_table (void)
                             sp-adjusting insns for this case.  */
                          || (current_function_calls_alloca
                              && EXIT_IGNORE_STACK)
+                         || current_function_accesses_prior_frames
                          || FRAME_POINTER_REQUIRED);
 
   num_eliminable = 0;