[llvm] 0563360 - [NewPM] Teach llc -passes to handle target machine analysis (#191704)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 15 03:19:27 PDT 2026
Author: macurtis-amd
Date: 2026-04-15T05:19:21-05:00
New Revision: 0563360ae1ac21b278b307a6b34f3f0cea023949
URL: https://github.com/llvm/llvm-project/commit/0563360ae1ac21b278b307a6b34f3f0cea023949
DIFF: https://github.com/llvm/llvm-project/commit/0563360ae1ac21b278b307a6b34f3f0cea023949.diff
LOG: [NewPM] Teach llc -passes to handle target machine analysis (#191704)
Added:
llvm/test/CodeGen/AMDGPU/new-pm-machine-analysis.mir
Modified:
llvm/include/llvm/Passes/TargetPassRegistry.inc
Removed:
################################################################################
diff --git a/llvm/include/llvm/Passes/TargetPassRegistry.inc b/llvm/include/llvm/Passes/TargetPassRegistry.inc
index 068b27794191c..de2fefa471529 100644
--- a/llvm/include/llvm/Passes/TargetPassRegistry.inc
+++ b/llvm/include/llvm/Passes/TargetPassRegistry.inc
@@ -92,6 +92,19 @@ if (PIC) {
return true; \
}
+#define ADD_ANALYSIS_PASS(NAME, CREATE_PASS) \
+ if (Name == "invalidate<" NAME ">") { \
+ PM.addPass(InvalidateAnalysisPass< \
+ std::remove_reference_t<decltype(CREATE_PASS)>>()); \
+ return true; \
+ } \
+ 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 +164,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-machine-analysis.mir b/llvm/test/CodeGen/AMDGPU/new-pm-machine-analysis.mir
new file mode 100644
index 0000000000000..d11ef50cbdc8f
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/new-pm-machine-analysis.mir
@@ -0,0 +1,13 @@
+# RUN: llc -mtriple=amdgcn \
+# RUN: "-passes=require<amdgpu-resource-usage>,invalidate<amdgpu-resource-usage>" \
+# RUN: --print-pipeline-passes --filetype=null %s | FileCheck %s
+
+# CHECK: machine-function(require<amdgpu-resource-usage>,invalidate<amdgpu-resource-usage>)
+---
+name: test
+body: |
+ bb.0:
+ S_NOP 0
+...
+
+
More information about the llvm-commits
mailing list