1 ; RUN: opt -rewrite-statepoints-for-gc -S < %s | FileCheck %s
2 ; RUN: opt -passes=rewrite-statepoints-for-gc -S < %s | FileCheck %s
4 ; A null test of a single value
6 define i1 @test(i8 addrspace(1)* %p, i1 %rare) gc "statepoint-example" {
9 %cond = icmp eq i8 addrspace(1)* %p, null
10 br i1 %rare, label %safepoint, label %continue, !prof !0
12 safepoint: ; preds = %entry
13 call void @safepoint() [ "deopt"() ]
16 continue: ; preds = %safepoint, %entry
17 ; CHECK-LABEL: continue:
19 ; CHECK-DAG: [ %p.relocated, %safepoint ]
20 ; CHECK-DAG: [ %p, %entry ]
23 ; Comparing two pointers
24 br i1 %cond, label %taken, label %untaken
26 taken: ; preds = %continue
29 untaken: ; preds = %continue
33 define i1 @test2(i8 addrspace(1)* %p, i8 addrspace(1)* %q, i1 %rare) gc "statepoint-example" {
36 %cond = icmp eq i8 addrspace(1)* %p, %q
37 br i1 %rare, label %safepoint, label %continue, !prof !0
39 safepoint: ; preds = %entry
40 call void @safepoint() [ "deopt"() ]
43 continue: ; preds = %safepoint, %entry
44 ; CHECK-LABEL: continue:
46 ; CHECK-DAG: [ %q.relocated, %safepoint ]
47 ; CHECK-DAG: [ %q, %entry ]
49 ; CHECK-DAG: [ %p.relocated, %safepoint ]
50 ; CHECK-DAG: [ %p, %entry ]
53 ; Sanity check that nothing bad happens if already last instruction
55 br i1 %cond, label %taken, label %untaken
57 taken: ; preds = %continue
60 untaken: ; preds = %continue
64 define i1 @test3(i8 addrspace(1)* %p, i8 addrspace(1)* %q, i1 %rare) gc "statepoint-example" {
66 ; CHECK: gc.statepoint
70 call void @safepoint() [ "deopt"() ]
71 %cond = icmp eq i8 addrspace(1)* %p, %q
72 br i1 %cond, label %taken, label %untaken
74 taken: ; preds = %entry
77 untaken: ; preds = %entry
81 declare void @safepoint()
82 !0 = !{!"branch_weights", i32 1, i32 10000}