[LLVMdev] Destination register needs to be valid after callee saved register restore when tail calling
Christopher Lamb
christopher.lamb at gmail.com
Wed Aug 8 11:59:25 PDT 2007
On Aug 8, 2007, at 10:46 AM, Arnold Schwaighofer wrote:
> So where i approximately had this before (assuming that RetNode.getOp
> (1) is not a TargetGlobalAddress or the like)
>
> SDOperand OpsTailCall [] = {AdjStackChain, RetNode.getOperand(1),
> RetNode.getOperand(2)};
> RetNode = DCI.DAG.getNode(X86ISD::TAILCALL, TCVTs, OpsTailCall,3);
>
> would then be replaced by
>
> Chain = DAG.getCopyToReg(AdjStackChain, X86::ECX, RetNode.getOperand
> (1));
> SDOperand OpsTailCall [] = {Chain,DAG.getRegister(X86::ECX,
> getPointerTy())), RetNode.getOperand(2)};
> RetNode = DCI.DAG.getNode(X86ISD::TAILCALL, TCVTs, OpsTailCall, 3);
>
> the downside here is that ECX is no longer free for passing function
> arguments. (i am using the x86_fastcall semantics at the moment with
> first
> two arguments stored in ecx,edx)
If you would like to give the RA more latitude in choosing the
register around other allocations you could create a register class
corresponding to registers which are call-clobbered, and therefore
safe to use to hold the function address for tail calls. Then instead
of a normal CopyToReg you would use a pseudo-move instruction similar
to MOV32to32_ to ensure that the function address is in a safe register.
--
Christopher Lamb
More information about the llvm-dev
mailing list