diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp index 0523fee5bcf9f..d82be9a7e9041 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -383,6 +383,11 @@ static cl::opt EnableHipStdPar( cl::desc("Enable HIP Standard Parallelism Offload support"), cl::init(false), cl::Hidden); +static cl::opt + EnableAMDGPUAttributor("amdgpu-attributor-enable", + cl::desc("Enable AMDGPUAttributorPass"), + cl::init(true), cl::Hidden); + extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUTarget() { // Register the target RegisterTargetMachine X(getTheR600Target()); @@ -762,6 +767,8 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) { // module is partitioned for codegen. if (EnableLowerModuleLDS) PM.addPass(AMDGPULowerModuleLDSPass(*this)); + if (EnableAMDGPUAttributor && Level != OptimizationLevel::O0) + PM.addPass(AMDGPUAttributorPass(*this)); }); PB.registerRegClassFilterParsingCallback( diff --git a/llvm/test/CodeGen/AMDGPU/print-pipeline-passes.ll b/llvm/test/CodeGen/AMDGPU/print-pipeline-passes.ll new file mode 100644 index 0000000000000..b9eda0c1cd3bb --- /dev/null +++ b/llvm/test/CodeGen/AMDGPU/print-pipeline-passes.ll @@ -0,0 +1,12 @@ +; RUN: opt -mtriple=amdgcn--amdhsa -S -passes="lto" -print-pipeline-passes %s -o - | FileCheck --check-prefix=O0 %s +; RUN: opt -mtriple=amdgcn--amdhsa -S -passes="lto" -print-pipeline-passes %s -o - | FileCheck %s +; RUN: opt -mtriple=amdgcn--amdhsa -S -passes="lto" -print-pipeline-passes %s -o - | FileCheck %s +; RUN: opt -mtriple=amdgcn--amdhsa -S -passes="lto" -print-pipeline-passes %s -o - | FileCheck %s + +; CHECK: amdgpu-attributor +; O0-NOT: amdgpu-attributor + +define amdgpu_kernel void @kernel() { +entry: + ret void +}