[llvm] 0f37081 - Mark PassBuilder::addPass() as minsize
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 5 22:10:33 PDT 2021
Author: Arthur Eubanks
Date: 2021-10-05T22:09:59-07:00
New Revision: 0f37081f989bceab5521a740ac5e92b7638b208b
URL: https://github.com/llvm/llvm-project/commit/0f37081f989bceab5521a740ac5e92b7638b208b
DIFF: https://github.com/llvm/llvm-project/commit/0f37081f989bceab5521a740ac5e92b7638b208b.diff
LOG: Mark PassBuilder::addPass() as minsize
PassBuilder.cpp is the slowest LLVM file to compile (if only building X86).
This makes PassBuilder.o a little faster to compile and a little smaller
as well.
These methods are not performance critical at all but are instantiated many times.
83M -> 72M instructions according to perf stat.
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D110782
Added:
Modified:
llvm/include/llvm/IR/PassManager.h
llvm/include/llvm/Support/Compiler.h
llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h
index 6d422d59235a3..d4f0bb331ea8f 100644
--- a/llvm/include/llvm/IR/PassManager.h
+++ b/llvm/include/llvm/IR/PassManager.h
@@ -548,8 +548,9 @@ class PassManager : public PassInfoMixin<
}
template <typename PassT>
- std::enable_if_t<!std::is_same<PassT, PassManager>::value>
- addPass(PassT &&Pass) {
+ LLVM_ATTRIBUTE_MINSIZE
+ std::enable_if_t<!std::is_same<PassT, PassManager>::value>
+ addPass(PassT &&Pass) {
using PassModelT =
detail::PassModel<IRUnitT, PassT, PreservedAnalyses, AnalysisManagerT,
ExtraArgTs...>;
@@ -565,8 +566,9 @@ class PassManager : public PassInfoMixin<
/// implementation complexity and avoid potential invalidation issues that may
/// happen with nested pass managers of the same type.
template <typename PassT>
- std::enable_if_t<std::is_same<PassT, PassManager>::value>
- addPass(PassT &&Pass) {
+ LLVM_ATTRIBUTE_MINSIZE
+ std::enable_if_t<std::is_same<PassT, PassManager>::value>
+ addPass(PassT &&Pass) {
for (auto &P : Pass.Passes)
Passes.push_back(std::move(P));
}
diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index f5937be157aa4..3f7a77ba559f4 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -212,6 +212,12 @@
#define LLVM_READONLY
#endif
+#if __has_attribute(minsize)
+#define LLVM_ATTRIBUTE_MINSIZE __attribute__((minsize))
+#else
+#define LLVM_ATTRIBUTE_MINSIZE
+#endif
+
#if __has_builtin(__builtin_expect) || LLVM_GNUC_PREREQ(4, 0, 0)
#define LLVM_LIKELY(EXPR) __builtin_expect((bool)(EXPR), true)
#define LLVM_UNLIKELY(EXPR) __builtin_expect((bool)(EXPR), false)
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
index 71af0dd4eab41..8aa20bded43a3 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
@@ -103,8 +103,9 @@ class PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
/// to the end of \var IsLoopNestPass so we can easily identify the types of
/// passes in the pass manager later.
template <typename PassT>
- std::enable_if_t<is_detected<HasRunOnLoopT, PassT>::value>
- addPass(PassT &&Pass) {
+ LLVM_ATTRIBUTE_MINSIZE
+ std::enable_if_t<is_detected<HasRunOnLoopT, PassT>::value>
+ addPass(PassT &&Pass) {
using LoopPassModelT =
detail::PassModel<Loop, PassT, PreservedAnalyses, LoopAnalysisManager,
LoopStandardAnalysisResults &, LPMUpdater &>;
@@ -116,8 +117,9 @@ class PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
}
template <typename PassT>
- std::enable_if_t<!is_detected<HasRunOnLoopT, PassT>::value>
- addPass(PassT &&Pass) {
+ LLVM_ATTRIBUTE_MINSIZE
+ std::enable_if_t<!is_detected<HasRunOnLoopT, PassT>::value>
+ addPass(PassT &&Pass) {
using LoopNestPassModelT =
detail::PassModel<LoopNest, PassT, PreservedAnalyses,
LoopAnalysisManager, LoopStandardAnalysisResults &,
@@ -133,8 +135,9 @@ class PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
// `RepeatedPass` has a templated `run` method that will result in incorrect
// detection of `HasRunOnLoopT`.
template <typename PassT>
- std::enable_if_t<is_detected<HasRunOnLoopT, PassT>::value>
- addPass(RepeatedPass<PassT> &&Pass) {
+ LLVM_ATTRIBUTE_MINSIZE
+ std::enable_if_t<is_detected<HasRunOnLoopT, PassT>::value>
+ addPass(RepeatedPass<PassT> &&Pass) {
using RepeatedLoopPassModelT =
detail::PassModel<Loop, RepeatedPass<PassT>, PreservedAnalyses,
LoopAnalysisManager, LoopStandardAnalysisResults &,
@@ -147,8 +150,9 @@ class PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
}
template <typename PassT>
- std::enable_if_t<!is_detected<HasRunOnLoopT, PassT>::value>
- addPass(RepeatedPass<PassT> &&Pass) {
+ LLVM_ATTRIBUTE_MINSIZE
+ std::enable_if_t<!is_detected<HasRunOnLoopT, PassT>::value>
+ addPass(RepeatedPass<PassT> &&Pass) {
using RepeatedLoopNestPassModelT =
detail::PassModel<LoopNest, RepeatedPass<PassT>, PreservedAnalyses,
LoopAnalysisManager, LoopStandardAnalysisResults &,
More information about the llvm-commits
mailing list