[llvm] [AMDGPU] Enable AMDGPUAttributorPass in full LTO (PR #102673)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 9 13:05:21 PDT 2024
https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/102673
None
>From baf8f1c4274bae951ae8e742b139c35452f8cd3a Mon Sep 17 00:00:00 2001
From: Shilei Tian <i at tianshilei.me>
Date: Fri, 9 Aug 2024 16:04:25 -0400
Subject: [PATCH] [AMDGPU] Enable AMDGPUAttributorPass in full LTO
---
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | 7 +++++++
llvm/test/CodeGen/AMDGPU/print-pipeline-passes.ll | 10 ++++++++++
2 files changed, 17 insertions(+)
create mode 100644 llvm/test/CodeGen/AMDGPU/print-pipeline-passes.ll
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index e80daff96c431..89342c5ba6568 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -381,6 +381,11 @@ static cl::opt<bool> EnableHipStdPar(
cl::desc("Enable HIP Standard Parallelism Offload support"), cl::init(false),
cl::Hidden);
+static cl::opt<bool>
+ EnableAMDGPUAttributor("amdgpu-attributor-enable",
+ cl::desc("Enable AMDGPUAttributorPass"),
+ cl::init(true), cl::Hidden);
+
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUTarget() {
// Register the target
RegisterTargetMachine<R600TargetMachine> X(getTheR600Target());
@@ -750,6 +755,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..c49187951e9ad
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/print-pipeline-passes.ll
@@ -0,0 +1,10 @@
+; RUN: opt -mtriple=amdgcn--amdhsa -S -passes="lto<O1>" -print-pipeline-passes %s -o - | FileCheck %s
+ ; RUN: opt -mtriple=amdgcn--amdhsa -S -passes="lto<O2>" -print-pipeline-passes %s -o - | FileCheck %s
+ ; RUN: opt -mtriple=amdgcn--amdhsa -S -passes="lto<O3>" -print-pipeline-passes %s -o - | FileCheck %s
+
+ ; CHECK: amdgpu-attributor
+
+ define amdgpu_kernel void @kernel() {
+ entry:
+ ret void
+ }
More information about the llvm-commits
mailing list