about summary refs log tree commit diff homepage
path: root/test/regression/2008-02-11-phi-nodes-after-invoke.ll
blob: f6077f25df10e2f5b3ae32e97fc7c30c4ff1e968 (plain) (blame)
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
; RUN: llvm-as -f %s -o - | %klee --no-output --exit-on-error

declare void @klee_abort()

define i32 @foo(i32 %val, i32 %fail) {
        %code = icmp ne i32 0, %fail
        br i1 %code, label %failing, label %return
failing:   
        unwind        
return:        
	ret i32 %val
}

define void @test(i32 %should_fail) {
entry:  
	%res0 = invoke i32 (i32, i32)* @foo(i32 0, i32 %should_fail) 
                        to label %check_phi unwind label %error
        
error:
        %res1 = zext i8 1 to i32
        br label %check_phi

check_phi:
        %val = phi i32 [%never_used, %never_used_label], [%res0, %entry], [%res1, %error]
        %ok = icmp eq i32 %val, %should_fail
        br i1 %ok, label %exit, label %on_error
        call void @klee_abort()
        unreachable

on_error:
        call void @klee_abort()
        unreachable
            
exit:
	ret void

        ;; this is so we hopefully fail if incomingBBIndex isn't set properly
never_used_label:       
        %never_used = zext i8 undef to i32
        br label %check_phi
}

define i32 @main() {
        call void (i32)* @test(i32 0)
        call void (i32)* @test(i32 1)
	ret i32 0
}