summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Analysis/LoopInfo.cpp12
-rw-r--r--llvm/test/Other/loop-pass-printer.ll14
2 files changed, 24 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp
index dce66fd3d96..9e54d60779a 100644
--- a/llvm/lib/Analysis/LoopInfo.cpp
+++ b/llvm/lib/Analysis/LoopInfo.cpp
@@ -731,6 +731,18 @@ PreservedAnalyses LoopPrinterPass::run(Function &F,
}
void llvm::printLoop(Loop &L, raw_ostream &OS, const std::string &Banner) {
+
+ if (forcePrintModuleIR()) {
+ // handling -print-module-scope
+ OS << Banner << " (loop: ";
+ L.getHeader()->printAsOperand(OS, false);
+ OS << ")\n";
+
+ // printing whole module
+ OS << *L.getHeader()->getModule();
+ return;
+ }
+
OS << Banner;
auto *PreHeader = L.getLoopPreheader();
diff --git a/llvm/test/Other/loop-pass-printer.ll b/llvm/test/Other/loop-pass-printer.ll
index e5ad8bdb1f9..bedcf164ace 100644
--- a/llvm/test/Other/loop-pass-printer.ll
+++ b/llvm/test/Other/loop-pass-printer.ll
@@ -7,7 +7,9 @@
; RUN: opt < %s 2>&1 -disable-output \
; RUN: -loop-unroll -print-after=loop-unroll -filter-print-funcs=bar \
; RUN: | FileCheck %s -check-prefix=BAR
-;
+; RUN: opt < %s 2>&1 -disable-output \
+; RUN: -loop-unroll -print-after=loop-unroll -filter-print-funcs=foo -print-module-scope \
+; RUN: | FileCheck %s -check-prefix=FOO-MODULE
; DEL: IR Dump Before
; DEL-SAME: dead loops
@@ -35,9 +37,17 @@
; BAR-NEXT: loop:
; BAR: ; Exit blocks
; BAR: end:
-; BAR-NOT: IR Dump Before
+; BAR-NOT: IR Dump
; BAR-NOT: ; Loop
+; FOO-MODULE: IR Dump After
+; FOO-MODULE-SAME: Unroll
+; FOO-MODULE-SAME: loop: %loop
+; FOO-MODULE-NEXT: ModuleID =
+; FOO-MODULE: define void @foo
+; FOO-MODULE: define void @bar
+; FOO-MODULE-NOT: IR Dump
+
define void @foo(){
%idx = alloca i32, align 4
store i32 0, i32* %idx, align 4
OpenPOWER on IntegriCloud