[PATCH] D110775: Instantiate fewer templates in PassManager::addPass()
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 29 13:54:11 PDT 2021
aeubanks created this revision.
aeubanks added a reviewer: rnk.
Herald added a subscriber: dexonsmith.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
We create many instantiations of PassManager::addPass() in
PassBuilder.cpp. vector::emplace_back() and make_unique() are both
templated and would have many instantiations based on the number of
times we instantiate addPass(). Now we directly construct the
unique_ptr with the type as the actual unique_ptr type in the vector we
are adding it to, so we only have one unique_ptr constructor
instantiation across all addPass() instantiations and only the
non-templated push_back().
This makes PassBuilder.cpp slightly faster to build.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D110775
Files:
llvm/include/llvm/IR/PassManager.h
llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
Index: llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
===================================================================
--- llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
+++ llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
@@ -109,7 +109,8 @@
detail::PassModel<Loop, PassT, PreservedAnalyses, LoopAnalysisManager,
LoopStandardAnalysisResults &, LPMUpdater &>;
IsLoopNestPass.push_back(false);
- LoopPasses.emplace_back(new LoopPassModelT(std::forward<PassT>(Pass)));
+ LoopPasses.push_back(std::unique_ptr<LoopPassConceptT>(
+ new LoopPassModelT(std::forward<PassT>(Pass))));
}
template <typename PassT>
@@ -120,8 +121,8 @@
LoopAnalysisManager, LoopStandardAnalysisResults &,
LPMUpdater &>;
IsLoopNestPass.push_back(true);
- LoopNestPasses.emplace_back(
- new LoopNestPassModelT(std::forward<PassT>(Pass)));
+ LoopNestPasses.push_back(std::unique_ptr<LoopNestPassConceptT>(
+ new LoopNestPassModelT(std::forward<PassT>(Pass))));
}
// Specializations of `addPass` for `RepeatedPass`. These are necessary since
@@ -135,7 +136,8 @@
LoopAnalysisManager, LoopStandardAnalysisResults &,
LPMUpdater &>;
IsLoopNestPass.push_back(false);
- LoopPasses.emplace_back(new RepeatedLoopPassModelT(std::move(Pass)));
+ LoopPasses.push_back(std::unique_ptr<LoopPassConceptT>(
+ new RepeatedLoopPassModelT(std::move(Pass))));
}
template <typename PassT>
@@ -146,8 +148,8 @@
LoopAnalysisManager, LoopStandardAnalysisResults &,
LPMUpdater &>;
IsLoopNestPass.push_back(true);
- LoopNestPasses.emplace_back(
- new RepeatedLoopNestPassModelT(std::move(Pass)));
+ LoopNestPasses.push_back(std::unique_ptr<LoopNestPassConceptT>(
+ new RepeatedLoopNestPassModelT(std::move(Pass))));
}
bool isEmpty() const { return LoopPasses.empty() && LoopNestPasses.empty(); }
Index: llvm/include/llvm/IR/PassManager.h
===================================================================
--- llvm/include/llvm/IR/PassManager.h
+++ llvm/include/llvm/IR/PassManager.h
@@ -554,7 +554,8 @@
detail::PassModel<IRUnitT, PassT, PreservedAnalyses, AnalysisManagerT,
ExtraArgTs...>;
- Passes.emplace_back(new PassModelT(std::forward<PassT>(Pass)));
+ Passes.push_back(std::unique_ptr<PassConceptT>(
+ new PassModelT(std::forward<PassT>(Pass))));
}
/// When adding a pass manager pass that has the same type as this pass
@@ -566,7 +567,7 @@
std::enable_if_t<std::is_same<PassT, PassManager>::value>
addPass(PassT &&Pass) {
for (auto &P : Pass.Passes)
- Passes.emplace_back(std::move(P));
+ Passes.push_back(std::move(P));
}
/// Returns if the pass manager contains any passes.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110775.376029.patch
Type: text/x-patch
Size: 2951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210929/82cc73dc/attachment.bin>
More information about the llvm-commits
mailing list