aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/InlineCost.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2021-03-24 15:36:48 -0700
committerKazu Hirata <kazu@google.com>2021-03-24 15:36:49 -0700
commitef69aa961d12dee2141a79b05c9637d8cc9c0c74 (patch)
treee7223c0010bdc1778deec18e48bba4cf0e117a46 /llvm/lib/Analysis/InlineCost.cpp
parent09a84d304776cbd97a31fbb0cc8ce772426aaabf (diff)
downloadllvm-ef69aa961d12dee2141a79b05c9637d8cc9c0c74.zip
llvm-ef69aa961d12dee2141a79b05c9637d8cc9c0c74.tar.gz
llvm-ef69aa961d12dee2141a79b05c9637d8cc9c0c74.tar.bz2
[InlineCost] Enable the cost benefit analysis on FDO
This patch enables the cost-benefit-analysis-based inliner by default if we have instrumentation profile. - SPEC CPU 2017 shows a 0.4% improvement. - An internal large benchmark shows a 0.9% reduction in the cycle count along with 14.6% reduction in the number of call instructions executed. Differential Revision: https://reviews.llvm.org/D98213
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r--llvm/lib/Analysis/InlineCost.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index b742259..393efa8 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -672,15 +672,22 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
}
bool isCostBenefitAnalysisEnabled() {
- if (!InlineEnableCostBenefitAnalysis)
- return false;
-
if (!PSI || !PSI->hasProfileSummary())
return false;
if (!GetBFI)
return false;
+ if (InlineEnableCostBenefitAnalysis.getNumOccurrences()) {
+ // Honor the explicit request from the user.
+ if (!InlineEnableCostBenefitAnalysis)
+ return false;
+ } else {
+ // Otherwise, require instrumentation profile.
+ if (!PSI->hasInstrumentationProfile())
+ return false;
+ }
+
auto *Caller = CandidateCall.getParent()->getParent();
if (!Caller->getEntryCount())
return false;