llvm.org GIT mirror llvm / a0c5e6c
Add some tests checking that the verifier rejects cases where a definition doesn't dominate a use. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157829 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 8 years ago
1 changed file(s) with 57 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: not llvm-as < %s -o /dev/null |& FileCheck %s
1
2 define i32 @f1(i32 %x) {
3 %y = add i32 %z, 1
4 %z = add i32 %x, 1
5 ret i32 %y
6 ; CHECK: Instruction does not dominate all uses!
7 ; CHECK-NEXT: %z = add i32 %x, 1
8 ; CHECK-NEXT: %y = add i32 %z, 1
9 }
10
11 declare i32 @g()
12 define void @f2(i32 %x) {
13 bb0:
14 %y1 = invoke i32 @g() to label %bb1 unwind label %bb2
15 bb1:
16 ret void
17 bb2:
18 %y2 = phi i32 [%y1, %bb0]
19 %y3 = landingpad i32 personality i32 ()* @g
20 cleanup
21 ret void
22 ; CHECK: Invoke result not available in the unwind destination!
23 ; CHECK-NEXT: %y1 = invoke i32 @g()
24 ; CHECK-NEXT: to label %bb1 unwind label %bb2
25 ; CHECK-NEXT: %y2 = phi i32 [ %y1, %bb0 ]
26 }
27
28 define void @f3(i32 %x) {
29 bb0:
30 %y1 = invoke i32 @g() to label %bb1 unwind label %bb2
31 bb1:
32 ret void
33 bb2:
34 %y2 = landingpad i32 personality i32 ()* @g
35 cleanup
36 br label %bb3
37 bb3:
38 %y3 = phi i32 [%y1, %bb2]
39 ret void
40 ; CHECK: Invoke result does not dominate all uses!
41 ; CHECK-NEXT: %y1 = invoke i32 @g()
42 ; CHECK-NEXT: to label %bb1 unwind label %bb2
43 ; CHECK-NEXT: %y3 = phi i32 [ %y1, %bb2 ]
44 }
45
46 define void @f4(i32 %x) {
47 bb0:
48 br label %bb1
49 bb1:
50 %y3 = phi i32 [%y1, %bb0]
51 %y1 = add i32 %x, 1
52 ret void
53 ; CHECK: Instruction does not dominate all uses!
54 ; CHECK-NEXT: %y1 = add i32 %x, 1
55 ; CHECK-NEXT: %y3 = phi i32 [ %y1, %bb0 ]
56 }