1 ; RUN: opt -passes=rewrite-statepoints-for-gc -S < %s | FileCheck %s
3 ; A null test of a single value
5 define i1 @test(ptr addrspace(1) %p, i1 %rare) gc "statepoint-example" {
8 %cond = icmp eq ptr addrspace(1) %p, null
9 br i1 %rare, label %safepoint, label %continue, !prof !0
11 safepoint: ; preds = %entry
12 call void @safepoint() [ "deopt"() ]
15 continue: ; preds = %safepoint, %entry
16 ; CHECK-LABEL: continue:
18 ; CHECK-DAG: [ %p.relocated, %safepoint ]
19 ; CHECK-DAG: [ %p, %entry ]
22 ; Comparing two pointers
23 br i1 %cond, label %taken, label %untaken
25 taken: ; preds = %continue
28 untaken: ; preds = %continue
32 define i1 @test2(ptr addrspace(1) %p, ptr addrspace(1) %q, i1 %rare) gc "statepoint-example" {
35 %cond = icmp eq ptr addrspace(1) %p, %q
36 br i1 %rare, label %safepoint, label %continue, !prof !0
38 safepoint: ; preds = %entry
39 call void @safepoint() [ "deopt"() ]
42 continue: ; preds = %safepoint, %entry
43 ; CHECK-LABEL: continue:
45 ; CHECK-DAG: [ %q.relocated, %safepoint ]
46 ; CHECK-DAG: [ %q, %entry ]
48 ; CHECK-DAG: [ %p.relocated, %safepoint ]
49 ; CHECK-DAG: [ %p, %entry ]
52 ; Check that nothing bad happens if already last instruction
54 br i1 %cond, label %taken, label %untaken
56 taken: ; preds = %continue
59 untaken: ; preds = %continue
63 define i1 @test3(ptr addrspace(1) %p, ptr addrspace(1) %q, i1 %rare) gc "statepoint-example" {
65 ; CHECK: gc.statepoint
69 call void @safepoint() [ "deopt"() ]
70 %cond = icmp eq ptr addrspace(1) %p, %q
71 br i1 %cond, label %taken, label %untaken
73 taken: ; preds = %entry
76 untaken: ; preds = %entry
80 declare void @safepoint()
81 !0 = !{!"branch_weights", i32 1, i32 10000}