Skip to content

Commit 94c988b

Browse files
committed
[NFC] Remove unused parameter from shouldAssumeDSOLocal()
1 parent 5feaef6 commit 94c988b

18 files changed

+33
-43
lines changed

llvm/include/llvm/Target/TargetMachine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class TargetMachine {
241241

242242
bool isPositionIndependent() const;
243243

244-
bool shouldAssumeDSOLocal(const Module &M, const GlobalValue *GV) const;
244+
bool shouldAssumeDSOLocal(const GlobalValue *GV) const;
245245

246246
/// Returns true if this target uses emulated TLS.
247247
bool useEmulatedTLS() const;

llvm/lib/CodeGen/GlobalMerge.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ bool GlobalMergeImpl::run(Module &M) {
641641
continue;
642642

643643
// It's not safe to merge globals that may be preempted
644-
if (TM && !TM->shouldAssumeDSOLocal(M, &GV))
644+
if (TM && !TM->shouldAssumeDSOLocal(&GV))
645645
continue;
646646

647647
if (!(Opt.MergeExternal && GV.hasExternalLinkage()) &&

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ TargetLowering::isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const {
491491

492492
// If the address is not even local to this DSO we will have to load it from
493493
// a got and then add the offset.
494-
if (!TM.shouldAssumeDSOLocal(*GV->getParent(), GV))
494+
if (!TM.shouldAssumeDSOLocal(GV))
495495
return false;
496496

497497
// If the code is position independent we will have to add a base register.

llvm/lib/Target/AArch64/AArch64Subtarget.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ AArch64Subtarget::ClassifyGlobalReference(const GlobalValue *GV,
398398
if (GV->isTagged())
399399
return AArch64II::MO_GOT;
400400

401-
if (!TM.shouldAssumeDSOLocal(*GV->getParent(), GV)) {
401+
if (!TM.shouldAssumeDSOLocal(GV)) {
402402
if (GV->hasDLLImportStorageClass()) {
403403
return AArch64II::MO_GOT | AArch64II::MO_DLLIMPORT;
404404
}
@@ -435,8 +435,7 @@ unsigned AArch64Subtarget::classifyGlobalFunctionReference(
435435
// NonLazyBind goes via GOT unless we know it's available locally.
436436
auto *F = dyn_cast<Function>(GV);
437437
if ((!isTargetMachO() || MachOUseNonLazyBind) && F &&
438-
F->hasFnAttribute(Attribute::NonLazyBind) &&
439-
!TM.shouldAssumeDSOLocal(*GV->getParent(), GV))
438+
F->hasFnAttribute(Attribute::NonLazyBind) && !TM.shouldAssumeDSOLocal(GV))
440439
return AArch64II::MO_GOT;
441440

442441
if (getTargetTriple().isOSWindows()) {

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6219,8 +6219,7 @@ bool SITargetLowering::shouldEmitGOTReloc(const GlobalValue *GV) const {
62196219
// address space for functions to avoid the explicit check.
62206220
return (GV->getValueType()->isFunctionTy() ||
62216221
!isNonGlobalAddrSpace(GV->getAddressSpace())) &&
6222-
!shouldEmitFixup(GV) &&
6223-
!getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV);
6222+
!shouldEmitFixup(GV) && !getTargetMachine().shouldAssumeDSOLocal(GV);
62246223
}
62256224

62266225
bool SITargetLowering::shouldEmitPCReloc(const GlobalValue *GV) const {

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2655,12 +2655,10 @@ ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
26552655
bool isDirect = false;
26562656

26572657
const TargetMachine &TM = getTargetMachine();
2658-
const Module *Mod = MF.getFunction().getParent();
26592658
const GlobalValue *GVal = nullptr;
26602659
if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee))
26612660
GVal = G->getGlobal();
2662-
bool isStub =
2663-
!TM.shouldAssumeDSOLocal(*Mod, GVal) && Subtarget->isTargetMachO();
2661+
bool isStub = !TM.shouldAssumeDSOLocal(GVal) && Subtarget->isTargetMachO();
26642662

26652663
bool isARMFunc = !Subtarget->isThumb() || (isStub && !Subtarget->isMClass());
26662664
bool isLocalARMFunc = false;
@@ -2737,7 +2735,7 @@ ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
27372735
unsigned TargetFlags = ARMII::MO_NO_FLAG;
27382736
if (GVal->hasDLLImportStorageClass())
27392737
TargetFlags = ARMII::MO_DLLIMPORT;
2740-
else if (!TM.shouldAssumeDSOLocal(*GVal->getParent(), GVal))
2738+
else if (!TM.shouldAssumeDSOLocal(GVal))
27412739
TargetFlags = ARMII::MO_COFFSTUB;
27422740
Callee = DAG.getTargetGlobalAddress(GVal, dl, PtrVt, /*offset=*/0,
27432741
TargetFlags);
@@ -4021,7 +4019,7 @@ SDValue ARMTargetLowering::LowerGlobalAddressWindows(SDValue Op,
40214019
ARMII::TOF TargetFlags = ARMII::MO_NO_FLAG;
40224020
if (GV->hasDLLImportStorageClass())
40234021
TargetFlags = ARMII::MO_DLLIMPORT;
4024-
else if (!TM.shouldAssumeDSOLocal(*GV->getParent(), GV))
4022+
else if (!TM.shouldAssumeDSOLocal(GV))
40254023
TargetFlags = ARMII::MO_COFFSTUB;
40264024
EVT PtrVT = getPointerTy(DAG.getDataLayout());
40274025
SDValue Result;

llvm/lib/Target/ARM/ARMSubtarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ bool ARMSubtarget::isRWPI() const {
353353
}
354354

355355
bool ARMSubtarget::isGVIndirectSymbol(const GlobalValue *GV) const {
356-
if (!TM.shouldAssumeDSOLocal(*GV->getParent(), GV))
356+
if (!TM.shouldAssumeDSOLocal(GV))
357357
return true;
358358

359359
// 32 bit macho has no relocation for a-b if a is undefined, even if b is in

llvm/lib/Target/CSKY/CSKYISelLowering.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,7 @@ SDValue CSKYTargetLowering::LowerCall(CallLoweringInfo &CLI,
649649

650650
if (GlobalAddressSDNode *S = dyn_cast<GlobalAddressSDNode>(Callee)) {
651651
const GlobalValue *GV = S->getGlobal();
652-
bool IsLocal =
653-
getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV);
652+
bool IsLocal = getTargetMachine().shouldAssumeDSOLocal(GV);
654653

655654
if (isPositionIndependent() || !Subtarget.has2E3()) {
656655
IsRegCall = true;
@@ -662,8 +661,7 @@ SDValue CSKYTargetLowering::LowerCall(CallLoweringInfo &CLI,
662661
cast<GlobalAddressSDNode>(Callee), Ty, DAG, CSKYII::MO_None));
663662
}
664663
} else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee)) {
665-
bool IsLocal = getTargetMachine().shouldAssumeDSOLocal(
666-
*MF.getFunction().getParent(), nullptr);
664+
bool IsLocal = getTargetMachine().shouldAssumeDSOLocal(nullptr);
667665

668666
if (isPositionIndependent() || !Subtarget.has2E3()) {
669667
IsRegCall = true;
@@ -1153,7 +1151,7 @@ SDValue CSKYTargetLowering::LowerGlobalAddress(SDValue Op,
11531151
int64_t Offset = N->getOffset();
11541152

11551153
const GlobalValue *GV = N->getGlobal();
1156-
bool IsLocal = getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV);
1154+
bool IsLocal = getTargetMachine().shouldAssumeDSOLocal(GV);
11571155
SDValue Addr = getAddr<GlobalAddressSDNode, false>(N, DAG, IsLocal);
11581156

11591157
// In order to maximise the opportunity for common subexpression elimination,

llvm/lib/Target/Hexagon/HexagonISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ HexagonTargetLowering::LowerGLOBALADDRESS(SDValue Op, SelectionDAG &DAG) const {
12381238
return DAG.getNode(HexagonISD::CONST32, dl, PtrVT, GA);
12391239
}
12401240

1241-
bool UsePCRel = getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV);
1241+
bool UsePCRel = getTargetMachine().shouldAssumeDSOLocal(GV);
12421242
if (UsePCRel) {
12431243
SDValue GA = DAG.getTargetGlobalAddress(GV, dl, PtrVT, Offset,
12441244
HexagonII::MO_PCREL);

llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4251,14 +4251,12 @@ LoongArchTargetLowering::LowerCall(CallLoweringInfo &CLI,
42514251
// split it and then direct call can be matched by PseudoCALL.
42524252
if (GlobalAddressSDNode *S = dyn_cast<GlobalAddressSDNode>(Callee)) {
42534253
const GlobalValue *GV = S->getGlobal();
4254-
unsigned OpFlags =
4255-
getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV)
4256-
? LoongArchII::MO_CALL
4257-
: LoongArchII::MO_CALL_PLT;
4254+
unsigned OpFlags = getTargetMachine().shouldAssumeDSOLocal(GV)
4255+
? LoongArchII::MO_CALL
4256+
: LoongArchII::MO_CALL_PLT;
42584257
Callee = DAG.getTargetGlobalAddress(S->getGlobal(), DL, PtrVT, 0, OpFlags);
42594258
} else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee)) {
4260-
unsigned OpFlags = getTargetMachine().shouldAssumeDSOLocal(
4261-
*MF.getFunction().getParent(), nullptr)
4259+
unsigned OpFlags = getTargetMachine().shouldAssumeDSOLocal(nullptr)
42624260
? LoongArchII::MO_CALL
42634261
: LoongArchII::MO_CALL_PLT;
42644262
Callee = DAG.getTargetExternalSymbol(S->getSymbol(), PtrVT, OpFlags);

llvm/lib/Target/M68k/M68kSubtarget.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ M68kSubtarget::classifyLocalReference(const GlobalValue *GV) const {
175175
}
176176

177177
unsigned char M68kSubtarget::classifyExternalReference(const Module &M) const {
178-
if (TM.shouldAssumeDSOLocal(M, nullptr))
178+
if (TM.shouldAssumeDSOLocal(nullptr))
179179
return classifyLocalReference(nullptr);
180180

181181
if (isPositionIndependent())
@@ -191,7 +191,7 @@ M68kSubtarget::classifyGlobalReference(const GlobalValue *GV) const {
191191

192192
unsigned char M68kSubtarget::classifyGlobalReference(const GlobalValue *GV,
193193
const Module &M) const {
194-
if (TM.shouldAssumeDSOLocal(M, GV))
194+
if (TM.shouldAssumeDSOLocal(GV))
195195
return classifyLocalReference(GV);
196196

197197
switch (TM.getCodeModel()) {
@@ -240,7 +240,7 @@ unsigned char
240240
M68kSubtarget::classifyGlobalFunctionReference(const GlobalValue *GV,
241241
const Module &M) const {
242242
// local always use pc-rel referencing
243-
if (TM.shouldAssumeDSOLocal(M, GV))
243+
if (TM.shouldAssumeDSOLocal(GV))
244244
return M68kII::MO_NO_FLAG;
245245

246246
// If the function is marked as non-lazy, generate an indirect call

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4818,7 +4818,7 @@ static bool callsShareTOCBase(const Function *Caller,
48184818
// If the callee is preemptable, then the static linker will use a plt-stub
48194819
// which saves the toc to the stack, and needs a nop after the call
48204820
// instruction to convert to a toc-restore.
4821-
if (!TM.shouldAssumeDSOLocal(*Caller->getParent(), CalleeGV))
4821+
if (!TM.shouldAssumeDSOLocal(CalleeGV))
48224822
return false;
48234823

48244824
// Functions with PC Relative enabled may clobber the TOC in the same DSO.
@@ -5420,10 +5420,9 @@ static SDValue transformCallee(const SDValue &Callee, SelectionDAG &DAG,
54205420
// Returns true if the callee is local, and false otherwise.
54215421
auto isLocalCallee = [&]() {
54225422
const GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee);
5423-
const Module *Mod = DAG.getMachineFunction().getFunction().getParent();
54245423
const GlobalValue *GV = G ? G->getGlobal() : nullptr;
54255424

5426-
return DAG.getTarget().shouldAssumeDSOLocal(*Mod, GV) &&
5425+
return DAG.getTarget().shouldAssumeDSOLocal(GV) &&
54275426
!isa_and_nonnull<GlobalIFunc>(GV);
54285427
};
54295428

@@ -18045,7 +18044,7 @@ bool PPCTargetLowering::mayBeEmittedAsTailCall(const CallInst *CI) const {
1804518044
return false;
1804618045

1804718046
// If the function is local then we have a good chance at tail-calling it
18048-
return getTargetMachine().shouldAssumeDSOLocal(*Caller->getParent(), Callee);
18047+
return getTargetMachine().shouldAssumeDSOLocal(Callee);
1804918048
}
1805018049

1805118050
bool PPCTargetLowering::

llvm/lib/Target/PowerPC/PPCSubtarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ bool PPCSubtarget::isGVIndirectSymbol(const GlobalValue *GV) const {
189189
// Large code model always uses the TOC even for local symbols.
190190
if (TM.getCodeModel() == CodeModel::Large)
191191
return true;
192-
if (TM.shouldAssumeDSOLocal(*GV->getParent(), GV))
192+
if (TM.shouldAssumeDSOLocal(GV))
193193
return false;
194194
return true;
195195
}

llvm/lib/Target/SystemZ/SystemZSubtarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV,
122122

123123
// For the small model, all locally-binding symbols are in range.
124124
if (CM == CodeModel::Small)
125-
return TLInfo.getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV);
125+
return TLInfo.getTargetMachine().shouldAssumeDSOLocal(GV);
126126

127127
// For Medium and above, assume that the symbol is not within the 4GB range.
128128
// Taking the address of locally-defined text would be OK, but that

llvm/lib/Target/TargetMachine.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ static TLSModel::Model getSelectedTLSModel(const GlobalValue *GV) {
160160
llvm_unreachable("invalid TLS model");
161161
}
162162

163-
bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
164-
const GlobalValue *GV) const {
163+
bool TargetMachine::shouldAssumeDSOLocal(const GlobalValue *GV) const {
165164
const Triple &TT = getTargetTriple();
166165
Reloc::Model RM = getRelocationModel();
167166

@@ -225,7 +224,7 @@ TLSModel::Model TargetMachine::getTLSModel(const GlobalValue *GV) const {
225224
bool IsPIE = GV->getParent()->getPIELevel() != PIELevel::Default;
226225
Reloc::Model RM = getRelocationModel();
227226
bool IsSharedLibrary = RM == Reloc::PIC_ && !IsPIE;
228-
bool IsLocal = shouldAssumeDSOLocal(*GV->getParent(), GV);
227+
bool IsLocal = shouldAssumeDSOLocal(GV);
229228

230229
TLSModel::Model Model;
231230
if (IsSharedLibrary) {

llvm/lib/Target/VE/VEISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ SDValue VETargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
653653
auto *CalleeG = dyn_cast<GlobalAddressSDNode>(Callee);
654654
if (CalleeG)
655655
GV = CalleeG->getGlobal();
656-
bool Local = TM.shouldAssumeDSOLocal(*Mod, GV);
656+
bool Local = TM.shouldAssumeDSOLocal(GV);
657657
bool UsePlt = !Local;
658658
MachineFunction &MF = DAG.getMachineFunction();
659659

llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,7 +1683,7 @@ WebAssemblyTargetLowering::LowerGlobalTLSAddress(SDValue Op,
16831683
if (model == GlobalValue::LocalExecTLSModel ||
16841684
model == GlobalValue::LocalDynamicTLSModel ||
16851685
(model == GlobalValue::GeneralDynamicTLSModel &&
1686-
getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV))) {
1686+
getTargetMachine().shouldAssumeDSOLocal(GV))) {
16871687
// For DSO-local TLS variables we use offset from __tls_base
16881688

16891689
MVT PtrVT = getPointerTy(DAG.getDataLayout());
@@ -1729,7 +1729,7 @@ SDValue WebAssemblyTargetLowering::LowerGlobalAddress(SDValue Op,
17291729
// need special treatment for tables in PIC mode.
17301730
if (isPositionIndependent() &&
17311731
!WebAssembly::isWebAssemblyTableType(GV->getValueType())) {
1732-
if (getTargetMachine().shouldAssumeDSOLocal(*GV->getParent(), GV)) {
1732+
if (getTargetMachine().shouldAssumeDSOLocal(GV)) {
17331733
MachineFunction &MF = DAG.getMachineFunction();
17341734
MVT PtrVT = getPointerTy(MF.getDataLayout());
17351735
const char *BaseName;

llvm/lib/Target/X86/X86Subtarget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ unsigned char X86Subtarget::classifyGlobalReference(const GlobalValue *GV,
140140
}
141141
}
142142

143-
if (TM.shouldAssumeDSOLocal(M, GV))
143+
if (TM.shouldAssumeDSOLocal(GV))
144144
return classifyLocalReference(GV);
145145

146146
if (isTargetCOFF()) {
@@ -190,7 +190,7 @@ X86Subtarget::classifyGlobalFunctionReference(const GlobalValue *GV) const {
190190
unsigned char
191191
X86Subtarget::classifyGlobalFunctionReference(const GlobalValue *GV,
192192
const Module &M) const {
193-
if (TM.shouldAssumeDSOLocal(M, GV))
193+
if (TM.shouldAssumeDSOLocal(GV))
194194
return X86II::MO_NO_FLAG;
195195

196196
// Functions on COFF can be non-DSO local for three reasons:

0 commit comments

Comments
 (0)