Skip to content

[AMDGPU] Enable AMDGPUAttributorPass in full LTO #102673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

shiltian
Copy link
Contributor

@shiltian shiltian commented Aug 9, 2024

This is basically same as #102086 but reverts some test case changes that are no longer needed.

@shiltian shiltian marked this pull request as ready for review August 9, 2024 20:05
Copy link
Contributor Author

shiltian commented Aug 9, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @shiltian and the rest of your teammates on Graphite Graphite

@llvmbot
Copy link
Member

llvmbot commented Aug 9, 2024

@llvm/pr-subscribers-backend-amdgpu

Author: Shilei Tian (shiltian)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/102673.diff

2 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp (+7)
  • (added) llvm/test/CodeGen/AMDGPU/print-pipeline-passes.ll (+10)
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
+ }

@shiltian shiltian force-pushed the users/shiltian/amdgpu-attributor-enable-lto branch from baf8f1c to f729dad Compare August 9, 2024 22:39
@shiltian
Copy link
Contributor Author

shiltian commented Aug 9, 2024

This PR passed the internal PSDB.

@shiltian
Copy link
Contributor Author

ping

@shiltian shiltian force-pushed the users/shiltian/amdgpu-attributor-enable-lto branch from f729dad to 85aab78 Compare August 12, 2024 17:38
@shiltian shiltian merged commit 862f504 into main Aug 12, 2024
5 of 6 checks passed
@shiltian shiltian deleted the users/shiltian/amdgpu-attributor-enable-lto branch August 12, 2024 17:39
@ye-luo
Copy link
Contributor

ye-luo commented Aug 15, 2024

It seems broke #104397

searlmc1 pushed a commit to ROCm/llvm-project that referenced this pull request Nov 22, 2024
This is basically same as
llvm#102086 but reverts some test
case changes that are no longer needed.

(cherry picked from commit 862f504)

Change-Id: Icc620b3afc6eacc6fea00d91176be054feaf3a6c
searlmc1 pushed a commit to ROCm/llvm-project that referenced this pull request Nov 22, 2024
This reverts commit dab6a0d.

Change-Id: If294e28c78060369aa3ee49f68b41494ea7a79fa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants