[PATCH] D82205: InlineCost - method ::print() to allow dump of statistics to non-debug builds

Kirill Naumov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 19 10:19:16 PDT 2020


knaumov created this revision.
knaumov added reviewers: apilipenko, mtrofin, fedor.sergeev, davidxl.
Herald added subscribers: llvm-commits, haicheng, hiraditya, eraman.
Herald added a project: LLVM.

This is a logical continuation of https://reviews.llvm.org/D81743.
My intention of the said patch was to introduce a pass that would allow us to print the debug stats to check the functionality of the inline and its decisions outside of debug builds. However, the definition of InlineCostCallAnalyzer::dump() is hidden inside preprocessing macros which caused the fall of several buildbots when I commit the change:
http://lab.llvm.org:8011/builders/fuchsia-x86_64-linux/builds/6688
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-win-fast/builds/17841

The idea of this change is to create another dumping function for InlineCostCallAnalyzer (namely, InlineCostCallAnalyzer::print()) with essentially identical purpose, but with the difference that its definition is not dependent on any preprocessing macros and, consequently build types.


https://reviews.llvm.org/D82205

Files:
  llvm/lib/Analysis/InlineCost.cpp


Index: llvm/lib/Analysis/InlineCost.cpp
===================================================================
--- llvm/lib/Analysis/InlineCost.cpp
+++ llvm/lib/Analysis/InlineCost.cpp
@@ -726,6 +726,10 @@
 
   void dump();
 
+  // Prints the same analysis as dump(), but its definition is not dependent
+  // on the build.
+  void print();
+
   Optional<InstructionCostDetail> getCostDetails(const Instruction *I) {
     if (InstructionCostDetailMap.find(I) != InstructionCostDetailMap.end())
       return InstructionCostDetailMap[I];
@@ -2167,6 +2171,26 @@
   return finalizeAnalysis();
 }
 
+void InlineCostCallAnalyzer::print() {
+#define PRINT_STAT(x) dbgs() << "      " #x ": " << x << "\n"
+  if (PrintInstructionComments)
+    F.print(dbgs(), &Writer);
+  PRINT_STAT(NumConstantArgs);
+  PRINT_STAT(NumConstantOffsetPtrArgs);
+  PRINT_STAT(NumAllocaArgs);
+  PRINT_STAT(NumConstantPtrCmps);
+  PRINT_STAT(NumConstantPtrDiffs);
+  PRINT_STAT(NumInstructionsSimplified);
+  PRINT_STAT(NumInstructions);
+  PRINT_STAT(SROACostSavings);
+  PRINT_STAT(SROACostSavingsLost);
+  PRINT_STAT(LoadEliminationCost);
+  PRINT_STAT(ContainsNoDuplicateCall);
+  PRINT_STAT(Cost);
+  PRINT_STAT(Threshold);
+#undef PRINT_STAT
+}
+
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 /// Dump stats about this call's analysis.
 LLVM_DUMP_METHOD void InlineCostCallAnalyzer::dump() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82205.272113.patch
Type: text/x-patch
Size: 1373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200619/672c975c/attachment.bin>


More information about the llvm-commits mailing list