[llvm] ef69aa9 - [InlineCost] Enable the cost benefit analysis on FDO

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 24 15:37:20 PDT 2021


Author: Kazu Hirata
Date: 2021-03-24T15:36:49-07:00
New Revision: ef69aa961d12dee2141a79b05c9637d8cc9c0c74

URL: https://github.com/llvm/llvm-project/commit/ef69aa961d12dee2141a79b05c9637d8cc9c0c74
DIFF: https://github.com/llvm/llvm-project/commit/ef69aa961d12dee2141a79b05c9637d8cc9c0c74.diff

LOG: [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

Added: 
    

Modified: 
    llvm/lib/Analysis/InlineCost.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index b742259758d8..393efa8bfc6f 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;


        


More information about the llvm-commits mailing list