Skip to content

Commit 2da20d8

Browse files
committed
[AMDGPU] Remove isKernelLDS, add isKernel(const Function &). NFC.
Since llvm#142598 isKernelLDS has been a pointless wrapper around isKernel.
1 parent ff1efe9 commit 2da20d8

File tree

8 files changed

+28
-32
lines changed

8 files changed

+28
-32
lines changed

llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7724,7 +7724,7 @@ bool AMDGPULegalizerInfo::legalizeIntrinsic(LegalizerHelper &Helper,
77247724
case Intrinsic::amdgcn_make_buffer_rsrc:
77257725
return legalizePointerAsRsrcIntrin(MI, MRI, B);
77267726
case Intrinsic::amdgcn_kernarg_segment_ptr:
7727-
if (!AMDGPU::isKernel(B.getMF().getFunction().getCallingConv())) {
7727+
if (!AMDGPU::isKernel(B.getMF().getFunction())) {
77287728
// This only makes sense to call in a kernel, so just lower to null.
77297729
B.buildConstant(MI.getOperand(0).getReg(), 0);
77307730
MI.eraseFromParent();

llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ class AMDGPULowerModuleLDS {
441441
return KernelSet;
442442

443443
for (Function &Func : M.functions()) {
444-
if (Func.isDeclaration() || !isKernelLDS(&Func))
444+
if (Func.isDeclaration() || !isKernel(Func))
445445
continue;
446446
for (GlobalVariable *GV : LDSUsesInfo.indirect_access[&Func]) {
447447
if (VariableSet.contains(GV)) {
@@ -555,7 +555,7 @@ class AMDGPULowerModuleLDS {
555555
for (Function &Func : M->functions()) {
556556
if (Func.isDeclaration())
557557
continue;
558-
if (!isKernelLDS(&Func))
558+
if (!isKernel(Func))
559559
continue;
560560

561561
if (KernelsThatAllocateTableLDS.contains(&Func) ||
@@ -703,15 +703,15 @@ class AMDGPULowerModuleLDS {
703703
return false;
704704
}
705705
Function *F = I->getFunction();
706-
return !isKernelLDS(F);
706+
return !isKernel(*F);
707707
});
708708

709709
// Replace uses of module scope variable from kernel functions that
710710
// allocate the module scope variable, otherwise leave them unchanged
711711
// Record on each kernel whether the module scope global is used by it
712712

713713
for (Function &Func : M.functions()) {
714-
if (Func.isDeclaration() || !isKernelLDS(&Func))
714+
if (Func.isDeclaration() || !isKernel(Func))
715715
continue;
716716

717717
if (KernelsThatAllocateModuleLDS.contains(&Func)) {
@@ -743,7 +743,7 @@ class AMDGPULowerModuleLDS {
743743

744744
DenseMap<Function *, LDSVariableReplacement> KernelToReplacement;
745745
for (Function &Func : M.functions()) {
746-
if (Func.isDeclaration() || !isKernelLDS(&Func))
746+
if (Func.isDeclaration() || !isKernel(Func))
747747
continue;
748748

749749
DenseSet<GlobalVariable *> KernelUsedVariables;
@@ -828,7 +828,7 @@ class AMDGPULowerModuleLDS {
828828
// semantics. Setting the alignment here allows this IR pass to accurately
829829
// predict the exact constant at which it will be allocated.
830830

831-
assert(isKernelLDS(func));
831+
assert(isKernel(*func));
832832

833833
LLVMContext &Ctx = M.getContext();
834834
const DataLayout &DL = M.getDataLayout();
@@ -878,7 +878,7 @@ class AMDGPULowerModuleLDS {
878878
for (auto &func : OrderedKernels) {
879879

880880
if (KernelsThatIndirectlyAllocateDynamicLDS.contains(func)) {
881-
assert(isKernelLDS(func));
881+
assert(isKernel(*func));
882882
if (!func->hasName()) {
883883
reportFatalUsageError("anonymous kernels cannot use LDS variables");
884884
}
@@ -912,7 +912,7 @@ class AMDGPULowerModuleLDS {
912912
auto *I = dyn_cast<Instruction>(U.getUser());
913913
if (!I)
914914
continue;
915-
if (isKernelLDS(I->getFunction()))
915+
if (isKernel(*I->getFunction()))
916916
continue;
917917

918918
replaceUseWithTableLookup(M, Builder, table, GV, U, nullptr);
@@ -928,7 +928,7 @@ class AMDGPULowerModuleLDS {
928928
for (Use &U : GV->uses()) {
929929
if (auto *I = dyn_cast<Instruction>(U.getUser())) {
930930
Function *F = I->getFunction();
931-
if (isKernelLDS(F) && F != KF) {
931+
if (isKernel(*F) && F != KF) {
932932
NeedsReplacement = true;
933933
break;
934934
}
@@ -945,7 +945,7 @@ class AMDGPULowerModuleLDS {
945945
for (Use &U : make_early_inc_range(GV->uses())) {
946946
if (auto *I = dyn_cast<Instruction>(U.getUser())) {
947947
Function *F = I->getFunction();
948-
if (!isKernelLDS(F) || F == KF) {
948+
if (!isKernel(*F) || F == KF) {
949949
U.getUser()->replaceUsesOfWith(GV, NewGV);
950950
}
951951
}
@@ -997,7 +997,7 @@ class AMDGPULowerModuleLDS {
997997
std::vector<Function *> OrderedKernels;
998998
for (auto &K : LDSUsesInfo.direct_access) {
999999
Function *F = K.first;
1000-
assert(isKernelLDS(F));
1000+
assert(isKernel(*F));
10011001
OrderedKernels.push_back(F);
10021002
}
10031003
OrderedKernels = sortByName(std::move(OrderedKernels));
@@ -1033,7 +1033,7 @@ class AMDGPULowerModuleLDS {
10331033
}
10341034
// Also erase those special LDS variables from indirect_access.
10351035
for (auto &K : LDSUsesInfo.indirect_access) {
1036-
assert(isKernelLDS(K.first));
1036+
assert(isKernel(*K.first));
10371037
for (GlobalVariable *GV : K.second) {
10381038
if (isNamedBarrier(*GV))
10391039
K.second.erase(GV);
@@ -1058,7 +1058,7 @@ class AMDGPULowerModuleLDS {
10581058
VariableFunctionMap LDSToKernelsThatNeedToAccessItIndirectly;
10591059
for (auto &K : LDSUsesInfo.indirect_access) {
10601060
Function *F = K.first;
1061-
assert(isKernelLDS(F));
1061+
assert(isKernel(*F));
10621062
for (GlobalVariable *GV : K.second) {
10631063
LDSToKernelsThatNeedToAccessItIndirectly[GV].insert(F);
10641064
}
@@ -1157,7 +1157,7 @@ class AMDGPULowerModuleLDS {
11571157
const DataLayout &DL = M.getDataLayout();
11581158

11591159
for (Function &Func : M.functions()) {
1160-
if (Func.isDeclaration() || !isKernelLDS(&Func))
1160+
if (Func.isDeclaration() || !isKernel(Func))
11611161
continue;
11621162

11631163
// All three of these are optional. The first variable is allocated at

llvm/lib/Target/AMDGPU/AMDGPUMemoryUtils.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void getUsesOfLDSByFunction(const CallGraph &CG, Module &M,
126126
for (User *V : GV.users()) {
127127
if (auto *I = dyn_cast<Instruction>(V)) {
128128
Function *F = I->getFunction();
129-
if (isKernelLDS(F))
129+
if (isKernel(*F))
130130
kernels[F].insert(&GV);
131131
else
132132
Functions[F].insert(&GV);
@@ -135,10 +135,6 @@ void getUsesOfLDSByFunction(const CallGraph &CG, Module &M,
135135
}
136136
}
137137

138-
bool isKernelLDS(const Function *F) {
139-
return AMDGPU::isKernel(F->getCallingConv());
140-
}
141-
142138
LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
143139

144140
FunctionVariableMap DirectMapKernel;
@@ -148,7 +144,7 @@ LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
148144
// Collect functions whose address has escaped
149145
DenseSet<Function *> AddressTakenFuncs;
150146
for (Function &F : M.functions()) {
151-
if (!isKernelLDS(&F))
147+
if (!isKernel(F))
152148
if (F.hasAddressTaken(nullptr,
153149
/* IgnoreCallbackUses */ false,
154150
/* IgnoreAssumeLikeCalls */ false,
@@ -180,7 +176,7 @@ LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
180176
// access all variables accessed by functions whose address escaped
181177
for (Function &F : M.functions()) {
182178
if (!F.isDeclaration() && FunctionMakesUnknownCall(&F)) {
183-
if (!isKernelLDS(&F)) {
179+
if (!isKernel(F)) {
184180
set_union(TransitiveMapFunction[&F],
185181
VariablesReachableThroughFunctionPointer);
186182
}
@@ -190,7 +186,7 @@ LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
190186
// Direct implementation of collecting all variables reachable from each
191187
// function
192188
for (Function &Func : M.functions()) {
193-
if (Func.isDeclaration() || isKernelLDS(&Func))
189+
if (Func.isDeclaration() || isKernel(Func))
194190
continue;
195191

196192
DenseSet<Function *> seen; // catches cycles
@@ -227,7 +223,7 @@ LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
227223
FunctionVariableMap IndirectMapKernel;
228224

229225
for (Function &Func : M.functions()) {
230-
if (Func.isDeclaration() || !isKernelLDS(&Func))
226+
if (Func.isDeclaration() || !isKernel(Func))
231227
continue;
232228

233229
for (const CallGraphNode::CallRecord &R : *CG[&Func]) {
@@ -335,7 +331,7 @@ void removeFnAttrFromReachable(CallGraph &CG, Function *KernelRoot,
335331
Function *PotentialCallee =
336332
ExternalCallRecord.second->getFunction();
337333
assert(PotentialCallee);
338-
if (!isKernelLDS(PotentialCallee)) {
334+
if (!isKernel(*PotentialCallee)) {
339335
for (StringRef Attr : FnAttrs)
340336
PotentialCallee->removeFnAttr(Attr);
341337
}

llvm/lib/Target/AMDGPU/AMDGPUMemoryUtils.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ void getUsesOfLDSByFunction(const CallGraph &CG, Module &M,
5353
FunctionVariableMap &kernels,
5454
FunctionVariableMap &functions);
5555

56-
bool isKernelLDS(const Function *F);
57-
5856
LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M);
5957

6058
/// Strip FnAttr attribute from any functions where we may have

llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ bool AMDGPUSubtarget::makeLIDRangeMetadata(Instruction *I) const {
350350
}
351351

352352
unsigned AMDGPUSubtarget::getImplicitArgNumBytes(const Function &F) const {
353-
assert(AMDGPU::isKernel(F.getCallingConv()));
353+
assert(AMDGPU::isKernel(F));
354354

355355
// We don't allocate the segment if we know the implicit arguments weren't
356356
// used, even if the ABI implies we need them.

llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ void AMDGPUSwLowerLDS::getNonKernelsWithLDSArguments(const CallGraph &CG) {
271271
Function *CalledFunc = CallerCGN->getFunction();
272272
if (!CalledFunc || CalledFunc->isDeclaration())
273273
continue;
274-
if (AMDGPU::isKernelLDS(CalledFunc))
274+
if (AMDGPU::isKernel(*CalledFunc))
275275
continue;
276276
for (auto AI = CalledFunc->arg_begin(), E = CalledFunc->arg_end();
277277
AI != E; ++AI) {
@@ -297,7 +297,7 @@ void AMDGPUSwLowerLDS::getUsesOfLDSByNonKernels() {
297297
for (User *V : GV->users()) {
298298
if (auto *I = dyn_cast<Instruction>(V)) {
299299
Function *F = I->getFunction();
300-
if (!isKernelLDS(F) && !F->isDeclaration())
300+
if (!isKernel(*F) && !F->isDeclaration())
301301
FuncLDSAccessInfo.NonKernelToLDSAccessMap[F].insert(GV);
302302
}
303303
}
@@ -1169,7 +1169,7 @@ bool AMDGPUSwLowerLDS::run() {
11691169
if (!F || K.second.empty())
11701170
continue;
11711171

1172-
assert(isKernelLDS(F));
1172+
assert(isKernel(*F));
11731173

11741174
// Only inserts if key isn't already in the map.
11751175
FuncLDSAccessInfo.KernelToLDSParametersMap.insert(

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9737,7 +9737,7 @@ SDValue SITargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
97379737
AMDGPUFunctionArgInfo::IMPLICIT_ARG_PTR);
97389738
}
97399739
case Intrinsic::amdgcn_kernarg_segment_ptr: {
9740-
if (!AMDGPU::isKernel(MF.getFunction().getCallingConv())) {
9740+
if (!AMDGPU::isKernel(MF.getFunction())) {
97419741
// This only makes sense to call in a kernel, so just lower to null.
97429742
return DAG.getConstant(0, DL, VT);
97439743
}

llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,6 +1513,8 @@ constexpr inline bool isKernel(CallingConv::ID CC) {
15131513
}
15141514
}
15151515

1516+
inline bool isKernel(const Function &F) { return isKernel(F.getCallingConv()); }
1517+
15161518
LLVM_READNONE
15171519
constexpr bool canGuaranteeTCO(CallingConv::ID CC) {
15181520
return CC == CallingConv::Fast;

0 commit comments

Comments
 (0)