@@ -18183,15 +18183,17 @@ unsigned X86TargetLowering::getGlobalWrapperKind(
1818318183 if (GV && GV->isAbsoluteSymbolRef())
1818418184 return X86ISD::Wrapper;
1818518185
18186- CodeModel::Model M = getTargetMachine().getCodeModel();
18186+ // The following OpFlags under RIP-rel PIC use RIP.
1818718187 if (Subtarget.isPICStyleRIPRel() &&
18188- (M == CodeModel::Small || M == CodeModel::Kernel))
18188+ (OpFlags == X86II::MO_NO_FLAG || OpFlags == X86II::MO_COFFSTUB ||
18189+ OpFlags == X86II::MO_DLLIMPORT))
1818918190 return X86ISD::WrapperRIP;
1819018191
1819118192 // In the medium model, functions can always be referenced RIP-relatively,
1819218193 // since they must be within 2GiB. This is also possible in non-PIC mode, and
1819318194 // shorter than the 64-bit absolute immediate that would otherwise be emitted.
18194- if (M == CodeModel::Medium && isa_and_nonnull<Function>(GV))
18195+ if (getTargetMachine().getCodeModel() == CodeModel::Medium &&
18196+ isa_and_nonnull<Function>(GV))
1819518197 return X86ISD::WrapperRIP;
1819618198
1819718199 // GOTPCREL references must always use RIP.
@@ -18219,7 +18221,8 @@ X86TargetLowering::LowerConstantPool(SDValue Op, SelectionDAG &DAG) const {
1821918221 SDValue Result = DAG.getTargetConstantPool(
1822018222 CP->getConstVal(), PtrVT, CP->getAlign(), CP->getOffset(), OpFlag);
1822118223 SDLoc DL(CP);
18222- Result = DAG.getNode(getGlobalWrapperKind(), DL, PtrVT, Result);
18224+ Result =
18225+ DAG.getNode(getGlobalWrapperKind(nullptr, OpFlag), DL, PtrVT, Result);
1822318226 // With PIC, the address is actually $g + Offset.
1822418227 if (OpFlag) {
1822518228 Result =
@@ -18240,7 +18243,8 @@ SDValue X86TargetLowering::LowerJumpTable(SDValue Op, SelectionDAG &DAG) const {
1824018243 auto PtrVT = getPointerTy(DAG.getDataLayout());
1824118244 SDValue Result = DAG.getTargetJumpTable(JT->getIndex(), PtrVT, OpFlag);
1824218245 SDLoc DL(JT);
18243- Result = DAG.getNode(getGlobalWrapperKind(), DL, PtrVT, Result);
18246+ Result =
18247+ DAG.getNode(getGlobalWrapperKind(nullptr, OpFlag), DL, PtrVT, Result);
1824418248
1824518249 // With PIC, the address is actually $g + Offset.
1824618250 if (OpFlag)
@@ -18266,7 +18270,8 @@ X86TargetLowering::LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const {
1826618270 SDLoc dl(Op);
1826718271 auto PtrVT = getPointerTy(DAG.getDataLayout());
1826818272 SDValue Result = DAG.getTargetBlockAddress(BA, PtrVT, Offset, OpFlags);
18269- Result = DAG.getNode(getGlobalWrapperKind(), dl, PtrVT, Result);
18273+ Result =
18274+ DAG.getNode(getGlobalWrapperKind(nullptr, OpFlags), dl, PtrVT, Result);
1827018275
1827118276 // With PIC, the address is actually $g + Offset.
1827218277 if (isGlobalRelativeToPICBase(OpFlags)) {
@@ -25982,7 +25987,7 @@ SDValue X86TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
2598225987 auto &Context = MF.getMMI().getContext();
2598325988 MCSymbol *S = Context.getOrCreateSymbol(Twine("GCC_except_table") +
2598425989 Twine(MF.getFunctionNumber()));
25985- return DAG.getNode(getGlobalWrapperKind(), dl, VT,
25990+ return DAG.getNode(getGlobalWrapperKind(nullptr, /*OpFlags=*/0 ), dl, VT,
2598625991 DAG.getMCSymbol(S, PtrVT));
2598725992 }
2598825993
0 commit comments