aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2024-06-20 12:00:19 +0200
committerNikita Popov <npopov@redhat.com>2024-06-20 13:00:01 +0200
commitb18bf8faaef952323c96e4c6b82f25623073fb1c (patch)
tree6d10010925574841cba421096ef27f88c8b2396c
parent797724975bd5916408d776dcfb959a979778e349 (diff)
downloadllvm-b18bf8faaef952323c96e4c6b82f25623073fb1c.zip
llvm-b18bf8faaef952323c96e4c6b82f25623073fb1c.tar.gz
llvm-b18bf8faaef952323c96e4c6b82f25623073fb1c.tar.bz2
[NewPM] Move PassManager::run() into Impl.h (NFC)
We use explicit template instantiation for these classes, so there is no need to have the definition in the header. The places that instantiate the method will include the PassManagerImpl.h file.
-rw-r--r--llvm/include/llvm/IR/PassManager.h46
-rw-r--r--llvm/include/llvm/IR/PassManagerImpl.h48
2 files changed, 49 insertions, 45 deletions
diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h
index d701481..cdeed83 100644
--- a/llvm/include/llvm/IR/PassManager.h
+++ b/llvm/include/llvm/IR/PassManager.h
@@ -199,51 +199,7 @@ public:
/// Run all of the passes in this manager over the given unit of IR.
/// ExtraArgs are passed to each pass.
PreservedAnalyses run(IRUnitT &IR, AnalysisManagerT &AM,
- ExtraArgTs... ExtraArgs) {
- PreservedAnalyses PA = PreservedAnalyses::all();
-
- // 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 ExtraArgs set.
- PassInstrumentation PI =
- detail::getAnalysisResult<PassInstrumentationAnalysis>(
- AM, IR, std::tuple<ExtraArgTs...>(ExtraArgs...));
-
- // RemoveDIs: if requested, convert debug-info to DbgRecord representation
- // for duration of these passes.
- ScopedDbgInfoFormatSetter FormatSetter(IR, UseNewDbgInfoFormat);
-
- for (auto &Pass : Passes) {
- // Check the PassInstrumentation's BeforePass callbacks before running the
- // pass, skip its execution completely if asked to (callback returns
- // false).
- if (!PI.runBeforePass<IRUnitT>(*Pass, IR))
- continue;
-
- PreservedAnalyses PassPA = Pass->run(IR, AM, ExtraArgs...);
-
- // Update the analysis manager as each pass runs and potentially
- // invalidates analyses.
- AM.invalidate(IR, PassPA);
-
- // Call onto PassInstrumentation's AfterPass callbacks immediately after
- // running the pass.
- PI.runAfterPass<IRUnitT>(*Pass, IR, PassPA);
-
- // Finally, intersect the preserved analyses to compute the aggregate
- // preserved set for this pass manager.
- PA.intersect(std::move(PassPA));
- }
-
- // Invalidation was handled after each pass in the above loop for the
- // current unit of IR. Therefore, the remaining analysis results in the
- // AnalysisManager are preserved. We mark this with a set so that we don't
- // need to inspect each one individually.
- PA.preserveSet<AllAnalysesOn<IRUnitT>>();
-
- return PA;
- }
+ ExtraArgTs... ExtraArgs);
// FIXME: Revert to enable_if style when gcc >= 11.1
template <typename PassT> LLVM_ATTRIBUTE_MINSIZE void addPass(PassT &&Pass) {
diff --git a/llvm/include/llvm/IR/PassManagerImpl.h b/llvm/include/llvm/IR/PassManagerImpl.h
index 3c94cf2..dc85ebc 100644
--- a/llvm/include/llvm/IR/PassManagerImpl.h
+++ b/llvm/include/llvm/IR/PassManagerImpl.h
@@ -19,6 +19,54 @@
namespace llvm {
+template <typename IRUnitT, typename AnalysisManagerT, typename... ExtraArgTs>
+PreservedAnalyses PassManager<IRUnitT, AnalysisManagerT, ExtraArgTs...>::run(
+ IRUnitT &IR, AnalysisManagerT &AM, ExtraArgTs... ExtraArgs) {
+ PreservedAnalyses PA = PreservedAnalyses::all();
+
+ // 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 ExtraArgs set.
+ PassInstrumentation PI =
+ detail::getAnalysisResult<PassInstrumentationAnalysis>(
+ AM, IR, std::tuple<ExtraArgTs...>(ExtraArgs...));
+
+ // RemoveDIs: if requested, convert debug-info to DbgRecord representation
+ // for duration of these passes.
+ ScopedDbgInfoFormatSetter FormatSetter(IR, UseNewDbgInfoFormat);
+
+ for (auto &Pass : Passes) {
+ // Check the PassInstrumentation's BeforePass callbacks before running the
+ // pass, skip its execution completely if asked to (callback returns
+ // false).
+ if (!PI.runBeforePass<IRUnitT>(*Pass, IR))
+ continue;
+
+ PreservedAnalyses PassPA = Pass->run(IR, AM, ExtraArgs...);
+
+ // Update the analysis manager as each pass runs and potentially
+ // invalidates analyses.
+ AM.invalidate(IR, PassPA);
+
+ // Call onto PassInstrumentation's AfterPass callbacks immediately after
+ // running the pass.
+ PI.runAfterPass<IRUnitT>(*Pass, IR, PassPA);
+
+ // Finally, intersect the preserved analyses to compute the aggregate
+ // preserved set for this pass manager.
+ PA.intersect(std::move(PassPA));
+ }
+
+ // Invalidation was handled after each pass in the above loop for the
+ // current unit of IR. Therefore, the remaining analysis results in the
+ // AnalysisManager are preserved. We mark this with a set so that we don't
+ // need to inspect each one individually.
+ PA.preserveSet<AllAnalysesOn<IRUnitT>>();
+
+ return PA;
+}
+
template <typename IRUnitT, typename... ExtraArgTs>
inline AnalysisManager<IRUnitT, ExtraArgTs...>::AnalysisManager() = default;