[PATCH] D157907: [NFC] Refactor X86TargetLowering::getGlobalWrapperKind()
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 14 11:28:57 PDT 2023
aeubanks created this revision.
aeubanks added reviewers: jyknight, rnk.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
To simplify D150297 <https://reviews.llvm.org/D150297>.
We should be looking at OpFlags more.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D157907
Files:
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86Subtarget.cpp
Index: llvm/lib/Target/X86/X86Subtarget.cpp
===================================================================
--- llvm/lib/Target/X86/X86Subtarget.cpp
+++ llvm/lib/Target/X86/X86Subtarget.cpp
@@ -323,7 +323,7 @@
InstrInfo(initializeSubtargetDependencies(CPU, TuneCPU, FS)),
TLInfo(TM, *this), FrameLowering(*this, getStackAlignment()) {
// Determine the PICStyle based on the target selected.
- if (!isPositionIndependent())
+ if (!isPositionIndependent() || TM.getCodeModel() == CodeModel::Large)
setPICStyle(PICStyles::Style::None);
else if (is64Bit())
setPICStyle(PICStyles::Style::RIPRel);
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -18204,15 +18204,17 @@
if (GV && GV->isAbsoluteSymbolRef())
return X86ISD::Wrapper;
- CodeModel::Model M = getTargetMachine().getCodeModel();
+ // The following OpFlags under RIP-rel PIC use RIP.
if (Subtarget.isPICStyleRIPRel() &&
- (M == CodeModel::Small || M == CodeModel::Kernel))
+ (OpFlags == X86II::MO_NO_FLAG || OpFlags == X86II::MO_COFFSTUB ||
+ OpFlags == X86II::MO_DLLIMPORT))
return X86ISD::WrapperRIP;
// In the medium model, functions can always be referenced RIP-relatively,
// since they must be within 2GiB. This is also possible in non-PIC mode, and
// shorter than the 64-bit absolute immediate that would otherwise be emitted.
- if (M == CodeModel::Medium && isa_and_nonnull<Function>(GV))
+ if (getTargetMachine().getCodeModel() == CodeModel::Medium &&
+ isa_and_nonnull<Function>(GV))
return X86ISD::WrapperRIP;
// GOTPCREL references must always use RIP.
@@ -18240,7 +18242,8 @@
SDValue Result = DAG.getTargetConstantPool(
CP->getConstVal(), PtrVT, CP->getAlign(), CP->getOffset(), OpFlag);
SDLoc DL(CP);
- Result = DAG.getNode(getGlobalWrapperKind(), DL, PtrVT, Result);
+ Result =
+ DAG.getNode(getGlobalWrapperKind(nullptr, OpFlag), DL, PtrVT, Result);
// With PIC, the address is actually $g + Offset.
if (OpFlag) {
Result =
@@ -18261,7 +18264,8 @@
auto PtrVT = getPointerTy(DAG.getDataLayout());
SDValue Result = DAG.getTargetJumpTable(JT->getIndex(), PtrVT, OpFlag);
SDLoc DL(JT);
- Result = DAG.getNode(getGlobalWrapperKind(), DL, PtrVT, Result);
+ Result =
+ DAG.getNode(getGlobalWrapperKind(nullptr, OpFlag), DL, PtrVT, Result);
// With PIC, the address is actually $g + Offset.
if (OpFlag)
@@ -18287,7 +18291,8 @@
SDLoc dl(Op);
auto PtrVT = getPointerTy(DAG.getDataLayout());
SDValue Result = DAG.getTargetBlockAddress(BA, PtrVT, Offset, OpFlags);
- Result = DAG.getNode(getGlobalWrapperKind(), dl, PtrVT, Result);
+ Result =
+ DAG.getNode(getGlobalWrapperKind(nullptr, OpFlags), dl, PtrVT, Result);
// With PIC, the address is actually $g + Offset.
if (isGlobalRelativeToPICBase(OpFlags)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157907.550036.patch
Type: text/x-patch
Size: 3002 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230814/d60cdff3/attachment-0001.bin>
More information about the llvm-commits
mailing list