From af63bb03c51231d81f6890dcaec7f71cb60b51de Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 24 Jan 2006 05:17:12 +0000 Subject: [PATCH] Emit the copies out of call return registers *after* the ISD::CALLSEQ_END node, fixing fastcc and the case where a function has a frame pointer due to dynamic allocas. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25580 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86ISelLowering.cpp | 28 ++++++++++++++++++++++------ lib/Target/X86/X86InstrInfo.td | 2 +- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 857fdfe6e94..c83e6d058cc 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -521,6 +521,17 @@ X86TargetLowering::LowerCCCCallTo(SDOperand Chain, const Type *RetTy, Chain = DAG.getNode(X86ISD::CALL, NodeTys, Ops); SDOperand InFlag = Chain.getValue(1); + NodeTys.clear(); + NodeTys.push_back(MVT::Other); // Returns a chain + NodeTys.push_back(MVT::Flag); // Returns a flag for retval copy to use. + Ops.clear(); + Ops.push_back(Chain); + Ops.push_back(DAG.getConstant(NumBytes, getPointerTy())); + Ops.push_back(DAG.getConstant(0, getPointerTy())); + Ops.push_back(InFlag); + Chain = DAG.getNode(ISD::CALLSEQ_END, NodeTys, Ops); + InFlag = Chain.getValue(1); + SDOperand RetVal; if (RetTyVT != MVT::isVoid) { switch (RetTyVT) { @@ -591,9 +602,6 @@ X86TargetLowering::LowerCCCCallTo(SDOperand Chain, const Type *RetTy, } } - Chain = DAG.getNode(ISD::CALLSEQ_END, MVT::Other, Chain, - DAG.getConstant(NumBytes, getPointerTy()), - DAG.getConstant(0, getPointerTy())); return std::make_pair(RetVal, Chain); } else { std::vector Ops; @@ -1049,6 +1057,17 @@ X86TargetLowering::LowerFastCCCallTo(SDOperand Chain, const Type *RetTy, Chain = DAG.getNode(X86ISD::CALL, NodeTys, Ops); InFlag = Chain.getValue(1); + NodeTys.clear(); + NodeTys.push_back(MVT::Other); // Returns a chain + NodeTys.push_back(MVT::Flag); // Returns a flag for retval copy to use. + Ops.clear(); + Ops.push_back(Chain); + Ops.push_back(DAG.getConstant(ArgOffset, getPointerTy())); + Ops.push_back(DAG.getConstant(ArgOffset, getPointerTy())); + Ops.push_back(InFlag); + Chain = DAG.getNode(ISD::CALLSEQ_END, NodeTys, Ops); + InFlag = Chain.getValue(1); + SDOperand RetVal; if (RetTyVT != MVT::isVoid) { switch (RetTyVT) { @@ -1119,9 +1138,6 @@ X86TargetLowering::LowerFastCCCallTo(SDOperand Chain, const Type *RetTy, } } - Chain = DAG.getNode(ISD::CALLSEQ_END, MVT::Other, Chain, - DAG.getConstant(ArgOffset, getPointerTy()), - DAG.getConstant(ArgOffset, getPointerTy())); return std::make_pair(RetVal, Chain); } else { std::vector Ops; diff --git a/lib/Target/X86/X86InstrInfo.td b/lib/Target/X86/X86InstrInfo.td index 04f8f16e15d..aa149fcf252 100644 --- a/lib/Target/X86/X86InstrInfo.td +++ b/lib/Target/X86/X86InstrInfo.td @@ -88,7 +88,7 @@ def X86callseq_start : [SDNPHasChain]>; def X86callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd, - [SDNPHasChain]>; + [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>; def X86call : SDNode<"X86ISD::CALL", SDT_X86Call, [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;