• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -rewrite-statepoints-for-gc -S < %s | FileCheck %s
2
3; A null test of a single value
4
5define i1 @test(i8 addrspace(1)* %p, i1 %rare) gc "statepoint-example" {
6; CHECK-LABEL: @test
7entry:
8  %cond = icmp eq i8 addrspace(1)* %p, null
9  br i1 %rare, label %safepoint, label %continue, !prof !0
10
11safepoint:                                        ; preds = %entry
12  call void @safepoint() [ "deopt"() ]
13  br label %continue
14
15continue:                                         ; preds = %safepoint, %entry
16; CHECK-LABEL: continue:
17; CHECK: phi
18; CHECK-DAG: [ %p.relocated, %safepoint ]
19; CHECK-DAG: [ %p, %entry ]
20; CHECK: %cond = icmp
21; CHECK: br i1 %cond
22; Comparing two pointers
23  br i1 %cond, label %taken, label %untaken
24
25taken:                                            ; preds = %continue
26  ret i1 true
27
28untaken:                                          ; preds = %continue
29  ret i1 false
30}
31
32define i1 @test2(i8 addrspace(1)* %p, i8 addrspace(1)* %q, i1 %rare) gc "statepoint-example" {
33; CHECK-LABEL: @test2
34entry:
35  %cond = icmp eq i8 addrspace(1)* %p, %q
36  br i1 %rare, label %safepoint, label %continue, !prof !0
37
38safepoint:                                        ; preds = %entry
39  call void @safepoint() [ "deopt"() ]
40  br label %continue
41
42continue:                                         ; preds = %safepoint, %entry
43; CHECK-LABEL: continue:
44; CHECK: phi
45; CHECK-DAG: [ %q.relocated, %safepoint ]
46; CHECK-DAG: [ %q, %entry ]
47; CHECK: phi
48; CHECK-DAG: [ %p.relocated, %safepoint ]
49; CHECK-DAG: [ %p, %entry ]
50; CHECK: %cond = icmp
51; CHECK: br i1 %cond
52; Sanity check that nothing bad happens if already last instruction
53; before terminator
54  br i1 %cond, label %taken, label %untaken
55
56taken:                                            ; preds = %continue
57  ret i1 true
58
59untaken:                                          ; preds = %continue
60  ret i1 false
61}
62
63define i1 @test3(i8 addrspace(1)* %p, i8 addrspace(1)* %q, i1 %rare) gc "statepoint-example" {
64; CHECK-LABEL: @test3
65; CHECK: gc.statepoint
66; CHECK: %cond = icmp
67; CHECK: br i1 %cond
68entry:
69  call void @safepoint() [ "deopt"() ]
70  %cond = icmp eq i8 addrspace(1)* %p, %q
71  br i1 %cond, label %taken, label %untaken
72
73taken:                                            ; preds = %entry
74  ret i1 true
75
76untaken:                                          ; preds = %entry
77  ret i1 false
78}
79
80declare void @safepoint()
81!0 = !{!"branch_weights", i32 1, i32 10000}
82