-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[AMDGPU] Remove isKernelLDS, add isKernel(const Function &). NFC. #167300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jayfoad
wants to merge
1
commit into
llvm:main
Choose a base branch
from
jayfoad:remove-iskernellds
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+28
−32
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Since llvm#142598 isKernelLDS has been a pointless wrapper around isKernel.
Member
|
@llvm/pr-subscribers-backend-amdgpu Author: Jay Foad (jayfoad) ChangesSince #142598 isKernelLDS has been a pointless wrapper around isKernel. Full diff: https://github.com/llvm/llvm-project/pull/167300.diff 8 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
index 1a13b2226ecd6..8b4396cd63e9a 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
@@ -7724,7 +7724,7 @@ bool AMDGPULegalizerInfo::legalizeIntrinsic(LegalizerHelper &Helper,
case Intrinsic::amdgcn_make_buffer_rsrc:
return legalizePointerAsRsrcIntrin(MI, MRI, B);
case Intrinsic::amdgcn_kernarg_segment_ptr:
- if (!AMDGPU::isKernel(B.getMF().getFunction().getCallingConv())) {
+ if (!AMDGPU::isKernel(B.getMF().getFunction())) {
// This only makes sense to call in a kernel, so just lower to null.
B.buildConstant(MI.getOperand(0).getReg(), 0);
MI.eraseFromParent();
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
index a4ef524c43466..56365284ffe32 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
@@ -441,7 +441,7 @@ class AMDGPULowerModuleLDS {
return KernelSet;
for (Function &Func : M.functions()) {
- if (Func.isDeclaration() || !isKernelLDS(&Func))
+ if (Func.isDeclaration() || !isKernel(Func))
continue;
for (GlobalVariable *GV : LDSUsesInfo.indirect_access[&Func]) {
if (VariableSet.contains(GV)) {
@@ -555,7 +555,7 @@ class AMDGPULowerModuleLDS {
for (Function &Func : M->functions()) {
if (Func.isDeclaration())
continue;
- if (!isKernelLDS(&Func))
+ if (!isKernel(Func))
continue;
if (KernelsThatAllocateTableLDS.contains(&Func) ||
@@ -703,7 +703,7 @@ class AMDGPULowerModuleLDS {
return false;
}
Function *F = I->getFunction();
- return !isKernelLDS(F);
+ return !isKernel(*F);
});
// Replace uses of module scope variable from kernel functions that
@@ -711,7 +711,7 @@ class AMDGPULowerModuleLDS {
// Record on each kernel whether the module scope global is used by it
for (Function &Func : M.functions()) {
- if (Func.isDeclaration() || !isKernelLDS(&Func))
+ if (Func.isDeclaration() || !isKernel(Func))
continue;
if (KernelsThatAllocateModuleLDS.contains(&Func)) {
@@ -743,7 +743,7 @@ class AMDGPULowerModuleLDS {
DenseMap<Function *, LDSVariableReplacement> KernelToReplacement;
for (Function &Func : M.functions()) {
- if (Func.isDeclaration() || !isKernelLDS(&Func))
+ if (Func.isDeclaration() || !isKernel(Func))
continue;
DenseSet<GlobalVariable *> KernelUsedVariables;
@@ -828,7 +828,7 @@ class AMDGPULowerModuleLDS {
// semantics. Setting the alignment here allows this IR pass to accurately
// predict the exact constant at which it will be allocated.
- assert(isKernelLDS(func));
+ assert(isKernel(*func));
LLVMContext &Ctx = M.getContext();
const DataLayout &DL = M.getDataLayout();
@@ -878,7 +878,7 @@ class AMDGPULowerModuleLDS {
for (auto &func : OrderedKernels) {
if (KernelsThatIndirectlyAllocateDynamicLDS.contains(func)) {
- assert(isKernelLDS(func));
+ assert(isKernel(*func));
if (!func->hasName()) {
reportFatalUsageError("anonymous kernels cannot use LDS variables");
}
@@ -912,7 +912,7 @@ class AMDGPULowerModuleLDS {
auto *I = dyn_cast<Instruction>(U.getUser());
if (!I)
continue;
- if (isKernelLDS(I->getFunction()))
+ if (isKernel(*I->getFunction()))
continue;
replaceUseWithTableLookup(M, Builder, table, GV, U, nullptr);
@@ -928,7 +928,7 @@ class AMDGPULowerModuleLDS {
for (Use &U : GV->uses()) {
if (auto *I = dyn_cast<Instruction>(U.getUser())) {
Function *F = I->getFunction();
- if (isKernelLDS(F) && F != KF) {
+ if (isKernel(*F) && F != KF) {
NeedsReplacement = true;
break;
}
@@ -945,7 +945,7 @@ class AMDGPULowerModuleLDS {
for (Use &U : make_early_inc_range(GV->uses())) {
if (auto *I = dyn_cast<Instruction>(U.getUser())) {
Function *F = I->getFunction();
- if (!isKernelLDS(F) || F == KF) {
+ if (!isKernel(*F) || F == KF) {
U.getUser()->replaceUsesOfWith(GV, NewGV);
}
}
@@ -997,7 +997,7 @@ class AMDGPULowerModuleLDS {
std::vector<Function *> OrderedKernels;
for (auto &K : LDSUsesInfo.direct_access) {
Function *F = K.first;
- assert(isKernelLDS(F));
+ assert(isKernel(*F));
OrderedKernels.push_back(F);
}
OrderedKernels = sortByName(std::move(OrderedKernels));
@@ -1033,7 +1033,7 @@ class AMDGPULowerModuleLDS {
}
// Also erase those special LDS variables from indirect_access.
for (auto &K : LDSUsesInfo.indirect_access) {
- assert(isKernelLDS(K.first));
+ assert(isKernel(*K.first));
for (GlobalVariable *GV : K.second) {
if (isNamedBarrier(*GV))
K.second.erase(GV);
@@ -1058,7 +1058,7 @@ class AMDGPULowerModuleLDS {
VariableFunctionMap LDSToKernelsThatNeedToAccessItIndirectly;
for (auto &K : LDSUsesInfo.indirect_access) {
Function *F = K.first;
- assert(isKernelLDS(F));
+ assert(isKernel(*F));
for (GlobalVariable *GV : K.second) {
LDSToKernelsThatNeedToAccessItIndirectly[GV].insert(F);
}
@@ -1157,7 +1157,7 @@ class AMDGPULowerModuleLDS {
const DataLayout &DL = M.getDataLayout();
for (Function &Func : M.functions()) {
- if (Func.isDeclaration() || !isKernelLDS(&Func))
+ if (Func.isDeclaration() || !isKernel(Func))
continue;
// All three of these are optional. The first variable is allocated at
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUMemoryUtils.cpp b/llvm/lib/Target/AMDGPU/AMDGPUMemoryUtils.cpp
index e17c2113ca398..f274471ffe6a4 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUMemoryUtils.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUMemoryUtils.cpp
@@ -126,7 +126,7 @@ void getUsesOfLDSByFunction(const CallGraph &CG, Module &M,
for (User *V : GV.users()) {
if (auto *I = dyn_cast<Instruction>(V)) {
Function *F = I->getFunction();
- if (isKernelLDS(F))
+ if (isKernel(*F))
kernels[F].insert(&GV);
else
Functions[F].insert(&GV);
@@ -135,10 +135,6 @@ void getUsesOfLDSByFunction(const CallGraph &CG, Module &M,
}
}
-bool isKernelLDS(const Function *F) {
- return AMDGPU::isKernel(F->getCallingConv());
-}
-
LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
FunctionVariableMap DirectMapKernel;
@@ -148,7 +144,7 @@ LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
// Collect functions whose address has escaped
DenseSet<Function *> AddressTakenFuncs;
for (Function &F : M.functions()) {
- if (!isKernelLDS(&F))
+ if (!isKernel(F))
if (F.hasAddressTaken(nullptr,
/* IgnoreCallbackUses */ false,
/* IgnoreAssumeLikeCalls */ false,
@@ -180,7 +176,7 @@ LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
// access all variables accessed by functions whose address escaped
for (Function &F : M.functions()) {
if (!F.isDeclaration() && FunctionMakesUnknownCall(&F)) {
- if (!isKernelLDS(&F)) {
+ if (!isKernel(F)) {
set_union(TransitiveMapFunction[&F],
VariablesReachableThroughFunctionPointer);
}
@@ -190,7 +186,7 @@ LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
// Direct implementation of collecting all variables reachable from each
// function
for (Function &Func : M.functions()) {
- if (Func.isDeclaration() || isKernelLDS(&Func))
+ if (Func.isDeclaration() || isKernel(Func))
continue;
DenseSet<Function *> seen; // catches cycles
@@ -227,7 +223,7 @@ LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
FunctionVariableMap IndirectMapKernel;
for (Function &Func : M.functions()) {
- if (Func.isDeclaration() || !isKernelLDS(&Func))
+ if (Func.isDeclaration() || !isKernel(Func))
continue;
for (const CallGraphNode::CallRecord &R : *CG[&Func]) {
@@ -335,7 +331,7 @@ void removeFnAttrFromReachable(CallGraph &CG, Function *KernelRoot,
Function *PotentialCallee =
ExternalCallRecord.second->getFunction();
assert(PotentialCallee);
- if (!isKernelLDS(PotentialCallee)) {
+ if (!isKernel(*PotentialCallee)) {
for (StringRef Attr : FnAttrs)
PotentialCallee->removeFnAttr(Attr);
}
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUMemoryUtils.h b/llvm/lib/Target/AMDGPU/AMDGPUMemoryUtils.h
index 058e74452573c..8868b93440768 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUMemoryUtils.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUMemoryUtils.h
@@ -53,8 +53,6 @@ void getUsesOfLDSByFunction(const CallGraph &CG, Module &M,
FunctionVariableMap &kernels,
FunctionVariableMap &functions);
-bool isKernelLDS(const Function *F);
-
LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M);
/// Strip FnAttr attribute from any functions where we may have
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp b/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
index 26e0b3dfc2e8a..38e7e17b85491 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
@@ -350,7 +350,7 @@ bool AMDGPUSubtarget::makeLIDRangeMetadata(Instruction *I) const {
}
unsigned AMDGPUSubtarget::getImplicitArgNumBytes(const Function &F) const {
- assert(AMDGPU::isKernel(F.getCallingConv()));
+ assert(AMDGPU::isKernel(F));
// We don't allocate the segment if we know the implicit arguments weren't
// used, even if the ABI implies we need them.
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp b/llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp
index 4a9437b37aa39..722b71b38141b 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp
@@ -271,7 +271,7 @@ void AMDGPUSwLowerLDS::getNonKernelsWithLDSArguments(const CallGraph &CG) {
Function *CalledFunc = CallerCGN->getFunction();
if (!CalledFunc || CalledFunc->isDeclaration())
continue;
- if (AMDGPU::isKernelLDS(CalledFunc))
+ if (AMDGPU::isKernel(*CalledFunc))
continue;
for (auto AI = CalledFunc->arg_begin(), E = CalledFunc->arg_end();
AI != E; ++AI) {
@@ -297,7 +297,7 @@ void AMDGPUSwLowerLDS::getUsesOfLDSByNonKernels() {
for (User *V : GV->users()) {
if (auto *I = dyn_cast<Instruction>(V)) {
Function *F = I->getFunction();
- if (!isKernelLDS(F) && !F->isDeclaration())
+ if (!isKernel(*F) && !F->isDeclaration())
FuncLDSAccessInfo.NonKernelToLDSAccessMap[F].insert(GV);
}
}
@@ -1169,7 +1169,7 @@ bool AMDGPUSwLowerLDS::run() {
if (!F || K.second.empty())
continue;
- assert(isKernelLDS(F));
+ assert(isKernel(*F));
// Only inserts if key isn't already in the map.
FuncLDSAccessInfo.KernelToLDSParametersMap.insert(
diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
index 8bb28084159e8..528ea73184a14 100644
--- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -9737,7 +9737,7 @@ SDValue SITargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
AMDGPUFunctionArgInfo::IMPLICIT_ARG_PTR);
}
case Intrinsic::amdgcn_kernarg_segment_ptr: {
- if (!AMDGPU::isKernel(MF.getFunction().getCallingConv())) {
+ if (!AMDGPU::isKernel(MF.getFunction())) {
// This only makes sense to call in a kernel, so just lower to null.
return DAG.getConstant(0, DL, VT);
}
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
index 5e3195b36fe4c..86b3cf767e565 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
@@ -1513,6 +1513,8 @@ constexpr inline bool isKernel(CallingConv::ID CC) {
}
}
+inline bool isKernel(const Function &F) { return isKernel(F.getCallingConv()); }
+
LLVM_READNONE
constexpr bool canGuaranteeTCO(CallingConv::ID CC) {
return CC == CallingConv::Fast;
|
shiltian
approved these changes
Nov 10, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since #142598 isKernelLDS has been a pointless wrapper around isKernel.