[llvm] [NewPM] Teach llc -passes to handle target machine analysis (PR #191704)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 12 05:25:04 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-amdgpu
Author: macurtis-amd
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/191704.diff
2 Files Affected:
- (modified) llvm/include/llvm/Passes/TargetPassRegistry.inc (+18)
- (added) llvm/test/CodeGen/AMDGPU/new-pm-req-machine-analysis.mir (+9)
``````````diff
diff --git a/llvm/include/llvm/Passes/TargetPassRegistry.inc b/llvm/include/llvm/Passes/TargetPassRegistry.inc
index 068b27794191c..4e778e77fa128 100644
--- a/llvm/include/llvm/Passes/TargetPassRegistry.inc
+++ b/llvm/include/llvm/Passes/TargetPassRegistry.inc
@@ -92,6 +92,14 @@ if (PIC) {
return true; \
}
+#define ADD_ANALYSIS_PASS(NAME, CREATE_PASS) \
+ if (Name == "require<" NAME ">") { \
+ PM.addPass( \
+ RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
+ MachineFunction>()); \
+ return true; \
+ }
+
PB.registerPipelineParsingCallback([=](StringRef Name, ModulePassManager &PM,
ArrayRef<PassBuilder::PipelineElement>) {
#define MODULE_PASS(NAME, CREATE_PASS) ADD_PASS(NAME, CREATE_PASS)
@@ -151,6 +159,16 @@ PB.registerPipelineParsingCallback([=](StringRef Name, FunctionPassManager &PM,
return false;
});
+PB.registerPipelineParsingCallback([=](StringRef Name,
+ MachineFunctionPassManager &PM,
+ ArrayRef<PassBuilder::PipelineElement>) {
+#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
+ ADD_ANALYSIS_PASS(NAME, CREATE_PASS)
+#include GET_PASS_REGISTRY
+#undef MACHINE_FUNCTION_ANALYSIS
+ return false;
+});
+
#undef ADD_PASS
#undef ADD_PASS_WITH_PARAMS
diff --git a/llvm/test/CodeGen/AMDGPU/new-pm-req-machine-analysis.mir b/llvm/test/CodeGen/AMDGPU/new-pm-req-machine-analysis.mir
new file mode 100644
index 0000000000000..ab7d84be8d617
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/new-pm-req-machine-analysis.mir
@@ -0,0 +1,9 @@
+# RUN: llc -mtriple=amdgcn "-passes=require<amdgpu-resource-usage>" -filetype=null %s
+---
+name: test
+body: |
+ bb.0:
+ S_NOP 0
+...
+
+
``````````
</details>
https://github.com/llvm/llvm-project/pull/191704
More information about the llvm-commits
mailing list