[LLVMdev] Destination register needs to be valid after callee saved register restore when tail calling

Anton Korobeynikov asl at math.spbu.ru
Wed Aug 8 07:43:43 PDT 2007


Hello, Arnold.

> Is there a way to indicate that the register the tail call  
> instruction uses as destination needs to be valid after the callee  
> saved registers have been restored? (some X86InstrInfo.td foo magic  
> maybe ?)
It's wrong way to do the things. Because in this case you either violate
the ABI for callee, or you're restricted to do tail call lowering only
for internal functions, making all stuff inpractical. . Only
call-clobbered registers can be used to store pointer to callee (I'd
suggest %ecx on x86/32, btw).

> Or do i have to insert code into PEI::saveCalleeSavedRegisters to  
> detect that there is a tail called function that uses a callee saved  
> register and move it to another (EAX).
You shouldn't use call-saved registers at all. Only call-clobbered. It
seems, that you can use the trick similar to eh_return lowering (that
case is somehow special, because %eax and %edx should be preserved there
too). You can see it in TOT for x86 target (also, prologue/epilogue
emission code changed on TOT, you might want to check, whether your code
works for it).

PS: Feel free to contact me in case of any related questions. In fact, I
planned to start tail call lowering within next 2-3 weeks :)

--
WBR, Anton Korobeynikov 



More information about the llvm-dev mailing list