[LLVMdev] passing allocas into tail calls

Nick Lewycky nicholas at mxc.ca
Mon Oct 27 12:26:28 PDT 2014

I have a LangRef question, what does this code mean:

   %A = alloca i32
   tail call @external(i32* %A)

The 'tail' marker means that the callee doesn't access the caller's 
stack frame. So what's the right interpretation of this. Is it:

   %A = alloca i32

   %A = alloca i32
   tail call @external(i32* undef)

   %A = alloca i32
   tail call @external(i32* readnone %A)

d) like (b) except that the 'undef' is really a poison value

I think the question boils down to two other questions, what does it 
mean to "access" the caller's stack frame? Is it accessing to look at 
the pointer but not to dereference it? And the second question is what 
exactly is the penalty for violating this rule. Does it happen at the 
call site, in which case conditionally ignoring the argument would still 
be invalid? Or is it only full UB once you dereference it? What about 
comparisons performed on such a pointer?


More information about the llvm-dev mailing list