forked from banach-space/llvm-tutor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDuplicateBB_switch.ll
83 lines (62 loc) · 2.26 KB
/
DuplicateBB_switch.ll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
; RUN: opt -load %shlibdir/libRIV%shlibext -load %shlibdir/libDuplicateBB%shlibext -legacy-duplicate-bb -S %s | FileCheck %s
; RUN: opt -load-pass-plugin %shlibdir/libRIV%shlibext -load-pass-plugin %shlibdir/libDuplicateBB%shlibext -passes=duplicate-bb -S %s | FileCheck %s
; Below is a rather simple function with one switch statement. This test
; verifies that the output from DuplicateBB is correct. As expected, for every
; BasicBlock 4 new BasicBlocks are created. The switch instruction is not
; duplicated - it's a terminator instruction, so that's expected.
define i32 @foo(i32) {
switch i32 %0, label %3 [
i32 1, label %2
]
; <label>:2:
br label %4
; <label>:3:
br label %4
; <label>:4:
%5 = phi i32 [ 20, %3 ], [ 10, %2 ]
ret i32 %5
}
; CHECK-LABEL: foo
; Entry block
; CHECK-NEXT: lt-if-then-else-0:
; CHECK-NEXT: %1 = icmp eq i32 %0, 0
; CHECK-NEXT: br i1 %1, label %lt-clone-1-0, label %lt-clone-2-0
; CHECK-LABEL:lt-clone-1-0:
; CHECK-NEXT: br label %lt-tail-0
; CHECK-LABEL:lt-clone-2-0:
; CHECK-NEXT: br label %lt-tail-0
; CHECK-LABEL:lt-tail-0:
; CHECK-NEXT: switch i32 %0, label %lt-if-then-else-2 [
; CHECK-NEXT: i32 1, label %lt-if-then-else-1
; CHECK-NEXT: ]
; <label>:2:
; CHECK-LABEL: lt-if-then-else-1:
; CHECK-NEXT: %2 = icmp eq i32 %0, 0
; CHECK-NEXT: br i1 %2, label %lt-clone-1-1, label %lt-clone-2-1
; CHECK-LABEL:lt-clone-1-1:
; CHECK-NEXT: br label %lt-tail-1
; CHECK-LABEL:lt-clone-2-1:
; CHECK-NEXT: br label %lt-tail-1
; CHECK-LABEL:lt-tail-1:
; CHECK-NEXT: br label %lt-if-then-else-3
; <label>:3:
; CHECK-LABEL: lt-if-then-else-2:
; CHECK-NEXT: %3 = icmp eq i32 %0, 0
; CHECK-NEXT: br i1 %3, label %lt-clone-1-2, label %lt-clone-2-2
; CHECK-LABEL:lt-clone-1-2:
; CHECK-NEXT: br label %lt-tail-2
; CHECK-LABEL:lt-clone-2-2:
; CHECK-NEXT: br label %lt-tail-2
; CHECK-LABEL:lt-tail-2:
; CHECK-NEXT: br label %lt-if-then-else-3
; <label>:4:
; CHECK-LABEL: lt-if-then-else-3:
; CHECK-NEXT: %4 = phi i32 [ 20, %lt-tail-2 ], [ 10, %lt-tail-1 ]
; CHECK-NEXT: %5 = icmp eq i32 %0, 0
; CHECK-NEXT: br i1 %5, label %lt-clone-1-3, label %lt-clone-2-3
; CHECK-LABEL:lt-clone-1-3:
; CHECK-NEXT: br label %lt-tail-3
; CHECK-LABEL:lt-clone-2-3:
; CHECK-NEXT: br label %lt-tail-3
; CHECK-LABEL:lt-tail-3:
; CHECK-NEXT: ret i32 %4