[llvm] 6cea404 - [IR] Remove RepeatedPass (#96211)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 20 10:39:22 PDT 2024
Author: Nikita Popov
Date: 2024-06-20T19:39:19+02:00
New Revision: 6cea40400df542a1a4a6d35b45cbe3367f2c32b7
URL: https://github.com/llvm/llvm-project/commit/6cea40400df542a1a4a6d35b45cbe3367f2c32b7
DIFF: https://github.com/llvm/llvm-project/commit/6cea40400df542a1a4a6d35b45cbe3367f2c32b7.diff
LOG: [IR] Remove RepeatedPass (#96211)
This pass is not used in any pipeline, barely used in tests and not
really useful, so drop it. The only place where we "repeat" passes is
devirt repetition, and that is done using a separate pass.
Added:
Modified:
llvm/include/llvm/IR/PassManager.h
llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
llvm/lib/Passes/PassBuilder.cpp
llvm/test/Other/new-pass-manager.ll
llvm/test/Other/new-pm-print-pipeline.ll
llvm/test/Transforms/Coroutines/coro-elide-stat.ll
llvm/test/Transforms/Coroutines/coro-elide.ll
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h
index 5661a1d58c8ec..65ba524bf49c4 100644
--- a/llvm/include/llvm/IR/PassManager.h
+++ b/llvm/include/llvm/IR/PassManager.h
@@ -950,58 +950,6 @@ struct InvalidateAllAnalysesPass : PassInfoMixin<InvalidateAllAnalysesPass> {
}
};
-/// A utility pass template that simply runs another pass multiple times.
-///
-/// This can be useful when debugging or testing passes. It also serves as an
-/// example of how to extend the pass manager in ways beyond composition.
-template <typename PassT>
-class RepeatedPass : public PassInfoMixin<RepeatedPass<PassT>> {
-public:
- RepeatedPass(int Count, PassT &&P)
- : Count(Count), P(std::forward<PassT>(P)) {}
-
- template <typename IRUnitT, typename AnalysisManagerT, typename... Ts>
- PreservedAnalyses run(IRUnitT &IR, AnalysisManagerT &AM, Ts &&... Args) {
-
- // Request PassInstrumentation from analysis manager, will use it to run
- // instrumenting callbacks for the passes later.
- // Here we use std::tuple wrapper over getResult which helps to extract
- // AnalysisManager's arguments out of the whole Args set.
- PassInstrumentation PI =
- detail::getAnalysisResult<PassInstrumentationAnalysis>(
- AM, IR, std::tuple<Ts...>(Args...));
-
- auto PA = PreservedAnalyses::all();
- for (int i = 0; i < Count; ++i) {
- // Check the PassInstrumentation's BeforePass callbacks before running the
- // pass, skip its execution completely if asked to (callback returns
- // false).
- if (!PI.runBeforePass<IRUnitT>(P, IR))
- continue;
- PreservedAnalyses IterPA = P.run(IR, AM, std::forward<Ts>(Args)...);
- PA.intersect(IterPA);
- PI.runAfterPass(P, IR, IterPA);
- }
- return PA;
- }
-
- void printPipeline(raw_ostream &OS,
- function_ref<StringRef(StringRef)> MapClassName2PassName) {
- OS << "repeat<" << Count << ">(";
- P.printPipeline(OS, MapClassName2PassName);
- OS << ')';
- }
-
-private:
- int Count;
- PassT P;
-};
-
-template <typename PassT>
-RepeatedPass<PassT> createRepeatedPass(int Count, PassT &&P) {
- return RepeatedPass<PassT>(Count, std::forward<PassT>(P));
-}
-
} // end namespace llvm
#endif // LLVM_IR_PASSMANAGER_H
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
index 6aab1f98e6781..7bdb4eafd107d 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
@@ -129,37 +129,6 @@ class PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
new LoopNestPassModelT(std::forward<PassT>(Pass))));
}
- // Specializations of `addPass` for `RepeatedPass`. These are necessary since
- // `RepeatedPass` has a templated `run` method that will result in incorrect
- // detection of `HasRunOnLoopT`.
- template <typename PassT>
- LLVM_ATTRIBUTE_MINSIZE
- std::enable_if_t<is_detected<HasRunOnLoopT, PassT>::value>
- addPass(RepeatedPass<PassT> &&Pass) {
- using RepeatedLoopPassModelT =
- detail::PassModel<Loop, RepeatedPass<PassT>, LoopAnalysisManager,
- LoopStandardAnalysisResults &, LPMUpdater &>;
- IsLoopNestPass.push_back(false);
- // Do not use make_unique or emplace_back, they cause too many template
- // instantiations, causing terrible compile times.
- LoopPasses.push_back(std::unique_ptr<LoopPassConceptT>(
- new RepeatedLoopPassModelT(std::move(Pass))));
- }
-
- template <typename PassT>
- LLVM_ATTRIBUTE_MINSIZE
- std::enable_if_t<!is_detected<HasRunOnLoopT, PassT>::value>
- addPass(RepeatedPass<PassT> &&Pass) {
- using RepeatedLoopNestPassModelT =
- detail::PassModel<LoopNest, RepeatedPass<PassT>, LoopAnalysisManager,
- LoopStandardAnalysisResults &, LPMUpdater &>;
- IsLoopNestPass.push_back(true);
- // Do not use make_unique or emplace_back, they cause too many template
- // instantiations, causing terrible compile times.
- LoopNestPasses.push_back(std::unique_ptr<LoopNestPassConceptT>(
- new RepeatedLoopNestPassModelT(std::move(Pass))));
- }
-
bool isEmpty() const { return LoopPasses.empty() && LoopNestPasses.empty(); }
static bool isRequired() { return true; }
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 19e8a8ab68a73..53025cfcdb86d 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -506,15 +506,6 @@ void PassBuilder::registerLoopAnalyses(LoopAnalysisManager &LAM) {
C(LAM);
}
-static std::optional<int> parseRepeatPassName(StringRef Name) {
- if (!Name.consume_front("repeat<") || !Name.consume_back(">"))
- return std::nullopt;
- int Count;
- if (Name.getAsInteger(0, Count) || Count <= 0)
- return std::nullopt;
- return Count;
-}
-
static std::optional<std::pair<bool, bool>>
parseFunctionPipelineName(StringRef Name) {
std::pair<bool, bool> Params;
@@ -1243,10 +1234,6 @@ static bool isModulePassName(StringRef Name, CallbacksT &Callbacks) {
if (Name == "coro-cond")
return true;
- // Explicitly handle custom-parsed pass names.
- if (parseRepeatPassName(Name))
- return true;
-
#define MODULE_PASS(NAME, CREATE_PASS) \
if (Name == NAME) \
return true;
@@ -1271,8 +1258,6 @@ static bool isCGSCCPassName(StringRef Name, CallbacksT &Callbacks) {
return true;
// Explicitly handle custom-parsed pass names.
- if (parseRepeatPassName(Name))
- return true;
if (parseDevirtPassName(Name))
return true;
@@ -1299,10 +1284,6 @@ static bool isFunctionPassName(StringRef Name, CallbacksT &Callbacks) {
if (Name == "loop" || Name == "loop-mssa" || Name == "machine-function")
return true;
- // Explicitly handle custom-parsed pass names.
- if (parseRepeatPassName(Name))
- return true;
-
#define FUNCTION_PASS(NAME, CREATE_PASS) \
if (Name == NAME) \
return true;
@@ -1323,10 +1304,6 @@ static bool isMachineFunctionPassName(StringRef Name, CallbacksT &Callbacks) {
if (Name == "machine-function")
return true;
- // Explicitly handle custom-parsed pass names.
- if (parseRepeatPassName(Name))
- return true;
-
#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
if (Name == NAME) \
return true;
@@ -1349,10 +1326,6 @@ static bool isLoopNestPassName(StringRef Name, CallbacksT &Callbacks,
bool &UseMemorySSA) {
UseMemorySSA = false;
- // Explicitly handle custom-parsed pass names.
- if (parseRepeatPassName(Name))
- return true;
-
if (PassBuilder::checkParametrizedPassName(Name, "lnicm")) {
UseMemorySSA = true;
return true;
@@ -1371,10 +1344,6 @@ static bool isLoopPassName(StringRef Name, CallbacksT &Callbacks,
bool &UseMemorySSA) {
UseMemorySSA = false;
- // Explicitly handle custom-parsed pass names.
- if (parseRepeatPassName(Name))
- return true;
-
if (PassBuilder::checkParametrizedPassName(Name, "licm")) {
UseMemorySSA = true;
return true;
@@ -1491,13 +1460,6 @@ Error PassBuilder::parseModulePass(ModulePassManager &MPM,
createModuleToFunctionPassAdaptor(std::move(FPM), Params->first));
return Error::success();
}
- if (auto Count = parseRepeatPassName(Name)) {
- ModulePassManager NestedMPM;
- if (auto Err = parseModulePassPipeline(NestedMPM, InnerPipeline))
- return Err;
- MPM.addPass(createRepeatedPass(*Count, std::move(NestedMPM)));
- return Error::success();
- }
for (auto &C : ModulePipelineParsingCallbacks)
if (C(Name, MPM, InnerPipeline))
@@ -1660,13 +1622,6 @@ Error PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM,
std::move(FPM), Params->first, Params->second));
return Error::success();
}
- if (auto Count = parseRepeatPassName(Name)) {
- CGSCCPassManager NestedCGPM;
- if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
- return Err;
- CGPM.addPass(createRepeatedPass(*Count, std::move(NestedCGPM)));
- return Error::success();
- }
if (auto MaxRepetitions = parseDevirtPassName(Name)) {
CGSCCPassManager NestedCGPM;
if (auto Err = parseCGSCCPassPipeline(NestedCGPM, InnerPipeline))
@@ -1789,13 +1744,6 @@ Error PassBuilder::parseFunctionPass(FunctionPassManager &FPM,
UseBFI, UseBPI));
return Error::success();
}
- if (auto Count = parseRepeatPassName(Name)) {
- FunctionPassManager NestedFPM;
- if (auto Err = parseFunctionPassPipeline(NestedFPM, InnerPipeline))
- return Err;
- FPM.addPass(createRepeatedPass(*Count, std::move(NestedFPM)));
- return Error::success();
- }
if (Name == "machine-function") {
MachineFunctionPassManager MFPM;
if (auto Err = parseMachinePassPipeline(MFPM, InnerPipeline))
@@ -1888,13 +1836,6 @@ Error PassBuilder::parseLoopPass(LoopPassManager &LPM,
LPM.addPass(std::move(NestedLPM));
return Error::success();
}
- if (auto Count = parseRepeatPassName(Name)) {
- LoopPassManager NestedLPM;
- if (auto Err = parseLoopPassPipeline(NestedLPM, InnerPipeline))
- return Err;
- LPM.addPass(createRepeatedPass(*Count, std::move(NestedLPM)));
- return Error::success();
- }
for (auto &C : LoopPipelineParsingCallbacks)
if (C(Name, LPM, InnerPipeline))
diff --git a/llvm/test/Other/new-pass-manager.ll b/llvm/test/Other/new-pass-manager.ll
index db0af54fe4ae8..f0fe708806f1b 100644
--- a/llvm/test/Other/new-pass-manager.ll
+++ b/llvm/test/Other/new-pass-manager.ll
@@ -299,60 +299,6 @@
; avoiding FileCheck complaining about the unused prefix.
; CHECK-NOEXT: {{.*}}
-; RUN: opt -disable-output -disable-verify -verify-analysis-invalidation=0 -debug-pass-manager \
-; RUN: -passes='repeat<3>(no-op-module)' %s 2>&1 \
-; RUN: | FileCheck %s --check-prefix=CHECK-REPEAT-MODULE-PASS
-; CHECK-REPEAT-MODULE-PASS: Running pass: RepeatedPass
-; CHECK-REPEAT-MODULE-PASS-NEXT: Running pass: NoOpModulePass
-; CHECK-REPEAT-MODULE-PASS-NEXT: Running pass: NoOpModulePass
-; CHECK-REPEAT-MODULE-PASS-NEXT: Running pass: NoOpModulePass
-
-; RUN: opt -disable-output -disable-verify -verify-analysis-invalidation=0 -debug-pass-manager \
-; RUN: -passes='cgscc(repeat<3>(no-op-cgscc))' %s 2>&1 \
-; RUN: | FileCheck %s --check-prefix=CHECK-REPEAT-CGSCC-PASS
-; CHECK-REPEAT-CGSCC-PASS: Running analysis: InnerAnalysisManagerProxy<{{.*(CGSCCAnalysisManager|AnalysisManager<.*LazyCallGraph::SCC.*>).*}},{{.*}}Module>
-; CHECK-REPEAT-CGSCC-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*(FunctionAnalysisManager|AnalysisManager<.*Function.*>).*}},{{.*}}Module>
-; CHECK-REPEAT-CGSCC-PASS-NEXT: Running analysis: LazyCallGraphAnalysis
-; CHECK-REPEAT-CGSCC-PASS-NEXT: Running analysis: TargetLibraryAnalysis
-; CHECK-REPEAT-CGSCC-PASS-NEXT: Running analysis: FunctionAnalysisManagerCGSCCProxy
-; CHECK-REPEAT-CGSCC-PASS-NEXT: Running analysis: OuterAnalysisManagerProxy<{{.*}}LazyCallGraph::SCC{{.*}}>
-; CHECK-REPEAT-CGSCC-PASS-NEXT: Running pass: RepeatedPass
-; CHECK-REPEAT-CGSCC-PASS-NEXT: Running pass: NoOpCGSCCPass
-; CHECK-REPEAT-CGSCC-PASS-NEXT: Running pass: NoOpCGSCCPass
-; CHECK-REPEAT-CGSCC-PASS-NEXT: Running pass: NoOpCGSCCPass
-
-; RUN: opt -disable-output -disable-verify -verify-analysis-invalidation=0 -debug-pass-manager \
-; RUN: -passes='function(repeat<3>(no-op-function))' %s 2>&1 \
-; RUN: | FileCheck %s --check-prefix=CHECK-REPEAT-FUNCTION-PASS
-; CHECK-REPEAT-FUNCTION-PASS: Running analysis: InnerAnalysisManagerProxy<{{.*}}>
-; CHECK-REPEAT-FUNCTION-PASS-NEXT: Running pass: RepeatedPass
-; CHECK-REPEAT-FUNCTION-PASS-NEXT: Running pass: NoOpFunctionPass
-; CHECK-REPEAT-FUNCTION-PASS-NEXT: Running pass: NoOpFunctionPass
-; CHECK-REPEAT-FUNCTION-PASS-NEXT: Running pass: NoOpFunctionPass
-
-; RUN: opt -disable-output -disable-verify -verify-analysis-invalidation=0 -debug-pass-manager \
-; RUN: -passes='loop(repeat<3>(no-op-loop))' %s 2>&1 \
-; RUN: | FileCheck %s --check-prefix=CHECK-REPEAT-LOOP-PASS
-; CHECK-REPEAT-LOOP-PASS: Running analysis: InnerAnalysisManagerProxy<{{.*}}>
-; CHECK-REPEAT-LOOP-PASS-NEXT: Running pass: LoopSimplify
-; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: LoopAnalysis
-; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: DominatorTreeAnalysis
-; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: AssumptionAnalysis
-; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: TargetIRAnalysis
-; CHECK-REPEAT-LOOP-PASS-NEXT: Running pass: LCSSAPass
-; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: AAManager
-; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: TargetLibraryAnalysis
-; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: BasicAA
-; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: ScopedNoAliasAA
-; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: TypeBasedAA
-; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: OuterAnalysisManagerProxy
-; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: ScalarEvolutionAnalysis
-; CHECK-REPEAT-LOOP-PASS-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}>
-; CHECK-REPEAT-LOOP-PASS-NEXT: Running pass: RepeatedPass
-; CHECK-REPEAT-LOOP-PASS-NEXT: Running pass: NoOpLoopPass
-; CHECK-REPEAT-LOOP-PASS-NEXT: Running pass: NoOpLoopPass
-; CHECK-REPEAT-LOOP-PASS-NEXT: Running pass: NoOpLoopPass
-
define void @foo(i1 %x, ptr %p1, ptr %p2) {
entry:
store i8 42, ptr %p1
diff --git a/llvm/test/Other/new-pm-print-pipeline.ll b/llvm/test/Other/new-pm-print-pipeline.ll
index 1bc0e95d10d81..a524c9991f1bf 100644
--- a/llvm/test/Other/new-pm-print-pipeline.ll
+++ b/llvm/test/Other/new-pm-print-pipeline.ll
@@ -6,9 +6,6 @@
; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(rpo-function-attrs,require<globals-aa>,function(float2int,lower-constant-intrinsics,loop(loop-rotate)),invalidate<globals-aa>)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-1
; CHECK-1: rpo-function-attrs,require<globals-aa>,function(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>)),invalidate<globals-aa>
-; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='repeat<5>(function(mem2reg)),invalidate<all>' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-2
-; CHECK-2: repeat<5>(function(mem2reg)),invalidate<all>
-
;; Test that we get ClassName printed when there is no ClassName to pass-name mapping (as is the case for the BitcodeWriterPass).
; RUN: opt -o /dev/null -disable-verify -print-pipeline-passes -passes='function(mem2reg)' < %s -disable-pipeline-verification | FileCheck %s --match-full-lines --check-prefixes=CHECK-3
; CHECK-3: function(mem2reg),BitcodeWriterPass
diff --git a/llvm/test/Transforms/Coroutines/coro-elide-stat.ll b/llvm/test/Transforms/Coroutines/coro-elide-stat.ll
index 0cf3143351b9e..eeb300af5068e 100644
--- a/llvm/test/Transforms/Coroutines/coro-elide-stat.ll
+++ b/llvm/test/Transforms/Coroutines/coro-elide-stat.ll
@@ -2,10 +2,10 @@
; REQUIRES: asserts
;
; RUN: opt < %s -S \
-; RUN: -passes='cgscc(repeat<2>(inline,function(coro-elide,dce)))' -stats 2>&1 \
+; RUN: -passes='cgscc(inline,function(coro-elide,dce),inline,function(coro-elide,dce))' -stats 2>&1 \
; RUN: | FileCheck %s
; RUN: opt < %s --disable-output \
-; RUN: -passes='cgscc(repeat<2>(inline,function(coro-elide,dce)))' \
+; RUN: -passes='cgscc(inline,function(coro-elide,dce),inline,function(coro-elide,dce))' \
; RUN: -coro-elide-info-output-file=%t && \
; RUN: cat %t \
; RUN: | FileCheck %s --check-prefix=FILE
diff --git a/llvm/test/Transforms/Coroutines/coro-elide.ll b/llvm/test/Transforms/Coroutines/coro-elide.ll
index 4232615a464b7..86ed88167bfe4 100644
--- a/llvm/test/Transforms/Coroutines/coro-elide.ll
+++ b/llvm/test/Transforms/Coroutines/coro-elide.ll
@@ -1,7 +1,7 @@
; Tests that the coro.destroy and coro.resume are devirtualized where possible,
; SCC pipeline restarts and inlines the direct calls.
; RUN: opt < %s -S \
-; RUN: -passes='cgscc(repeat<2>(inline,function(coro-elide,dce)))' \
+; RUN: -passes='cgscc(inline,function(coro-elide,dce),inline,function(coro-elide,dce))' \
; RUN: | FileCheck %s
declare void @print(i32) nounwind
More information about the llvm-commits
mailing list