Rerunning TailCallElim at a later stage

Hi

from what I have figured out, the pass "TailCallElim" is being done in what I would call the "opt" phase of optimization. The "StackColoring" is being done in the "llc" phase. opt -> llc, so TailCallElim is always ahead.

Now I would like to add something (my reusealloca idea) in "StackColoring" to get rid of some allocas, which inhibit "TailCallElim".

* Is it possible to rerun (if even possible at that stage) the "TailCallElim" at this stage ?

* Is it possible to make "StackColoring" into an "opt" pass and try to get it ahead of "TailCallElim" ? I guess not, though I can see how "RegisterColoring" is dependent on architecture, but I don't really see it for allocas.

Ciao
    Nat!

P.S. AU.addRequired<TailCallElim>(); would not work BTW.

No, this reordering is not possible. Stack coloring is part of codegen. Passes that modify the IR cannot run as part of codegen.

Your best bet for enabling tail calls with your meta calling convention is to write a custom pass that rewrites calls in the tail position to use the incoming argument memory instead of a local alloca. It would be up to this custom pass to determine exactly when this is legal.

Reid Kleckner schrieb:

Your best bet for enabling tail calls with your meta calling convention
is to write a custom pass that rewrites calls in the tail position to
use the incoming argument memory instead of a local alloca. It would be
up to this custom pass to determine exactly when this is legal.

I assume that would be a pass that I would try to get, somehow, ahead of "TailCallElim" in the "opt" phase ?

Thanks for the help!

Ciao
    Nat!