llvm.org GIT mirror llvm / 5608259
IR printing improvement for loop passes - handle -print-module-scope Summary: Adding support for -print-module-scope similar to how it is being done for function passes. This option causes loop-pass printer to emit a whole-module IR instead of just a loop itself. Reviewers: sanjoy, silvas, weimingz Reviewed By: sanjoy Subscribers: apilipenko, skatkov, llvm-commits Differential Revision: https://reviews.llvm.org/D40247 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319566 91177308-0d34-0410-b5e6-96231b3b80d8 Fedor Sergeev 1 year, 9 months ago
2 changed file(s) with 24 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
730730 }
731731
732732 void llvm::printLoop(Loop &L, raw_ostream &OS, const std::string &Banner) {
733
734 if (forcePrintModuleIR()) {
735 // handling -print-module-scope
736 OS << Banner << " (loop: ";
737 L.getHeader()->printAsOperand(OS, false);
738 OS << ")\n";
739
740 // printing whole module
741 OS << *L.getHeader()->getModule();
742 return;
743 }
744
733745 OS << Banner;
734746
735747 auto *PreHeader = L.getLoopPreheader();
66 ; RUN: opt < %s 2>&1 -disable-output \
77 ; RUN: -loop-unroll -print-after=loop-unroll -filter-print-funcs=bar \
88 ; RUN: | FileCheck %s -check-prefix=BAR
9 ;
9 ; RUN: opt < %s 2>&1 -disable-output \
10 ; RUN: -loop-unroll -print-after=loop-unroll -filter-print-funcs=foo -print-module-scope \
11 ; RUN: | FileCheck %s -check-prefix=FOO-MODULE
1012
1113 ; DEL: IR Dump Before
1214 ; DEL-SAME: dead loops
3436 ; BAR-NEXT: loop:
3537 ; BAR: ; Exit blocks
3638 ; BAR: end:
37 ; BAR-NOT: IR Dump Before
39 ; BAR-NOT: IR Dump
3840 ; BAR-NOT: ; Loop
41
42 ; FOO-MODULE: IR Dump After
43 ; FOO-MODULE-SAME: Unroll
44 ; FOO-MODULE-SAME: loop: %loop
45 ; FOO-MODULE-NEXT: ModuleID =
46 ; FOO-MODULE: define void @foo
47 ; FOO-MODULE: define void @bar
48 ; FOO-MODULE-NOT: IR Dump
3949
4050 define void @foo(){
4151 %idx = alloca i32, align 4