Re: CALL_EXPR_MUST_TAIL_CALL and LLVM's musttail

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Marc Feeley:

> [Marc Feeley here, the author of the Gambit Scheme compiler that generates the code which would benefit from tail-calls]
>
> What is needed (for Gambit) is a way for the programmer to express in
> the source code that the tail-call is known to be optimizable, i.e. it
> does not violate any of the tail-calling constraints, such as all
> local variables are dead (including those whose address was taken with
> “&var”) at the moment of the call.

Are you presently using scopes for that?

See the different between f3 and f3_tail on x86-64:

void f1 (int *);
int f2 (int *);

int
f3 (void)
{
  int i;
  f1 (&i);
  return f2 (i);
}

int
f3_tail (void)
{
  int i;
  {
    int i0;
    f1 (&i0);
    i = i0;
  }
  return f2 (i);
}

If the life-time of the variables whose address has been taken has ended
at the time of the call in a tail position, I expect GCC to turn it into
a tail call (subject to the other constraints mentioned).

Thanks,
Florian





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux