[llvm] b18bf8f - [NewPM] Move PassManager::run() into Impl.h (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 20 04:00:11 PDT 2024
Author: Nikita Popov
Date: 2024-06-20T13:00:01+02:00
New Revision: b18bf8faaef952323c96e4c6b82f25623073fb1c
URL: https://github.com/llvm/llvm-project/commit/b18bf8faaef952323c96e4c6b82f25623073fb1c
DIFF: https://github.com/llvm/llvm-project/commit/b18bf8faaef952323c96e4c6b82f25623073fb1c.diff
LOG: [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.
Added:
Modified:
llvm/include/llvm/IR/PassManager.h
llvm/include/llvm/IR/PassManagerImpl.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h
index d701481202f8d..cdeed83bbf702 100644
--- a/llvm/include/llvm/IR/PassManager.h
+++ b/llvm/include/llvm/IR/PassManager.h
@@ -199,51 +199,7 @@ class PassManager : public PassInfoMixin<
/// 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 3c94cf2811f62..dc85ebc3644b9 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;
More information about the llvm-commits
mailing list