[NewPM] Teach llc -passes to handle target machine analysis - #191704
Merged
Merged
Conversation
Member
|
@llvm/pr-subscribers-backend-amdgpu Author: macurtis-amd ChangesFull diff: https://github.com/llvm/llvm-project/pull/191704.diff 2 Files Affected:
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
+...
+
+
|
paperchalice
left a comment
Contributor
There was a problem hiding this comment.
Could you also add invalidate<pass-name> support? Thanks!
| #undef MACHINE_FUNCTION_ANALYSIS | ||
| return false; | ||
| }); | ||
|
|
Contributor
There was a problem hiding this comment.
This is implementation is for machine function analysis only, target like DirectX has some IR analyses, so it is worth to support other IR kinds.
Maybe we could introduce something like <IRUnit>PassManager::IRUnitT to simplifiy it, but this is out of scope for this pr.
vikramRH
reviewed
Apr 13, 2026
vikramRH
approved these changes
Apr 14, 2026
Contributor
|
LGTM |
kmitropoulou
approved these changes
Apr 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.