Skip to content

Commit c7efd47

Browse files
committed
[AMDGPU] Remove the AnnotateKernelFeatures pass
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 0f696c2 commit c7efd47

File tree

116 files changed

+12744
-1836
lines changed

Some content is hidden

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

116 files changed

+12744
-1836
lines changed

llvm/lib/Target/AMDGPU/AMDGPU.h

Lines changed: 0 additions & 3 deletions
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

Lines changed: 0 additions & 9 deletions
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/AMDGPUTargetMachine.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,6 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUTarget() {
511511
initializeAMDGPUAlwaysInlinePass(*PR);
512512
initializeAMDGPUSwLowerLDSLegacyPass(*PR);
513513
initializeAMDGPUAttributorLegacyPass(*PR);
514-
initializeAMDGPUAnnotateKernelFeaturesPass(*PR);
515514
initializeAMDGPUAnnotateUniformValuesLegacyPass(*PR);
516515
initializeAMDGPUArgumentUsageInfoPass(*PR);
517516
initializeAMDGPUAtomicOptimizerPass(*PR);
@@ -1294,12 +1293,6 @@ void AMDGPUPassConfig::addIRPasses() {
12941293
}
12951294

12961295
void AMDGPUPassConfig::addCodeGenPrepare() {
1297-
if (TM->getTargetTriple().isAMDGCN()) {
1298-
// FIXME: This pass adds 2 hacky attributes that can be replaced with an
1299-
// analysis, and should be removed.
1300-
addPass(createAMDGPUAnnotateKernelFeaturesPass());
1301-
}
1302-
13031296
if (TM->getTargetTriple().isAMDGCN() && EnableLowerKernelArguments)
13041297
addPass(createAMDGPULowerKernelArgumentsPass());
13051298

llvm/lib/Target/AMDGPU/GCNSubtarget.cpp

Lines changed: 6 additions & 10 deletions
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,14 @@ 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.
626+
const bool IsNoFlatScratchInitSet = F.hasFnAttribute("amdgpu-no-flat-scratch-init");
627+
635628
if (ST.hasFlatAddressSpace() && AMDGPU::isEntryFunctionCC(CC) &&
636629
(IsAmdHsaOrMesa || ST.enableFlatScratch()) &&
637-
(HasCalls || HasStackObjects || ST.enableFlatScratch()) &&
630+
// The line below: If enableFlatScratch() is true, whether
631+
// no-flat-scratch-init is set is not important. If enableFlatScratch()
632+
// is false, FlatScratchInit cannot be true for graphics CC.
633+
(ST.enableFlatScratch() || (!IsNoFlatScratchInitSet && !AMDGPU::isGraphics(CC))) &&
638634
!ST.flatScratchIsArchitected()) {
639635
FlatScratchInit = true;
640636
}

0 commit comments

Comments
 (0)