Skip to content

Commit 31f39c8

Browse files
authored
[AMDGPU] Remove the AnnotateKernelFeatures pass (llvm#130198)
Previously the AnnotateKernelFeatures pass infers two attributes: amdgpu-calls and amdgpu-stack-objects, which are used to help determine if flat scratch init is allowed. PR llvm#118907 created the amdgpu-no-flat-scratch-init attribute. Continuing with that work, this patch makes use of this attribute to determine flat scratch init, replacing amdgpu-calls and amdgpu-stack-objects. This also leads to the removal of the AnnotateKernelFeatures pass.
1 parent 6e2bca8 commit 31f39c8

File tree

119 files changed

+13654
-1853
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+13654
-1853
lines changed

llvm/lib/Target/AMDGPU/AMDGPU.h

-3
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,8 @@ void initializeAMDGPUDAGToDAGISelLegacyPass(PassRegistry &);
9595

9696
void initializeAMDGPUAlwaysInlinePass(PassRegistry&);
9797

98-
Pass *createAMDGPUAnnotateKernelFeaturesPass();
9998
Pass *createAMDGPUAttributorLegacyPass();
10099
void initializeAMDGPUAttributorLegacyPass(PassRegistry &);
101-
void initializeAMDGPUAnnotateKernelFeaturesPass(PassRegistry &);
102-
extern char &AMDGPUAnnotateKernelFeaturesID;
103100

104101
// DPP/Iterative option enables the atomic optimizer with given strategy
105102
// whereas None disables the atomic optimizer.

llvm/lib/Target/AMDGPU/AMDGPUAnnotateKernelFeatures.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ class AMDGPUAnnotateKernelFeatures : public CallGraphSCCPass {
5252

5353
char AMDGPUAnnotateKernelFeatures::ID = 0;
5454

55-
char &llvm::AMDGPUAnnotateKernelFeaturesID = AMDGPUAnnotateKernelFeatures::ID;
56-
57-
INITIALIZE_PASS(AMDGPUAnnotateKernelFeatures, DEBUG_TYPE,
58-
"Add AMDGPU function attributes", false, false)
59-
6055
bool AMDGPUAnnotateKernelFeatures::addFeatureAttributes(Function &F) {
6156
bool HaveStackObjects = false;
6257
bool Changed = false;
@@ -131,7 +126,3 @@ bool AMDGPUAnnotateKernelFeatures::doInitialization(CallGraph &CG) {
131126
TM = &TPC->getTM<TargetMachine>();
132127
return false;
133128
}
134-
135-
Pass *llvm::createAMDGPUAnnotateKernelFeaturesPass() {
136-
return new AMDGPUAnnotateKernelFeatures();
137-
}

llvm/lib/Target/AMDGPU/AMDGPUPassRegistry.def

-6
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,3 @@ DUMMY_MACHINE_FUNCTION_PASS("amdgpu-regbanklegalize", AMDGPURegBankLegalizePass(
149149
DUMMY_MACHINE_FUNCTION_PASS("amdgpu-regbank-combiner", AMDGPURegBankCombinerPass())
150150

151151
#undef DUMMY_MACHINE_FUNCTION_PASS
152-
153-
154-
#define DUMMY_CGSCC_PASS(NAME, CREATE_PASS)
155-
DUMMY_CGSCC_PASS("amdgpu-annotate-kernel-features", AMDGPUAnnotateKernelFeaturesPass())
156-
157-
#undef DUMMY_CGSCC_PASS

llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUTarget() {
515515
initializeAMDGPUAlwaysInlinePass(*PR);
516516
initializeAMDGPUSwLowerLDSLegacyPass(*PR);
517517
initializeAMDGPUAttributorLegacyPass(*PR);
518-
initializeAMDGPUAnnotateKernelFeaturesPass(*PR);
519518
initializeAMDGPUAnnotateUniformValuesLegacyPass(*PR);
520519
initializeAMDGPUArgumentUsageInfoPass(*PR);
521520
initializeAMDGPUAtomicOptimizerPass(*PR);
@@ -1317,12 +1316,6 @@ void AMDGPUPassConfig::addIRPasses() {
13171316
}
13181317

13191318
void AMDGPUPassConfig::addCodeGenPrepare() {
1320-
if (TM->getTargetTriple().isAMDGCN()) {
1321-
// FIXME: This pass adds 2 hacky attributes that can be replaced with an
1322-
// analysis, and should be removed.
1323-
addPass(createAMDGPUAnnotateKernelFeaturesPass());
1324-
}
1325-
13261319
if (TM->getTargetTriple().isAMDGCN() && EnableLowerKernelArguments)
13271320
addPass(createAMDGPULowerKernelArgumentsPass());
13281321

llvm/lib/Target/AMDGPU/GCNSubtarget.cpp

+5-10
Original file line numberDiff line numberDiff line change
@@ -601,12 +601,6 @@ GCNUserSGPRUsageInfo::GCNUserSGPRUsageInfo(const Function &F,
601601
const CallingConv::ID CC = F.getCallingConv();
602602
const bool IsKernel =
603603
CC == CallingConv::AMDGPU_KERNEL || CC == CallingConv::SPIR_KERNEL;
604-
// FIXME: Should have analysis or something rather than attribute to detect
605-
// calls.
606-
const bool HasCalls = F.hasFnAttribute("amdgpu-calls");
607-
// FIXME: This attribute is a hack, we just need an analysis on the function
608-
// to look for allocas.
609-
const bool HasStackObjects = F.hasFnAttribute("amdgpu-stack-objects");
610604

611605
if (IsKernel && (!F.arg_empty() || ST.getImplicitArgNumBytes(F) != 0))
612606
KernargSegmentPtr = true;
@@ -629,12 +623,13 @@ GCNUserSGPRUsageInfo::GCNUserSGPRUsageInfo(const Function &F,
629623
DispatchID = true;
630624
}
631625

632-
// TODO: This could be refined a lot. The attribute is a poor way of
633-
// detecting calls or stack objects that may require it before argument
634-
// lowering.
635626
if (ST.hasFlatAddressSpace() && AMDGPU::isEntryFunctionCC(CC) &&
636627
(IsAmdHsaOrMesa || ST.enableFlatScratch()) &&
637-
(HasCalls || HasStackObjects || ST.enableFlatScratch()) &&
628+
// FlatScratchInit cannot be true for graphics CC if enableFlatScratch()
629+
// is false.
630+
(ST.enableFlatScratch() ||
631+
(!AMDGPU::isGraphics(CC) &&
632+
!F.hasFnAttribute("amdgpu-no-flat-scratch-init"))) &&
638633
!ST.flatScratchIsArchitected()) {
639634
FlatScratchInit = true;
640635
}

0 commit comments

Comments
 (0)