[llvm] ecd25ed - [InlineCost] Add empty line between call sites when printing inline costs

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 18 13:56:56 PDT 2021


Author: Arthur Eubanks
Date: 2021-10-18T13:56:48-07:00
New Revision: ecd25edfc5d908a1010fdf81419d779e8347de79

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

LOG: [InlineCost] Add empty line between call sites when printing inline costs

Added: 
    

Modified: 
    llvm/lib/Analysis/InlineCost.cpp
    llvm/test/Transforms/Inline/inline-cost-annotation-pass.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 4b5c1bf46a62..a77dd32f1816 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -1013,7 +1013,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
 
   // Prints the same analysis as dump(), but its definition is not dependent
   // on the build.
-  void print();
+  void print(raw_ostream &OS);
 
   Optional<InstructionCostDetail> getCostDetails(const Instruction *I) {
     if (InstructionCostDetailMap.find(I) != InstructionCostDetailMap.end())
@@ -2711,10 +2711,10 @@ InlineResult CallAnalyzer::analyze() {
   return finalizeAnalysis();
 }
 
-void InlineCostCallAnalyzer::print() {
-#define DEBUG_PRINT_STAT(x) dbgs() << "      " #x ": " << x << "\n"
+void InlineCostCallAnalyzer::print(raw_ostream &OS) {
+#define DEBUG_PRINT_STAT(x) OS << "      " #x ": " << x << "\n"
   if (PrintInstructionComments)
-    F.print(dbgs(), &Writer);
+    F.print(OS, &Writer);
   DEBUG_PRINT_STAT(NumConstantArgs);
   DEBUG_PRINT_STAT(NumConstantOffsetPtrArgs);
   DEBUG_PRINT_STAT(NumAllocaArgs);
@@ -2733,7 +2733,7 @@ void InlineCostCallAnalyzer::print() {
 
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 /// Dump stats about this call's analysis.
-LLVM_DUMP_METHOD void InlineCostCallAnalyzer::dump() { print(); }
+LLVM_DUMP_METHOD void InlineCostCallAnalyzer::dump() { print(dbgs()); }
 #endif
 
 /// Test that there are no attribute conflicts between Caller and Callee
@@ -3127,7 +3127,8 @@ InlineCostAnnotationPrinterPass::run(Function &F,
         ICCA.analyze();
         OS << "      Analyzing call of " << CalledFunction->getName()
            << "... (caller:" << CI->getCaller()->getName() << ")\n";
-        ICCA.print();
+        ICCA.print(OS);
+        OS << "\n";
       }
     }
   }

diff  --git a/llvm/test/Transforms/Inline/inline-cost-annotation-pass.ll b/llvm/test/Transforms/Inline/inline-cost-annotation-pass.ll
index 73b8a0bb0c0b..17b2e1581e6e 100644
--- a/llvm/test/Transforms/Inline/inline-cost-annotation-pass.ll
+++ b/llvm/test/Transforms/Inline/inline-cost-annotation-pass.ll
@@ -20,6 +20,8 @@
 ; CHECK:       ContainsNoDuplicateCall: {{.*}}
 ; CHECK:       Cost: {{.*}}
 ; CHECK:       Threshold: {{.*}}
+; CHECK-EMPTY:
+; CHECK:  Analyzing call of foo... (caller:main)
 
 define i8 addrspace(1)** @foo() {
   %1 = inttoptr i64 754974720 to i8 addrspace(1)**
@@ -28,5 +30,6 @@ define i8 addrspace(1)** @foo() {
 
 define i8 addrspace(1)** @main() {
   %1 = call i8 addrspace(1)** @foo()
+  %2 = call i8 addrspace(1)** @foo()
   ret i8 addrspace(1)** %1
 }


        


More information about the llvm-commits mailing list