This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

sibcall vs attribute((noreturn))


I had a discussion with Andreas Bauer recently about improving GCC's
support for general last call optimization.

One issue that we noticed is that GCC does not do sibling call
optimization for calls to functions marked with __attribute__((noreturn)).
Why not?

For code written in continuation-passing style, it may be the
case that no function ever returns, they all just (tail-)call
their continuation.  Sibling call optimization of such calls
would then be necessary to avoid a stack leak.

Is there any reason why the check for no-return functions in
sibling call can't be just removed?

--- calls.c	Fri Aug 30 05:19:59 2002
+++ calls.c.new	Fri Sep  6 07:57:40 2002
@@ -2454,7 +2454,6 @@
 	 before the sibcall_epilogue.  */
       || fndecl == NULL_TREE
       || (flags & (ECF_RETURNS_TWICE | ECF_LONGJMP))
-      || TREE_THIS_VOLATILE (fndecl)
       || !FUNCTION_OK_FOR_SIBCALL (fndecl)
       /* If this function requires more stack slots than the current
 	 function, we cannot change it into a sibling call.  */
-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]