-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Passes] Manage extra passes using inner pass managers (NFC). #119348
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
Conversation
|
@llvm/pr-subscribers-llvm-transforms Author: Florian Hahn (fhahn) ChangesAs suggested post-commit for Full diff: https://github.com/llvm/llvm-project/pull/119348.diff 1 Files Affected:
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;
}
|
aeubanks
left a comment
There was a problem hiding this 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.
e3fa578 to
be580bf
Compare
|
Now that we don't inherit from the pass managers, I needed to added names for the passes and mark them as required. |
|
we need to figure out a way to represent these pass managers with the textual pipeline representation. it'll probably require something like llvm-project/llvm/lib/Passes/PassBuilder.cpp Line 1530 in a8456c9
|
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.