[PATCH] D98213: [InlineCost] Enable the cost benefit analysis on FDO

Kazu Hirata via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 8 12:17:02 PST 2021


kazu created this revision.
kazu added a reviewer: davidxl.
Herald added subscribers: wenlei, haicheng, hiraditya, eraman.
kazu requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98213

Files:
  llvm/lib/Analysis/InlineCost.cpp


Index: llvm/lib/Analysis/InlineCost.cpp
===================================================================
--- llvm/lib/Analysis/InlineCost.cpp
+++ llvm/lib/Analysis/InlineCost.cpp
@@ -672,15 +672,22 @@
   }
 
   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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98213.329098.patch
Type: text/x-patch
Size: 872 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210308/740d29c9/attachment.bin>


More information about the llvm-commits mailing list