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/tailcall terminology


Currently the GCC sources are rather confused/confusing with regard to the
terminology used for the different kinds of tail recursion and sibling
call optimization.

I would like to make a patch that cleans this up by introducing some
standard terms for three concepts, and making sure that the appropriate term
is used in all the places dealing with this.  But before I can do this,
we need to agree on what terminology should be used.

The concepts are these:

	(1) the case where the callee is the same function
	    as the caller, and the call in a tail position
	    (the calling function has no code reachable
	    after the function call, except the return),
	    and the caller's stack frame is no longer live.

	(2) the case where the callee is a (potentially) different function
	    than the caller (including the case where the
	    call is to an unknown function, via a function pointer),
	    and the call is in a tail position,
	    and the stack frame is not live.

	(2b) the subcategory of (2) in which the callee ends up
	    recursively calling the caller.

	(3) The union of (1) and (2),
	    i.e. the case in 

In the past, I have used the following terminology:

	(1) direct tail recursion; directly recursive tail call
	(2) indirect tail call
	(2b) indirect tail recursion; indirectly recursive tail call
	(3) tail call

Currently GCC uses the following terminology:

	(1) tail recursion (e.g. try_tail_recursion and tail_recursion_insns
			    in calls.c);
	    tail recursive call

	(2) sibling call (e.g. sibcall_epilogue, OK_FOR_SIBCALL);
	    tail call (e.g. try_tail_call in calls.c)

	(3) sibling call (e.g. -foptimize-sibling-calls, sibcall.c);
	    tail call (e.g. CALL_EXPR_TAILCALL, tail_call_reg in calls.c (?))

As you can see, the current terminology is confusing; the terms "tail call"
and "sibling call" are both ambiguous, meaning different things in different
places.

So, I suggest we pick one meaning for each term and then stick to it.

In particular, here are some concrete proposals.

Proposal A:
I propose that we use "tail call" to mean (3)
and "sibling call" to mean (2).

As a consequence:
	- sibcall.c should renamed tailcall.c
	- -foptimize-sibling-calls should be renamed -foptimize-tail-calls
	  (or perhaps -foptimize-tailcalls?)
	- try_tail_call in calls.c should be renamed try_sibling_call

Proposal B:
Alternatively, we could use "sibling call" to mean (3)
and "tail call" to mean (2).  In that case:
	- OK_FOR_SIBCALL should be renamed OK_FOR_TAILCALL
	- sibcall_epilogue should be renamed tailcall_epilogue
	etc.

I prefer Proposal A.

Comments?  Alternative suggestions?  Arguments in favour of the status quo?

-- 
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]