diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp --- a/llvm/lib/Passes/StandardInstrumentations.cpp +++ b/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(IR)) { + unsigned Count = any_cast(IR)->getInstructionCount(); + OS << " (" << Count << " instruction"; + if (Count != 1) + OS << 's'; + OS << ')'; + } else if (any_isa(IR)) { + int Count = any_cast(IR)->size(); + OS << " (" << Count << " node"; + if (Count != 1) + OS << 's'; + OS << ')'; + } + OS << "\n"; Indent += 2; }); PIC.registerAfterPassCallback( diff --git a/llvm/test/Other/print-function-size.ll b/llvm/test/Other/print-function-size.ll new file mode 100644 --- /dev/null +++ b/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 +} diff --git a/llvm/test/Other/print-scc-size.ll b/llvm/test/Other/print-scc-size.ll new file mode 100644 --- /dev/null +++ b/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 +}