Loading llvm/lib/Target/AMDGPU/AMDGPU.h +12 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ namespace llvm { class AMDGPUTargetMachine; class GCNTargetMachine; class TargetMachine; // GlobalISel passes Loading Loading @@ -86,8 +87,8 @@ extern char &AMDGPUMachineCFGStructurizerID; void initializeAMDGPUAlwaysInlinePass(PassRegistry&); Pass *createAMDGPUAnnotateKernelFeaturesPass(); Pass *createAMDGPUAttributorPass(); void initializeAMDGPUAttributorPass(PassRegistry &); Pass *createAMDGPUAttributorLegacyPass(); void initializeAMDGPUAttributorLegacyPass(PassRegistry &); void initializeAMDGPUAnnotateKernelFeaturesPass(PassRegistry &); extern char &AMDGPUAnnotateKernelFeaturesID; Loading Loading @@ -262,6 +263,15 @@ public: PreservedAnalyses run(Function &, FunctionAnalysisManager &); }; class AMDGPUAttributorPass : public PassInfoMixin<AMDGPUAttributorPass> { private: TargetMachine &TM; public: AMDGPUAttributorPass(TargetMachine &TM) : TM(TM){}; PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); }; FunctionPass *createAMDGPUAnnotateUniformValues(); ModulePass *createAMDGPUPrintfRuntimeBinding(); Loading llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp +67 −49 Original line number Diff line number Diff line Loading @@ -933,24 +933,8 @@ static void addPreloadKernArgHint(Function &F, TargetMachine &TM) { } } class AMDGPUAttributor : public ModulePass { public: AMDGPUAttributor() : ModulePass(ID) {} /// doInitialization - Virtual method overridden by subclasses to do /// any necessary initialization before any pass is run. bool doInitialization(Module &) override { auto *TPC = getAnalysisIfAvailable<TargetPassConfig>(); if (!TPC) report_fatal_error("TargetMachine is required"); TM = &TPC->getTM<TargetMachine>(); return false; } bool runOnModule(Module &M) override { static bool runImpl(Module &M, AnalysisGetter &AG, TargetMachine &TM) { SetVector<Function *> Functions; AnalysisGetter AG(this); for (Function &F : M) { if (!F.isIntrinsic()) Functions.insert(&F); Loading @@ -958,7 +942,7 @@ public: CallGraphUpdater CGUpdater; BumpPtrAllocator Allocator; AMDGPUInformationCache InfoCache(M, AG, Allocator, nullptr, *TM); AMDGPUInformationCache InfoCache(M, AG, Allocator, nullptr, TM); DenseSet<const char *> Allowed( {&AAAMDAttributes::ID, &AAUniformWorkGroupSize::ID, &AAPotentialValues::ID, &AAAMDFlatWorkGroupSize::ID, Loading @@ -984,7 +968,7 @@ public: A.getOrCreateAAFor<AAAMDFlatWorkGroupSize>(IRPosition::function(F)); A.getOrCreateAAFor<AAAMDWavesPerEU>(IRPosition::function(F)); } else if (CC == CallingConv::AMDGPU_KERNEL) { addPreloadKernArgHint(F, *TM); addPreloadKernArgHint(F, TM); } } } Loading @@ -993,6 +977,26 @@ public: return Change == ChangeStatus::CHANGED; } class AMDGPUAttributorLegacy : public ModulePass { public: AMDGPUAttributorLegacy() : ModulePass(ID) {} /// doInitialization - Virtual method overridden by subclasses to do /// any necessary initialization before any pass is run. bool doInitialization(Module &) override { auto *TPC = getAnalysisIfAvailable<TargetPassConfig>(); if (!TPC) report_fatal_error("TargetMachine is required"); TM = &TPC->getTM<TargetMachine>(); return false; } bool runOnModule(Module &M) override { AnalysisGetter AG(this); return runImpl(M, AG, *TM); } void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequired<CycleInfoWrapperPass>(); } Loading @@ -1003,11 +1007,25 @@ public: }; } // namespace char AMDGPUAttributor::ID = 0; PreservedAnalyses llvm::AMDGPUAttributorPass::run(Module &M, ModuleAnalysisManager &AM) { FunctionAnalysisManager &FAM = AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager(); AnalysisGetter AG(FAM); Pass *llvm::createAMDGPUAttributorPass() { return new AMDGPUAttributor(); } INITIALIZE_PASS_BEGIN(AMDGPUAttributor, DEBUG_TYPE, "AMDGPU Attributor", false, false) // TODO: Probably preserves CFG return runImpl(M, AG, TM) ? PreservedAnalyses::none() : PreservedAnalyses::all(); } char AMDGPUAttributorLegacy::ID = 0; Pass *llvm::createAMDGPUAttributorLegacyPass() { return new AMDGPUAttributorLegacy(); } INITIALIZE_PASS_BEGIN(AMDGPUAttributorLegacy, DEBUG_TYPE, "AMDGPU Attributor", false, false) INITIALIZE_PASS_DEPENDENCY(CycleInfoWrapperPass); INITIALIZE_PASS_END(AMDGPUAttributor, DEBUG_TYPE, "AMDGPU Attributor", false, false) INITIALIZE_PASS_END(AMDGPUAttributorLegacy, DEBUG_TYPE, "AMDGPU Attributor", false, false) llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -381,7 +381,7 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUTarget() { initializeSILoadStoreOptimizerPass(*PR); initializeAMDGPUCtorDtorLoweringLegacyPass(*PR); initializeAMDGPUAlwaysInlinePass(*PR); initializeAMDGPUAttributorPass(*PR); initializeAMDGPUAttributorLegacyPass(*PR); initializeAMDGPUAnnotateKernelFeaturesPass(*PR); initializeAMDGPUAnnotateUniformValuesPass(*PR); initializeAMDGPUArgumentUsageInfoPass(*PR); Loading Loading @@ -610,6 +610,10 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) { PB.registerPipelineParsingCallback( [this](StringRef PassName, ModulePassManager &PM, ArrayRef<PassBuilder::PipelineElement>) { if (PassName == "amdgpu-attributor") { PM.addPass(AMDGPUAttributorPass(*this)); return true; } if (PassName == "amdgpu-unify-metadata") { PM.addPass(AMDGPUUnifyMetadataPass()); return true; Loading Loading @@ -1021,7 +1025,7 @@ void AMDGPUPassConfig::addIRPasses() { // AMDGPUAttributor infers lack of llvm.amdgcn.lds.kernel.id calls, so run // after their introduction if (TM.getOptLevel() > CodeGenOptLevel::None) addPass(createAMDGPUAttributorPass()); addPass(createAMDGPUAttributorLegacyPass()); if (TM.getOptLevel() > CodeGenOptLevel::None) addPass(createInferAddressSpacesPass()); Loading llvm/test/CodeGen/AMDGPU/addrspacecast-constantexpr.ll +1 −1 Original line number Diff line number Diff line ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-globals ; RUN: opt -mtriple=amdgcn-unknown-amdhsa -S -amdgpu-annotate-kernel-features < %s | FileCheck -check-prefixes=HSA,AKF_HSA %s ; RUN: opt -mtriple=amdgcn-unknown-amdhsa -S -amdgpu-attributor < %s | FileCheck -check-prefixes=HSA,ATTRIBUTOR_HSA %s ; RUN: opt -mtriple=amdgcn-unknown-amdhsa -S -passes=amdgpu-attributor < %s | FileCheck -check-prefixes=HSA,ATTRIBUTOR_HSA %s declare void @llvm.memcpy.p1.p4.i32(ptr addrspace(1) nocapture, ptr addrspace(4) nocapture, i32, i1) #0 Loading llvm/test/CodeGen/AMDGPU/annotate-existing-abi-attributes.ll +1 −1 Original line number Diff line number Diff line ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-globals ; RUN: opt -mtriple=amdgcn-unknown-amdhsa -S -amdgpu-attributor %s | FileCheck %s ; RUN: opt -mtriple=amdgcn-unknown-amdhsa -S -passes=amdgpu-attributor %s | FileCheck %s ; Check handling for pre-existing attributes on function declarations Loading Loading
llvm/lib/Target/AMDGPU/AMDGPU.h +12 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ namespace llvm { class AMDGPUTargetMachine; class GCNTargetMachine; class TargetMachine; // GlobalISel passes Loading Loading @@ -86,8 +87,8 @@ extern char &AMDGPUMachineCFGStructurizerID; void initializeAMDGPUAlwaysInlinePass(PassRegistry&); Pass *createAMDGPUAnnotateKernelFeaturesPass(); Pass *createAMDGPUAttributorPass(); void initializeAMDGPUAttributorPass(PassRegistry &); Pass *createAMDGPUAttributorLegacyPass(); void initializeAMDGPUAttributorLegacyPass(PassRegistry &); void initializeAMDGPUAnnotateKernelFeaturesPass(PassRegistry &); extern char &AMDGPUAnnotateKernelFeaturesID; Loading Loading @@ -262,6 +263,15 @@ public: PreservedAnalyses run(Function &, FunctionAnalysisManager &); }; class AMDGPUAttributorPass : public PassInfoMixin<AMDGPUAttributorPass> { private: TargetMachine &TM; public: AMDGPUAttributorPass(TargetMachine &TM) : TM(TM){}; PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); }; FunctionPass *createAMDGPUAnnotateUniformValues(); ModulePass *createAMDGPUPrintfRuntimeBinding(); Loading
llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp +67 −49 Original line number Diff line number Diff line Loading @@ -933,24 +933,8 @@ static void addPreloadKernArgHint(Function &F, TargetMachine &TM) { } } class AMDGPUAttributor : public ModulePass { public: AMDGPUAttributor() : ModulePass(ID) {} /// doInitialization - Virtual method overridden by subclasses to do /// any necessary initialization before any pass is run. bool doInitialization(Module &) override { auto *TPC = getAnalysisIfAvailable<TargetPassConfig>(); if (!TPC) report_fatal_error("TargetMachine is required"); TM = &TPC->getTM<TargetMachine>(); return false; } bool runOnModule(Module &M) override { static bool runImpl(Module &M, AnalysisGetter &AG, TargetMachine &TM) { SetVector<Function *> Functions; AnalysisGetter AG(this); for (Function &F : M) { if (!F.isIntrinsic()) Functions.insert(&F); Loading @@ -958,7 +942,7 @@ public: CallGraphUpdater CGUpdater; BumpPtrAllocator Allocator; AMDGPUInformationCache InfoCache(M, AG, Allocator, nullptr, *TM); AMDGPUInformationCache InfoCache(M, AG, Allocator, nullptr, TM); DenseSet<const char *> Allowed( {&AAAMDAttributes::ID, &AAUniformWorkGroupSize::ID, &AAPotentialValues::ID, &AAAMDFlatWorkGroupSize::ID, Loading @@ -984,7 +968,7 @@ public: A.getOrCreateAAFor<AAAMDFlatWorkGroupSize>(IRPosition::function(F)); A.getOrCreateAAFor<AAAMDWavesPerEU>(IRPosition::function(F)); } else if (CC == CallingConv::AMDGPU_KERNEL) { addPreloadKernArgHint(F, *TM); addPreloadKernArgHint(F, TM); } } } Loading @@ -993,6 +977,26 @@ public: return Change == ChangeStatus::CHANGED; } class AMDGPUAttributorLegacy : public ModulePass { public: AMDGPUAttributorLegacy() : ModulePass(ID) {} /// doInitialization - Virtual method overridden by subclasses to do /// any necessary initialization before any pass is run. bool doInitialization(Module &) override { auto *TPC = getAnalysisIfAvailable<TargetPassConfig>(); if (!TPC) report_fatal_error("TargetMachine is required"); TM = &TPC->getTM<TargetMachine>(); return false; } bool runOnModule(Module &M) override { AnalysisGetter AG(this); return runImpl(M, AG, *TM); } void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequired<CycleInfoWrapperPass>(); } Loading @@ -1003,11 +1007,25 @@ public: }; } // namespace char AMDGPUAttributor::ID = 0; PreservedAnalyses llvm::AMDGPUAttributorPass::run(Module &M, ModuleAnalysisManager &AM) { FunctionAnalysisManager &FAM = AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager(); AnalysisGetter AG(FAM); Pass *llvm::createAMDGPUAttributorPass() { return new AMDGPUAttributor(); } INITIALIZE_PASS_BEGIN(AMDGPUAttributor, DEBUG_TYPE, "AMDGPU Attributor", false, false) // TODO: Probably preserves CFG return runImpl(M, AG, TM) ? PreservedAnalyses::none() : PreservedAnalyses::all(); } char AMDGPUAttributorLegacy::ID = 0; Pass *llvm::createAMDGPUAttributorLegacyPass() { return new AMDGPUAttributorLegacy(); } INITIALIZE_PASS_BEGIN(AMDGPUAttributorLegacy, DEBUG_TYPE, "AMDGPU Attributor", false, false) INITIALIZE_PASS_DEPENDENCY(CycleInfoWrapperPass); INITIALIZE_PASS_END(AMDGPUAttributor, DEBUG_TYPE, "AMDGPU Attributor", false, false) INITIALIZE_PASS_END(AMDGPUAttributorLegacy, DEBUG_TYPE, "AMDGPU Attributor", false, false)
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -381,7 +381,7 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUTarget() { initializeSILoadStoreOptimizerPass(*PR); initializeAMDGPUCtorDtorLoweringLegacyPass(*PR); initializeAMDGPUAlwaysInlinePass(*PR); initializeAMDGPUAttributorPass(*PR); initializeAMDGPUAttributorLegacyPass(*PR); initializeAMDGPUAnnotateKernelFeaturesPass(*PR); initializeAMDGPUAnnotateUniformValuesPass(*PR); initializeAMDGPUArgumentUsageInfoPass(*PR); Loading Loading @@ -610,6 +610,10 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) { PB.registerPipelineParsingCallback( [this](StringRef PassName, ModulePassManager &PM, ArrayRef<PassBuilder::PipelineElement>) { if (PassName == "amdgpu-attributor") { PM.addPass(AMDGPUAttributorPass(*this)); return true; } if (PassName == "amdgpu-unify-metadata") { PM.addPass(AMDGPUUnifyMetadataPass()); return true; Loading Loading @@ -1021,7 +1025,7 @@ void AMDGPUPassConfig::addIRPasses() { // AMDGPUAttributor infers lack of llvm.amdgcn.lds.kernel.id calls, so run // after their introduction if (TM.getOptLevel() > CodeGenOptLevel::None) addPass(createAMDGPUAttributorPass()); addPass(createAMDGPUAttributorLegacyPass()); if (TM.getOptLevel() > CodeGenOptLevel::None) addPass(createInferAddressSpacesPass()); Loading
llvm/test/CodeGen/AMDGPU/addrspacecast-constantexpr.ll +1 −1 Original line number Diff line number Diff line ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-globals ; RUN: opt -mtriple=amdgcn-unknown-amdhsa -S -amdgpu-annotate-kernel-features < %s | FileCheck -check-prefixes=HSA,AKF_HSA %s ; RUN: opt -mtriple=amdgcn-unknown-amdhsa -S -amdgpu-attributor < %s | FileCheck -check-prefixes=HSA,ATTRIBUTOR_HSA %s ; RUN: opt -mtriple=amdgcn-unknown-amdhsa -S -passes=amdgpu-attributor < %s | FileCheck -check-prefixes=HSA,ATTRIBUTOR_HSA %s declare void @llvm.memcpy.p1.p4.i32(ptr addrspace(1) nocapture, ptr addrspace(4) nocapture, i32, i1) #0 Loading
llvm/test/CodeGen/AMDGPU/annotate-existing-abi-attributes.ll +1 −1 Original line number Diff line number Diff line ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-globals ; RUN: opt -mtriple=amdgcn-unknown-amdhsa -S -amdgpu-attributor %s | FileCheck %s ; RUN: opt -mtriple=amdgcn-unknown-amdhsa -S -passes=amdgpu-attributor %s | FileCheck %s ; Check handling for pre-existing attributes on function declarations Loading