[llvm] f10004e - [CSSPGO] Add stats for pre-inliner

Wenlei He via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 1 20:04:09 PDT 2021


Author: Wenlei He
Date: 2021-09-01T20:03:50-07:00
New Revision: f10004e7dd688f15cfec2e7c7c8a989696ef4b57

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

LOG: [CSSPGO] Add stats for pre-inliner

Add some stats to help tuning pre-inliner.

Differential Revision: https://reviews.llvm.org/D109098

Added: 
    

Modified: 
    llvm/tools/llvm-profgen/CSPreInliner.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-profgen/CSPreInliner.cpp b/llvm/tools/llvm-profgen/CSPreInliner.cpp
index a0544c0e6a9d0..ab6615c30846f 100644
--- a/llvm/tools/llvm-profgen/CSPreInliner.cpp
+++ b/llvm/tools/llvm-profgen/CSPreInliner.cpp
@@ -9,6 +9,7 @@
 #include "CSPreInliner.h"
 #include "ProfiledBinary.h"
 #include "llvm/ADT/SCCIterator.h"
+#include "llvm/ADT/Statistic.h"
 #include <cstdint>
 #include <queue>
 
@@ -17,6 +18,18 @@
 using namespace llvm;
 using namespace sampleprof;
 
+STATISTIC(PreInlNumCSInlined,
+          "Number of functions inlined with context sensitive profile");
+STATISTIC(PreInlNumCSNotInlined,
+          "Number of functions not inlined with context sensitive profile");
+STATISTIC(PreInlNumCSInlinedHitMinLimit,
+          "Number of functions with FDO inline stopped due to min size limit");
+STATISTIC(PreInlNumCSInlinedHitMaxLimit,
+          "Number of functions with FDO inline stopped due to max size limit");
+STATISTIC(
+    PreInlNumCSInlinedHitGrowthLimit,
+    "Number of functions with FDO inline stopped due to growth size limit");
+
 // The switches specify inline thresholds used in SampleProfileLoader inlining.
 // TODO: the actual threshold to be tuned here because the size here is based
 // on machine code not LLVM IR.
@@ -163,11 +176,14 @@ void CSPreInliner::processFunction(const StringRef Name) {
     if ((ShouldInline = shouldInline(Candidate))) {
       // We mark context as inlined as the corresponding context profile
       // won't be merged into that function's base profile.
+      ++PreInlNumCSInlined;
       ContextTracker.markContextSamplesInlined(Candidate.CalleeSamples);
       Candidate.CalleeSamples->getContext().setAttribute(
           ContextShouldBeInlined);
       FuncFinalSize += Candidate.SizeCost;
       getInlineCandidates(CQueue, Candidate.CalleeSamples);
+    } else {
+      ++PreInlNumCSNotInlined;
     }
     LLVM_DEBUG(dbgs() << (ShouldInline ? "  Inlined" : "  Outlined")
                       << " context profile for: "
@@ -176,6 +192,15 @@ void CSPreInliner::processFunction(const StringRef Name) {
                       << ", call count:" << Candidate.CallsiteCount << ")\n");
   }
 
+  if (!CQueue.empty()) {
+    if (SizeLimit == (unsigned)ProfileInlineLimitMax)
+      ++PreInlNumCSInlinedHitMaxLimit;
+    else if (SizeLimit == (unsigned)ProfileInlineLimitMin)
+      ++PreInlNumCSInlinedHitMinLimit;
+    else
+      ++PreInlNumCSInlinedHitGrowthLimit;
+  }
+
   LLVM_DEBUG({
     if (!CQueue.empty())
       dbgs() << "  Inline candidates ignored due to size limit (inliner "


        


More information about the llvm-commits mailing list