calls.c (expand_call): Prevent sibcall optimization for calls to nested subprograms.
authorOlivier Hainque <hainque@act-europe.fr>
Mon, 21 Apr 2003 21:08:50 +0000 (23:08 +0200)
committerRichard Kenner <kenner@gcc.gnu.org>
Mon, 21 Apr 2003 21:08:50 +0000 (17:08 -0400)
* calls.c (expand_call): Prevent sibcall optimization for calls to
nested subprograms.

From-SVN: r65904

gcc/ChangeLog
gcc/calls.c

index b27996f50e1f5bcff8e3999e47523d6904866452..decc4b14b45eb55acee476343218add5d2a96552 100644 (file)
@@ -1,3 +1,8 @@
+2003-04-21  Olivier Hainque  <hainque@act-europe.fr>
+
+       * calls.c (expand_call): Prevent sibcall optimization for calls to
+       nested subprograms.
+
 2003-04-21  Joel Brobecker  <brobecker@gnat.com>
 
        * dwarf2out.c (is_ada, is_ada_subrange_type): New functions.
index 9b49f8719c206ce4bd48f2d3ccff627582db747e..06ed14a00e473359564fe39822a72a5aac325c4b 100644 (file)
@@ -2515,6 +2515,10 @@ expand_call (exp, target, ignore)
          optimized.  */
       || (flags & (ECF_RETURNS_TWICE | ECF_LONGJMP | ECF_NORETURN))
       || TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (addr)))
+      /* If the called function is nested in the current one, it might access
+         some of the caller's arguments, but could clobber them beforehand if
+         the argument areas are shared.  */
+      || (fndecl && decl_function_context (fndecl) == current_function_decl)
       /* If this function requires more stack slots than the current
         function, we cannot change it into a sibling call.  */
       || args_size.constant > current_function_args_size