1 ; RUN: opt -rewrite-statepoints-for-gc -verify -S < %s | FileCheck %s
2 ; RUN: opt -passes=rewrite-statepoints-for-gc,verify -S < %s | FileCheck %s
4 declare i8 addrspace(1)* @gc_call()
6 declare i32* @fake_personality_function()
8 define i8 addrspace(1)* @test(i1 %c) gc "statepoint-example" personality i32* ()* @fake_personality_function {
11 br i1 %c, label %gc_invoke, label %normal_dest
14 ; CHECK: [[TOKEN:%[^ ]+]] = invoke token {{[^@]+}}@llvm.experimental.gc.statepoint{{[^@]+}}@gc_call
15 %obj = invoke i8 addrspace(1)* @gc_call() [ "deopt"(i32 0, i32 -1, i32 0, i32 0, i32 0) ]
16 to label %normal_dest unwind label %unwind_dest
20 %lpad = landingpad { i8*, i32 }
22 resume { i8*, i32 } undef
24 ; CHECK: [[NORMAL_DEST_SPLIT:[^:]+:]]
25 ; CHECK-NEXT: [[RET_VAL:%[^ ]+]] = call i8 addrspace(1)* @llvm.experimental.gc.result.p1i8(token [[TOKEN]])
26 ; CHECK-NEXT: br label %normal_dest
30 ; CHECK-NEXT: %merge = phi i8 addrspace(1)* [ null, %entry ], [ %obj2, %normal_dest1 ]
31 %merge = phi i8 addrspace(1)* [ null, %entry ], [ %obj, %gc_invoke ]
32 ret i8 addrspace(1)* %merge