Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[AMDGPU][NPM] Add isRequired to passes missing it #134033

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

optimisan
Copy link
Contributor

@optimisan optimisan commented Apr 2, 2025

Now that the skipFunction check is done automatically in OptNone instrumentation, we have to add this method to passes that should not be skipped.

Copy link
Contributor Author

optimisan commented Apr 2, 2025

@optimisan optimisan marked this pull request as ready for review April 2, 2025 06:27
@llvmbot
Copy link
Member

llvmbot commented Apr 2, 2025

@llvm/pr-subscribers-backend-amdgpu

Author: Akshat Oke (optimisan)

Changes

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

13 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/AMDGPU.h (+3)
  • (modified) llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h (+1)
  • (modified) llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.h (+1)
  • (modified) llvm/lib/Target/AMDGPU/GCNNSAReassign.h (+1)
  • (modified) llvm/lib/Target/AMDGPU/GCNPreRALongBranchReg.h (+1)
  • (modified) llvm/lib/Target/AMDGPU/GCNRewritePartialRegUses.h (+1)
  • (modified) llvm/lib/Target/AMDGPU/SIFixSGPRCopies.h (+1)
  • (modified) llvm/lib/Target/AMDGPU/SIFixVGPRCopies.h (+1)
  • (modified) llvm/lib/Target/AMDGPU/SILowerControlFlow.h (+1)
  • (modified) llvm/lib/Target/AMDGPU/SILowerSGPRSpills.h (+1)
  • (modified) llvm/lib/Target/AMDGPU/SILowerWWMCopies.h (+1)
  • (modified) llvm/lib/Target/AMDGPU/SIPreAllocateWWMRegs.h (+1)
  • (modified) llvm/lib/Target/AMDGPU/SIWholeQuadMode.h (+1)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.h b/llvm/lib/Target/AMDGPU/AMDGPU.h
index a8e4ea9429f50..5236c83c6e99f 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.h
@@ -89,6 +89,7 @@ class SILowerI1CopiesPass : public PassInfoMixin<SILowerI1CopiesPass> {
   SILowerI1CopiesPass() = default;
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
+  static bool isRequired() { return true; }
 };
 
 void initializeAMDGPUDAGToDAGISelLegacyPass(PassRegistry &);
@@ -356,6 +357,7 @@ class SIModeRegisterPass : public PassInfoMixin<SIModeRegisterPass> {
 public:
   SIModeRegisterPass() {}
   PreservedAnalyses run(MachineFunction &F, MachineFunctionAnalysisManager &AM);
+  static bool isRequired() { return true; }
 };
 
 class SIMemoryLegalizerPass : public PassInfoMixin<SIMemoryLegalizerPass> {
@@ -458,6 +460,7 @@ class SIAnnotateControlFlowPass
 public:
   SIAnnotateControlFlowPass(const AMDGPUTargetMachine &TM) : TM(TM) {}
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+  static bool isRequired() { return true; }
 };
 
 void initializeSIAnnotateControlFlowLegacyPass(PassRegistry &);
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h
index f3b9364fdb92b..db5a1c0ac71aa 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h
@@ -287,6 +287,7 @@ class AMDGPUISelDAGToDAGPass : public SelectionDAGISelPass {
 
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
+  static bool isRequired() { return true; }
 };
 
 class AMDGPUDAGToDAGISelLegacy : public SelectionDAGISelLegacy {
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.h b/llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.h
index 2fd98a2ee1a93..d6fb0e53e1169 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.h
@@ -29,6 +29,7 @@ class AMDGPUUnifyDivergentExitNodesPass
     : public PassInfoMixin<AMDGPUUnifyDivergentExitNodesPass> {
 public:
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
+  static bool isRequired() { return true; }
 };
 
 } // end namespace llvm
diff --git a/llvm/lib/Target/AMDGPU/GCNNSAReassign.h b/llvm/lib/Target/AMDGPU/GCNNSAReassign.h
index 97a72e7ddbb24..4f2abe0dd0086 100644
--- a/llvm/lib/Target/AMDGPU/GCNNSAReassign.h
+++ b/llvm/lib/Target/AMDGPU/GCNNSAReassign.h
@@ -16,6 +16,7 @@ class GCNNSAReassignPass : public PassInfoMixin<GCNNSAReassignPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
+  static bool isRequired() { return true; }
 };
 } // namespace llvm
 
diff --git a/llvm/lib/Target/AMDGPU/GCNPreRALongBranchReg.h b/llvm/lib/Target/AMDGPU/GCNPreRALongBranchReg.h
index 4cd7dea83a061..4c4ac344cb206 100644
--- a/llvm/lib/Target/AMDGPU/GCNPreRALongBranchReg.h
+++ b/llvm/lib/Target/AMDGPU/GCNPreRALongBranchReg.h
@@ -17,6 +17,7 @@ class GCNPreRALongBranchRegPass
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
+  static bool isRequired() { return true; }
 };
 } // namespace llvm
 
diff --git a/llvm/lib/Target/AMDGPU/GCNRewritePartialRegUses.h b/llvm/lib/Target/AMDGPU/GCNRewritePartialRegUses.h
index b2c3190b5c6ba..4e97128bdc2d5 100644
--- a/llvm/lib/Target/AMDGPU/GCNRewritePartialRegUses.h
+++ b/llvm/lib/Target/AMDGPU/GCNRewritePartialRegUses.h
@@ -17,6 +17,7 @@ class GCNRewritePartialRegUsesPass
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
+  static bool isRequired() { return true; }
 };
 } // namespace llvm
 
diff --git a/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.h b/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.h
index d7551a45887b9..12b87d756e664 100644
--- a/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.h
+++ b/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.h
@@ -18,6 +18,7 @@ class SIFixSGPRCopiesPass : public PassInfoMixin<SIFixSGPRCopiesPass> {
   SIFixSGPRCopiesPass() = default;
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
+  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/lib/Target/AMDGPU/SIFixVGPRCopies.h b/llvm/lib/Target/AMDGPU/SIFixVGPRCopies.h
index 7b098b71597ff..0637b5d1750f9 100644
--- a/llvm/lib/Target/AMDGPU/SIFixVGPRCopies.h
+++ b/llvm/lib/Target/AMDGPU/SIFixVGPRCopies.h
@@ -16,6 +16,7 @@ class SIFixVGPRCopiesPass : public PassInfoMixin<SIFixVGPRCopiesPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
+  static bool isRequired() { return true; }
 };
 } // namespace llvm
 
diff --git a/llvm/lib/Target/AMDGPU/SILowerControlFlow.h b/llvm/lib/Target/AMDGPU/SILowerControlFlow.h
index 23803c679c246..478558dfbf97f 100644
--- a/llvm/lib/Target/AMDGPU/SILowerControlFlow.h
+++ b/llvm/lib/Target/AMDGPU/SILowerControlFlow.h
@@ -16,6 +16,7 @@ class SILowerControlFlowPass : public PassInfoMixin<SILowerControlFlowPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
+  static bool isRequired() { return true; }
 };
 } // namespace llvm
 
diff --git a/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.h b/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.h
index a9ffb5705d094..55c1e914d9a6a 100644
--- a/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.h
+++ b/llvm/lib/Target/AMDGPU/SILowerSGPRSpills.h
@@ -23,6 +23,7 @@ class SILowerSGPRSpillsPass : public PassInfoMixin<SILowerSGPRSpillsPass> {
         .set(MachineFunctionProperties::Property::IsSSA)
         .set(MachineFunctionProperties::Property::NoVRegs);
   }
+  static bool isRequired() { return true; }
 };
 } // namespace llvm
 
diff --git a/llvm/lib/Target/AMDGPU/SILowerWWMCopies.h b/llvm/lib/Target/AMDGPU/SILowerWWMCopies.h
index cfc8100901760..5c17a479d953c 100644
--- a/llvm/lib/Target/AMDGPU/SILowerWWMCopies.h
+++ b/llvm/lib/Target/AMDGPU/SILowerWWMCopies.h
@@ -16,6 +16,7 @@ class SILowerWWMCopiesPass : public PassInfoMixin<SILowerWWMCopiesPass> {
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
+  static bool isRequired() { return true; }
 };
 } // namespace llvm
 
diff --git a/llvm/lib/Target/AMDGPU/SIPreAllocateWWMRegs.h b/llvm/lib/Target/AMDGPU/SIPreAllocateWWMRegs.h
index 9964817649168..6eae4756d59b2 100644
--- a/llvm/lib/Target/AMDGPU/SIPreAllocateWWMRegs.h
+++ b/llvm/lib/Target/AMDGPU/SIPreAllocateWWMRegs.h
@@ -18,6 +18,7 @@ class SIPreAllocateWWMRegsPass
 public:
   PreservedAnalyses run(MachineFunction &MF,
                         MachineFunctionAnalysisManager &MFAM);
+  static bool isRequired() { return true; }
 };
 
 } // namespace llvm
diff --git a/llvm/lib/Target/AMDGPU/SIWholeQuadMode.h b/llvm/lib/Target/AMDGPU/SIWholeQuadMode.h
index e30b46721841b..b33c7d4a632bb 100644
--- a/llvm/lib/Target/AMDGPU/SIWholeQuadMode.h
+++ b/llvm/lib/Target/AMDGPU/SIWholeQuadMode.h
@@ -21,6 +21,7 @@ class SIWholeQuadModePass : public PassInfoMixin<SIWholeQuadModePass> {
     return MachineFunctionProperties().set(
         MachineFunctionProperties::Property::IsSSA);
   }
+  static bool isRequired() { return true; }
 };
 } // namespace llvm
 

Copy link
Contributor

@arsenm arsenm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should revisit this API. Wrong by default is a bad pattern. Passes should be required by default

@arsenm arsenm requested review from aeubanks and paperchalice April 2, 2025 06:43
@optimisan
Copy link
Contributor Author

I think we should revisit this API. Wrong by default is a bad pattern. Passes should be required by default

There is in fact a lingering suggestion that we replace PassInfoMixin with OptionalPassMixin and RequiredPassMixin to avoid these kinds of slips and force passes to explicitly choose between the two.
I remember @paperchalice working on that a while ago but I can pick that up too. @aeubanks I suppose it was your suggestion?

@paperchalice
Copy link
Contributor

I think we should revisit this API. Wrong by default is a bad pattern. Passes should be required by default

There is in fact a lingering suggestion that we replace PassInfoMixin with OptionalPassMixin and RequiredPassMixin to avoid these kinds of slips and force passes to explicitly choose between the two. I remember @paperchalice working on that a while ago but I can pick that up too. @aeubanks I suppose it was your suggestion?

I want something like pass traits but seems that it conflicts with the type erasure style in current implementation...

@aeubanks
Copy link
Contributor

I think we should revisit this API. Wrong by default is a bad pattern. Passes should be required by default

There is in fact a lingering suggestion that we replace PassInfoMixin with OptionalPassMixin and RequiredPassMixin to avoid these kinds of slips and force passes to explicitly choose between the two. I remember @paperchalice working on that a while ago but I can pick that up too. @aeubanks I suppose it was your suggestion?

I want something like pass traits but seems that it conflicts with the type erasure style in current implementation...

doesn't something like aeubanks@2ac577e work? if that works, do you want to send an RFC to do push this through?

@paperchalice
Copy link
Contributor

I think we should revisit this API. Wrong by default is a bad pattern. Passes should be required by default

There is in fact a lingering suggestion that we replace PassInfoMixin with OptionalPassMixin and RequiredPassMixin to avoid these kinds of slips and force passes to explicitly choose between the two. I remember @paperchalice working on that a while ago but I can pick that up too. @aeubanks I suppose it was your suggestion?

I want something like pass traits but seems that it conflicts with the type erasure style in current implementation...

doesn't something like aeubanks@2ac577e work? if that works, do you want to send an RFC to do push this through?

I will draft an RFC in this weekend and post it in next week.

@paperchalice
Copy link
Contributor

@optimisan
Copy link
Contributor Author

doesn't something like aeubanks@2ac577e work? if that works, do you want to send an RFC to do push this through?

I was thinking we remove PassInfoMixin altogether and only keep Optional and AlwaysRun mixins.

@optimisan optimisan changed the base branch from main to users/optimisan/04-15-_codegen_npm_do_not_add_required_passes_to_pipeline_skip-even-required-passes April 15, 2025 06:54
@optimisan optimisan force-pushed the users/optimisan/04-02-_amdgpu_npm_add_isrequired_to_passes_missing_it branch from 6b7957b to f20165e Compare April 15, 2025 06:55
@optimisan optimisan force-pushed the users/optimisan/04-02-_amdgpu_npm_add_isrequired_to_passes_missing_it branch from f20165e to 1b93c63 Compare April 22, 2025 05:40
@optimisan optimisan force-pushed the users/optimisan/04-15-_codegen_npm_do_not_add_required_passes_to_pipeline_skip-even-required-passes branch 2 times, most recently from 33d6bcf to 0b820a0 Compare April 22, 2025 06:42
@optimisan optimisan force-pushed the users/optimisan/04-02-_amdgpu_npm_add_isrequired_to_passes_missing_it branch from 1b93c63 to 50a8ebc Compare April 22, 2025 06:42
@optimisan optimisan force-pushed the users/optimisan/04-15-_codegen_npm_do_not_add_required_passes_to_pipeline_skip-even-required-passes branch from 0b820a0 to 269e279 Compare May 5, 2025 06:14
@optimisan optimisan force-pushed the users/optimisan/04-02-_amdgpu_npm_add_isrequired_to_passes_missing_it branch from 50a8ebc to 45100af Compare May 5, 2025 06:14
Base automatically changed from users/optimisan/04-15-_codegen_npm_do_not_add_required_passes_to_pipeline_skip-even-required-passes to main July 9, 2025 09:23
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.

5 participants