llvm-project
69 строк · 1.9 Кб
1; This test checks -print-after/before on loop passes
2; Besides of the loop itself it should be dumping loop pre-header and exits.
3;
4; RUN: opt < %s 2>&1 -disable-output \
5; RUN: -passes='loop(loop-deletion)' -print-before=loop-deletion \
6; RUN: | FileCheck %s -check-prefix=DEL
7; RUN: opt < %s 2>&1 -disable-output \
8; RUN: -passes='require<opt-remark-emit>,loop(loop-unroll-full)' -print-after=loop-unroll-full -filter-print-funcs=bar \
9; RUN: | FileCheck %s -check-prefix=BAR
10; RUN: opt < %s 2>&1 -disable-output \
11; RUN: -passes='require<opt-remark-emit>,loop(loop-unroll-full)' -print-after=loop-unroll-full -filter-print-funcs=foo -print-module-scope \
12; RUN: | FileCheck %s -check-prefix=FOO-MODULE
13
14; DEL: IR Dump Before {{Delete dead loops|LoopDeletionPass}}
15; DEL: ; Preheader:
16; DEL-NEXT: %idx = alloca i32, align 4
17; DEL: ; Loop:
18; DEL-NEXT: loop:
19; DEL: cont:
20; DEL: ; Exit blocks
21; DEL: done:
22; DEL: IR Dump Before {{Delete dead loops|LoopDeletionPass}}
23; DEL: ; Preheader:
24; DEL-NEXT: br label %loop
25; DEL: ; Loop:
26; DEL-NEXT: loop:
27; DEL: ; Exit blocks
28; DEL: end:
29
30; BAR: IR Dump After {{Unroll|LoopFullUnrollPass}}
31; BAR: ; Preheader:
32; BAR-NEXT: br label %loop
33; BAR: ; Loop:
34; BAR-NEXT: loop:
35; BAR: ; Exit blocks
36; BAR: end:
37
38; FOO-MODULE: IR Dump After {{Unroll|LoopFullUnrollPass}} {{.*}}loop
39; FOO-MODULE-NEXT: ModuleID =
40; FOO-MODULE: define void @foo
41; FOO-MODULE: define void @bar
42
43define void @foo(){
44%idx = alloca i32, align 4
45store i32 0, ptr %idx, align 4
46br label %loop
47
48loop:
49%1 = load i32, ptr %idx, align 4
50%2 = icmp slt i32 %1, 10
51br i1 %2, label %cont, label %done
52
53cont:
54%3 = load i32, ptr %idx, align 4
55%4 = add nsw i32 %3, 1
56store i32 %4, ptr %idx, align 4
57br label %loop
58
59done:
60ret void
61}
62
63define void @bar(){
64br label %loop
65loop:
66br i1 1, label %loop, label %end
67end:
68ret void
69}
70