summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/Mips
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2016-09-01 10:28:47 +0000
committerHal Finkel <hfinkel@anl.gov>2016-09-01 10:28:47 +0000
commit5081ac27c75542031b4345a298fa623a03b00e44 (patch)
treeb637ead36cab9cfd50339cb288c06c29eef1febb /llvm/lib/Target/Mips
parent1b13886b5f626a65e5242f22d93650c3a1f6ef8f (diff)
downloadbcm5719-llvm-5081ac27c75542031b4345a298fa623a03b00e44.tar.gz
bcm5719-llvm-5081ac27c75542031b4345a298fa623a03b00e44.zip
Add ISD::EH_DWARF_CFA, simplify @llvm.eh.dwarf.cfa on Mips, fix on PowerPC
LLVM has an @llvm.eh.dwarf.cfa intrinsic, used to lower the GCC-compatible __builtin_dwarf_cfa() builtin. As pointed out in PR26761, this is currently broken on PowerPC (and likely on ARM as well). Currently, @llvm.eh.dwarf.cfa is lowered using: ADD(FRAMEADDR, FRAME_TO_ARGS_OFFSET) where FRAME_TO_ARGS_OFFSET defaults to the constant zero. On x86, FRAME_TO_ARGS_OFFSET is lowered to 2*SlotSize. This setup, however, does not work for PowerPC. Because of the way that the stack layout works, the canonical frame address is not exactly (FRAMEADDR + FRAME_TO_ARGS_OFFSET) on PowerPC (there is a lower save-area offset as well), so it is not just a matter of implementing FRAME_TO_ARGS_OFFSET for PowerPC (unless we redefine its semantics -- We can do that, since it is currently used only for @llvm.eh.dwarf.cfa lowering, but the better to directly lower the CFA construct itself (since it can be easily represented as a fixed-offset FrameIndex)). Mips currently does this, but by using a custom lowering for ADD that specifically recognizes the (FRAMEADDR, FRAME_TO_ARGS_OFFSET) pattern. This change introduces a ISD::EH_DWARF_CFA node, which by default expands using the existing logic, but can be directly lowered by the target. Mips is updated to use this method (which simplifies its implementation, and I suspect makes it more robust), and updates PowerPC to do the same. Fixes PR26761. Differential Revision: https://reviews.llvm.org/D24038 llvm-svn: 280350
Diffstat (limited to 'llvm/lib/Target/Mips')
-rw-r--r--llvm/lib/Target/Mips/MipsISelLowering.cpp27
-rw-r--r--llvm/lib/Target/Mips/MipsISelLowering.h2
2 files changed, 9 insertions, 20 deletions
diff --git a/llvm/lib/Target/Mips/MipsISelLowering.cpp b/llvm/lib/Target/Mips/MipsISelLowering.cpp
index e2b8ec0c196..c12668bf63c 100644
--- a/llvm/lib/Target/Mips/MipsISelLowering.cpp
+++ b/llvm/lib/Target/Mips/MipsISelLowering.cpp
@@ -305,9 +305,9 @@ MipsTargetLowering::MipsTargetLowering(const MipsTargetMachine &TM,
setOperationAction(ISD::SRL_PARTS, MVT::i32, Custom);
}
- setOperationAction(ISD::ADD, MVT::i32, Custom);
+ setOperationAction(ISD::EH_DWARF_CFA, MVT::i32, Custom);
if (Subtarget.isGP64bit())
- setOperationAction(ISD::ADD, MVT::i64, Custom);
+ setOperationAction(ISD::EH_DWARF_CFA, MVT::i64, Custom);
setOperationAction(ISD::SDIV, MVT::i32, Expand);
setOperationAction(ISD::SREM, MVT::i32, Expand);
@@ -914,7 +914,7 @@ LowerOperation(SDValue Op, SelectionDAG &DAG) const
case ISD::SRL_PARTS: return lowerShiftRightParts(Op, DAG, false);
case ISD::LOAD: return lowerLOAD(Op, DAG);
case ISD::STORE: return lowerSTORE(Op, DAG);
- case ISD::ADD: return lowerADD(Op, DAG);
+ case ISD::EH_DWARF_CFA: return lowerEH_DWARF_CFA(Op, DAG);
case ISD::FP_TO_SINT: return lowerFP_TO_SINT(Op, DAG);
}
return SDValue();
@@ -2393,26 +2393,15 @@ SDValue MipsTargetLowering::lowerSTORE(SDValue Op, SelectionDAG &DAG) const {
return lowerFP_TO_SINT_STORE(SD, DAG);
}
-SDValue MipsTargetLowering::lowerADD(SDValue Op, SelectionDAG &DAG) const {
- if (Op->getOperand(0).getOpcode() != ISD::FRAMEADDR
- || cast<ConstantSDNode>
- (Op->getOperand(0).getOperand(0))->getZExtValue() != 0
- || Op->getOperand(1).getOpcode() != ISD::FRAME_TO_ARGS_OFFSET)
- return SDValue();
+SDValue MipsTargetLowering::lowerEH_DWARF_CFA(SDValue Op,
+ SelectionDAG &DAG) const {
- // The pattern
- // (add (frameaddr 0), (frame_to_args_offset))
- // results from lowering llvm.eh.dwarf.cfa intrinsic. Transform it to
- // (add FrameObject, 0)
- // where FrameObject is a fixed StackObject with offset 0 which points to
- // the old stack pointer.
+ // Return a fixed StackObject with offset 0 which points to the old stack
+ // pointer.
MachineFrameInfo &MFI = DAG.getMachineFunction().getFrameInfo();
EVT ValTy = Op->getValueType(0);
int FI = MFI.CreateFixedObject(Op.getValueSizeInBits() / 8, 0, false);
- SDValue InArgsAddr = DAG.getFrameIndex(FI, ValTy);
- SDLoc DL(Op);
- return DAG.getNode(ISD::ADD, DL, ValTy, InArgsAddr,
- DAG.getConstant(0, DL, ValTy));
+ return DAG.getFrameIndex(FI, ValTy);
}
SDValue MipsTargetLowering::lowerFP_TO_SINT(SDValue Op,
diff --git a/llvm/lib/Target/Mips/MipsISelLowering.h b/llvm/lib/Target/Mips/MipsISelLowering.h
index cc1f736901c..767eee7a995 100644
--- a/llvm/lib/Target/Mips/MipsISelLowering.h
+++ b/llvm/lib/Target/Mips/MipsISelLowering.h
@@ -446,7 +446,7 @@ namespace llvm {
SDValue lowerShiftLeftParts(SDValue Op, SelectionDAG& DAG) const;
SDValue lowerShiftRightParts(SDValue Op, SelectionDAG& DAG,
bool IsSRA) const;
- SDValue lowerADD(SDValue Op, SelectionDAG &DAG) const;
+ SDValue lowerEH_DWARF_CFA(SDValue Op, SelectionDAG &DAG) const;
SDValue lowerFP_TO_SINT(SDValue Op, SelectionDAG &DAG) const;
/// isEligibleForTailCallOptimization - Check whether the call is eligible
OpenPOWER on IntegriCloud