Skip to content

Commit

Permalink
[X86] Provide the LSDA pointer with RIP relative addressing if necessary
Browse files Browse the repository at this point in the history
This makes sure the LSDA pointer isn't truncated to 32 bit.

Make LowerINTRINSIC_WO_CHAIN a member function instead of a static
function, so that it can use the getGlobalWrapperKind method.

This solves the second half of the issues mentioned in PR34720.

Differential Revision: https://reviews.llvm.org/D38343

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314767 91177308-0d34-0410-b5e6-96231b3b80d8
mstorsjo committed Oct 3, 2017
1 parent 42c9fd0 commit 4495cb1
Showing 3 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
@@ -19304,8 +19304,8 @@ static SDValue recoverFramePointer(SelectionDAG &DAG, const Function *Fn,
return DAG.getNode(ISD::SUB, dl, PtrVT, RegNodeBase, ParentFrameOffset);
}

static SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, const X86Subtarget &Subtarget,
SelectionDAG &DAG) {
SDValue X86TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
SelectionDAG &DAG) const {
// Helper to detect if the operand is CUR_DIRECTION rounding mode.
auto isRoundModeCurDirection = [](SDValue Rnd) {
if (!isa<ConstantSDNode>(Rnd))
@@ -20126,7 +20126,8 @@ static SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, const X86Subtarget &Subtarget
auto &Context = MF.getMMI().getContext();
MCSymbol *S = Context.getOrCreateSymbol(Twine("GCC_except_table") +
Twine(MF.getFunctionNumber()));
return DAG.getNode(X86ISD::Wrapper, dl, VT, DAG.getMCSymbol(S, PtrVT));
return DAG.getNode(getGlobalWrapperKind(), dl, VT,
DAG.getMCSymbol(S, PtrVT));
}

case Intrinsic::x86_seh_lsda: {
@@ -24042,7 +24043,7 @@ SDValue X86TargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
case ISD::VASTART: return LowerVASTART(Op, DAG);
case ISD::VAARG: return LowerVAARG(Op, DAG);
case ISD::VACOPY: return LowerVACOPY(Op, Subtarget, DAG);
case ISD::INTRINSIC_WO_CHAIN: return LowerINTRINSIC_WO_CHAIN(Op, Subtarget, DAG);
case ISD::INTRINSIC_WO_CHAIN: return LowerINTRINSIC_WO_CHAIN(Op, DAG);
case ISD::INTRINSIC_VOID:
case ISD::INTRINSIC_W_CHAIN: return LowerINTRINSIC_W_CHAIN(Op, Subtarget, DAG);
case ISD::RETURNADDR: return LowerRETURNADDR(Op, DAG);
@@ -24302,7 +24303,7 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
}
}
case ISD::INTRINSIC_WO_CHAIN: {
if (SDValue V = LowerINTRINSIC_WO_CHAIN(SDValue(N, 0), Subtarget, DAG))
if (SDValue V = LowerINTRINSIC_WO_CHAIN(SDValue(N, 0), DAG))
Results.push_back(V);
return;
}
1 change: 1 addition & 0 deletions lib/Target/X86/X86ISelLowering.h
Original file line number Diff line number Diff line change
@@ -1189,6 +1189,7 @@ namespace llvm {
SDValue LowerWin64_i128OP(SDValue Op, SelectionDAG &DAG) const;
SDValue LowerGC_TRANSITION_START(SDValue Op, SelectionDAG &DAG) const;
SDValue LowerGC_TRANSITION_END(SDValue Op, SelectionDAG &DAG) const;
SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;

SDValue
LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
2 changes: 1 addition & 1 deletion test/CodeGen/X86/sjlj-eh.ll
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ try.cont:
; CHECK-X64: leaq __gxx_personality_sj0(%rip), %rax
; CHECK-X64: movq %rax, -280(%rbp)
; UFC.__lsda = $LSDA
; CHECK-X64: movl $[[LSDA:GCC_except_table[0-9]+]], %eax
; CHECK-X64: leaq [[LSDA:GCC_except_table[0-9]+]](%rip), %rax
; CHECK-X64: movq %rax, -272(%rbp)
; UFC.__jbuf[0] = $RBP
; CHECK-X64: movq %rbp, -264(%rbp)

0 comments on commit 4495cb1

Please sign in to comment.