xref: /llvm-project/llvm/test/Other/print-loop-func-scope.ll (revision 5b6a26ccdd98da7c5246d4c23ef7cc596189b52c)
1; This test documents how the IR dumped for loop passes differs with -print-loop-func-scope
2; and -print-module-scope
3;   - Without -print-loop-func-scope, dumps only the loop, with 3 sections- preheader,
4;     loop, and exit blocks
5;   - With -print-loop-func-scope, dumps only the function which contains the loop
6;   - With -print-module-scope, dumps the entire module containing the loop, and disregards
7;     the -print-loop-func-scope flag.
8
9; RUN: opt < %s 2>&1 -disable-output \
10; RUN: 	   -passes=licm -print-after=licm \
11; RUN:	   | FileCheck %s -check-prefix=VANILLA
12; RUN: opt < %s 2>&1 -disable-output \
13; RUN: 	   -passes=licm -print-after=licm -print-loop-func-scope \
14; RUN:	   | FileCheck %s -check-prefix=LOOPFUNC
15; RUN: opt < %s 2>&1 -disable-output \
16; RUN: 	   -passes=licm -print-after=licm -print-module-scope \
17; RUN:	   | FileCheck %s -check-prefix=MODULE
18; RUN: opt < %s 2>&1 -disable-output \
19; RUN: 	   -passes=licm -print-after=licm -print-module-scope -print-loop-func-scope\
20; RUN:	   | FileCheck %s -check-prefix=MODULEWITHLOOP
21
22; VANILLA: IR Dump After LICMPass
23; VANILLA-NOT: define void @foo
24; VANILLA: Preheader:
25; VANILLA: Loop:
26; VANILLA: Exit blocks
27
28; LOOPFUNC: IR Dump After LICMPass
29; LOOPFUNC: (loop:
30; LOOPFUNC: define void @foo
31; LOOPFUNC-NOT: Preheader:
32; LOOPFUNC-NOT: Loop:
33; LOOPFUNC-NOT: Exit blocks
34
35; MODULE: IR Dump After LICMPass
36; MODULE: ModuleID =
37; MODULE: define void @foo
38; MODULE-NOT: Preheader:
39; MODULE-NOT: Loop:
40; MODULE-NOT: Exit blocks
41; MODULE: define void @bar
42; MODULE: declare void @baz(i32)
43
44; MODULEWITHLOOP: IR Dump After LICMPass
45; MODULEWITHLOOP: ModuleID =
46; MODULEWITHLOOP: define void @foo
47; MODULEWITHLOOP-NOT: Preheader:
48; MODULEWITHLOOP-NOT: Loop:
49; MODULEWITHLOOP-NOT: Exit blocks
50; MODULEWITHLOOP: define void @bar
51; MODULEWITHLOOP: declare void @baz(i32)
52
53define void @foo(i32 %n) {
54entry:
55  br label %loop_cond
56
57loop_cond:
58  %i = phi i32 [ 0, %entry ], [ %i_next, %loop_body ]
59  %cmp = icmp slt i32 %i, %n
60  br i1 %cmp, label %loop_body, label %loop_end
61
62loop_body:
63  call void @baz(i32 %i)
64  %i_next = add i32 %i, 1
65  br label %loop_cond
66
67loop_end:
68  ret void
69}
70
71define void @bar() {
72  ret void
73}
74
75declare void @baz(i32)
76