diff options
author | Kazu Hirata <kazu@google.com> | 2021-03-25 21:51:38 -0700 |
---|---|---|
committer | Kazu Hirata <kazu@google.com> | 2021-03-25 21:51:38 -0700 |
commit | 9d375a40c3df90dd48edc0e1b1115c702c55d716 (patch) | |
tree | 0d6bf338429fa3acaef5fb787dbe3d1aaa1b21d3 /llvm/lib/Analysis/InlineCost.cpp | |
parent | 3c775d93a1dda3cec3bb6c7617c4b4ab770f4af0 (diff) | |
download | llvm-9d375a40c3df90dd48edc0e1b1115c702c55d716.zip llvm-9d375a40c3df90dd48edc0e1b1115c702c55d716.tar.gz llvm-9d375a40c3df90dd48edc0e1b1115c702c55d716.tar.bz2 |
Reapply [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.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index 538dfac..f4e22d4 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -675,15 +675,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; |