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]

Re: forcing tail/sibling call optimization


I'm concerned that on many machines the default calling convention
may make tail-call optimization difficult.  To make tail-call
optimization practical (or at least efficient) you may want to use
a non-default calling convention.

Specifically, the traditional C calling convention has the caller
pop the arguments from the stack after the function returns.  This
is needed to handle varags.  Safe and efficient tail-call
elimination assumes the callee pops the arguments.

This means that syntax associated with the call site is not enough.
You also (or instead) need some annotation when the called function
is compiled.  Because of the need to handle unknown functions,
that annotation needs to be an attribute of the function *type*.

The special case where tail-calling a function that as the same
parameter types as the callee can however be handled relatively
easily using standard calling conventions.

There was some discussion on this topic not too long ago, I believe
on this list and this year.  People pointed out some of the problems.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/

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