Skip to content

Conversation

@fhahn
Copy link
Contributor

@fhahn fhahn commented Dec 10, 2024

As suggested post-commit for
#118323, adjust the extra pass managers to no inherit from Function/LoopPassManager, but manage the extra passes via member pass managers.

@llvmbot
Copy link
Member

llvmbot commented Dec 10, 2024

@llvm/pr-subscribers-llvm-transforms

Author: Florian Hahn (fhahn)

Changes

As suggested post-commit for
#118323, adjust the extra pass managers to no inherit from Function/LoopPassManager, but manage the extra passes via member pass managers.


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

1 Files Affected:

  • (modified) llvm/include/llvm/Transforms/Utils/ExtraPassManager.h (+20-4)
diff --git a/llvm/include/llvm/Transforms/Utils/ExtraPassManager.h b/llvm/include/llvm/Transforms/Utils/ExtraPassManager.h
index 7ea50a5584dde0..b3286e9bbd6444 100644
--- a/llvm/include/llvm/Transforms/Utils/ExtraPassManager.h
+++ b/llvm/include/llvm/Transforms/Utils/ExtraPassManager.h
@@ -55,11 +55,19 @@ template <typename MarkerTy> struct ShouldRunExtraPasses {
 /// request additional transformations on demand. An example is extra
 /// simplifications after loop-vectorization, if runtime checks have been added.
 template <typename MarkerTy>
-struct ExtraFunctionPassManager : public FunctionPassManager {
+class ExtraFunctionPassManager
+    : public PassInfoMixin<ExtraFunctionPassManager<MarkerTy>> {
+  FunctionPassManager InnerFPM;
+
+public:
+  template <typename PassT> void addPass(PassT &&Pass) {
+    InnerFPM.addPass(std::move(Pass));
+  }
+
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM) {
     auto PA = PreservedAnalyses::all();
     if (AM.getCachedResult<MarkerTy>(F))
-      PA.intersect(FunctionPassManager::run(F, AM));
+      PA.intersect(InnerFPM.run(F, AM));
     PA.abandon<MarkerTy>();
     return PA;
   }
@@ -69,12 +77,20 @@ struct ExtraFunctionPassManager : public FunctionPassManager {
 /// present. This allows passes to request additional transformations on demand.
 /// An example is doing additional runs of SimpleLoopUnswitch.
 template <typename MarkerTy>
-struct ExtraLoopPassManager : public LoopPassManager {
+class ExtraLoopPassManager
+    : public PassInfoMixin<ExtraLoopPassManager<MarkerTy>> {
+  LoopPassManager InnerLPM;
+
+public:
+  template <typename PassT> void addPass(PassT &&Pass) {
+    InnerLPM.addPass(std::move(Pass));
+  }
+
   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
                         LoopStandardAnalysisResults &AR, LPMUpdater &U) {
     auto PA = PreservedAnalyses::all();
     if (AM.getCachedResult<MarkerTy>(L))
-      PA.intersect(LoopPassManager::run(L, AM, AR, U));
+      PA.intersect(InnerLPM.run(L, AM, AR, U));
     PA.abandon<MarkerTy>();
     return PA;
   }

Copy link
Contributor

@aeubanks aeubanks left a comment

Choose a reason for hiding this comment

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

thanks!

As suggested post-commit for
llvm#118323, adjust the extra pass
managers to no inherit from Function/LoopPassManager, but manage the
extra passes via member pass managers.
@fhahn fhahn force-pushed the extra-pass-manager-member branch from e3fa578 to be580bf Compare December 11, 2024 11:33
@fhahn
Copy link
Contributor Author

fhahn commented Dec 11, 2024

Now that we don't inherit from the pass managers, I needed to added names for the passes and mark them as required.

@fhahn fhahn merged commit 62fcd45 into llvm:main Dec 11, 2024
8 checks passed
@fhahn fhahn deleted the extra-pass-manager-member branch December 11, 2024 18:45
@aeubanks
Copy link
Contributor

we need to figure out a way to represent these pass managers with the textual pipeline representation. it'll probably require something like

if (Name == "coro-cond") {

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