diff options
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 10 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 32 |
3 files changed, 20 insertions, 24 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 6eb43e1d8e..c3289fc1e7 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -652,6 +652,16 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { break; } break; + case ISD::FRAMEADDR: + case ISD::RETURNADDR: + // The only option for these nodes is to custom lower them. If the target + // does not custom lower them, then return zero. + Tmp1 = TLI.LowerOperation(Op, DAG); + if (Tmp1.Val) + Result = Tmp1; + else + Result = DAG.getConstant(0, TLI.getPointerTy()); + break; case ISD::AssertSext: case ISD::AssertZext: Tmp1 = LegalizeOp(Node->getOperand(0)); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 97fb8c5a04..8bed6f7a26 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -2665,6 +2665,8 @@ const char *SDNode::getOperationName(const SelectionDAG *G) const { case ISD::FrameIndex: return "FrameIndex"; case ISD::JumpTable: return "JumpTable"; case ISD::GLOBAL_OFFSET_TABLE: return "GLOBAL_OFFSET_TABLE"; + case ISD::RETURNADDR: return "RETURNADDR"; + case ISD::FRAMEADDR: return "FRAMEADDR"; case ISD::ConstantPool: return "ConstantPool"; case ISD::ExternalSymbol: return "ExternalSymbol"; case ISD::INTRINSIC_WO_CHAIN: { diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index df7440f792..3b452979aa 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -570,7 +570,6 @@ public: void visitVAArg(VAArgInst &I); void visitVAEnd(CallInst &I); void visitVACopy(CallInst &I); - void visitFrameReturnAddress(CallInst &I, bool isFrameAddress); void visitMemIntrinsic(CallInst &I, unsigned Op); @@ -1932,8 +1931,14 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) { case Intrinsic::vastart: visitVAStart(I); return 0; case Intrinsic::vaend: visitVAEnd(I); return 0; case Intrinsic::vacopy: visitVACopy(I); return 0; - case Intrinsic::returnaddress: visitFrameReturnAddress(I, false); return 0; - case Intrinsic::frameaddress: visitFrameReturnAddress(I, true); return 0; + case Intrinsic::returnaddress: + setValue(&I, DAG.getNode(ISD::RETURNADDR, TLI.getPointerTy(), + getValue(I.getOperand(1)))); + return 0; + case Intrinsic::frameaddress: + setValue(&I, DAG.getNode(ISD::FRAMEADDR, TLI.getPointerTy(), + getValue(I.getOperand(1)))); + return 0; case Intrinsic::setjmp: return "_setjmp"+!TLI.usesUnderscoreSetJmp(); break; @@ -3207,19 +3212,6 @@ TargetLowering::LowerCallTo(SDOperand Chain, const Type *RetTy, return std::make_pair(ResVal, Res.getValue(Res.Val->getNumValues()-1)); } - - -// It is always conservatively correct for llvm.returnaddress and -// llvm.frameaddress to return 0. -// -// FIXME: Change this to insert a FRAMEADDR/RETURNADDR node, and have that be -// expanded to 0 if the target wants. -std::pair<SDOperand, SDOperand> -TargetLowering::LowerFrameReturnAddress(bool isFrameAddr, SDOperand Chain, - unsigned Depth, SelectionDAG &DAG) { - return std::make_pair(DAG.getConstant(0, getPointerTy()), Chain); -} - SDOperand TargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) { assert(0 && "LowerOperation not implemented for this target!"); abort(); @@ -3233,14 +3225,6 @@ SDOperand TargetLowering::CustomPromoteOperation(SDOperand Op, return SDOperand(); } -void SelectionDAGLowering::visitFrameReturnAddress(CallInst &I, bool isFrame) { - unsigned Depth = (unsigned)cast<ConstantInt>(I.getOperand(1))->getZExtValue(); - std::pair<SDOperand,SDOperand> Result = - TLI.LowerFrameReturnAddress(isFrame, getRoot(), Depth, DAG); - setValue(&I, Result.first); - DAG.setRoot(Result.second); -} - /// getMemsetValue - Vectorized representation of the memset value /// operand. static SDOperand getMemsetValue(SDOperand Value, MVT::ValueType VT, |