[PATCH] D128003: [NewPM] Print function/SCC size with -debug-pass-manager

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 19 09:05:12 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8c6305b8b485: [NewPM] Print function/SCC size with -debug-pass-manager (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128003/new/

https://reviews.llvm.org/D128003

Files:
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/Other/print-function-size.ll
  llvm/test/Other/print-scc-size.ll


Index: llvm/test/Other/print-scc-size.ll
===================================================================
--- /dev/null
+++ llvm/test/Other/print-scc-size.ll
@@ -0,0 +1,18 @@
+; RUN: opt -S -debug-pass-manager -passes=no-op-cgscc < %s 2>&1 | FileCheck %s
+
+; CHECK: Running pass: NoOpCGSCCPass on (f) (1 node)
+; CHECK: Running pass: NoOpCGSCCPass on (g, h) (2 nodes)
+
+define void @f() {
+  ret void
+}
+
+define void @g() {
+  call void @h()
+  ret void
+}
+
+define void @h() {
+  call void @g()
+  ret void
+}
Index: llvm/test/Other/print-function-size.ll
===================================================================
--- /dev/null
+++ llvm/test/Other/print-function-size.ll
@@ -0,0 +1,14 @@
+; RUN: opt -S -debug-pass-manager -passes=no-op-function < %s 2>&1 | FileCheck %s
+
+; CHECK: Running pass: NoOpFunctionPass on f (3 instructions)
+; CHECK: Running pass: NoOpFunctionPass on g (1 instruction)
+
+define i32 @f(i32 %i) {
+  %a = add i32 %i, 1
+  %b = add i32 %a, 1
+  ret i32 %b
+}
+
+define i32 @g(i32 %i) {
+  ret i32 0
+}
Index: llvm/lib/Passes/StandardInstrumentations.cpp
===================================================================
--- llvm/lib/Passes/StandardInstrumentations.cpp
+++ llvm/lib/Passes/StandardInstrumentations.cpp
@@ -940,7 +940,22 @@
     if (isSpecialPass(PassID, SpecialPasses))
       return;
 
-    print() << "Running pass: " << PassID << " on " << getIRName(IR) << "\n";
+    auto &OS = print();
+    OS << "Running pass: " << PassID << " on " << getIRName(IR);
+    if (any_isa<const Function *>(IR)) {
+      unsigned Count = any_cast<const Function *>(IR)->getInstructionCount();
+      OS << " (" << Count << " instruction";
+      if (Count != 1)
+        OS << 's';
+      OS << ')';
+    } else if (any_isa<const LazyCallGraph::SCC *>(IR)) {
+      int Count = any_cast<const LazyCallGraph::SCC *>(IR)->size();
+      OS << " (" << Count << " node";
+      if (Count != 1)
+        OS << 's';
+      OS << ')';
+    }
+    OS << "\n";
     Indent += 2;
   });
   PIC.registerAfterPassCallback(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128003.445838.patch
Type: text/x-patch
Size: 2060 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220719/55381056/attachment.bin>


More information about the llvm-commits mailing list