[LLVMdev] Understanding tail calls

Scott Ricketts sricketts at maxentric.com
Wed Mar 17 18:05:32 PDT 2010


On Tue, Mar 16, 2010 at 6:57 PM, Chris Lattner <clattner at apple.com> wrote:
>
> The "tail" marker has a very specific description in LLVM IR: it says that the caller does not access the callee's stack:
> http://llvm.org/docs/LangRef.html#i_call

Ah that makes more sense. Thanks for the pointer.


> > 2) When I instrument the code using my opt pass, none of the instrumentation functions in the callee get called, leading me to believe that some funny business is going on.
> I don't know about this.

That is because I did not give you enough information :). I realized
that the callee was linkonce_odr, and so the function body that I was
instrumenting was not making its way into the final executable. This
is why I was not seeing my debug info printed.

So if I am looking at a CallInst, and want to know if the callee is
going to be instrumented by my pass, I can check F->isWeakForLinker(),
where F is the called function. But this just tells me when the
function definition *may* be replaced. I want to know precisely when
the CallInst is a call to a function that I am going to instrument as
part of my pass (ignore indirect invocations for the moment).
Obviously I could do an initial pass and build an explicit list of
such functions. But is there an easier way by just looking at the
Function object?

I guess I am looking for something like
F->IsGoingToGetReplacedAtLinkTime(). Actually, that seems like it is
probably impossible to resolve during the pass.



More information about the llvm-dev mailing list