llvm.org GIT mirror llvm / 194a874
[RS4GC] Add some missing tests and CHECK: lines I missed porting these in rL259129. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@259203 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjoy Das 3 years ago
2 changed file(s) with 165 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
4848 %res = load i8, i8 addrspace(1)* @G, align 1
4949 ret i8 %res
5050 }
51
52 ; Even for source languages without constant references, we can
53 ; see constants can show up along paths where the value is dead.
54 ; This is particular relevant when computing bases of PHIs.
55 define i8 addrspace(1)* @test4(i8 addrspace(1)* %p) gc "statepoint-example" {
56 ; CHECK-LABEL: @test4
57 entry:
58 %is_null = icmp eq i8 addrspace(1)* %p, null
59 br i1 %is_null, label %split, label %join
60
61 split:
62 call void @foo()
63 %arg_value_addr.i = getelementptr inbounds i8, i8 addrspace(1)* %p, i64 8
64 %arg_value_addr_casted.i = bitcast i8 addrspace(1)* %arg_value_addr.i to i8 addrspace(1)* addrspace(1)*
65 br label %join
66
67 join:
68 ; CHECK-LABEL: join
69 ; CHECK: %addr2.base =
70 %addr2 = phi i8 addrspace(1)* addrspace(1)* [ %arg_value_addr_casted.i, %split ], [ inttoptr (i64 8 to i8 addrspace(1)* addrspace(1)*), %entry ]
71 ;; NOTE: This particular example can be jump-threaded, but in general,
72 ;; we can't, and have to deal with the resulting IR.
73 br i1 %is_null, label %early-exit, label %use
74
75 early-exit:
76 ret i8 addrspace(1)* null
77
78 use:
79 ; CHECK-LABEL: use:
80 ; CHECK: gc.statepoint
81 ; CHECK: gc.relocate
82 call void @foo()
83 %res = load i8 addrspace(1)*, i8 addrspace(1)* addrspace(1)* %addr2, align 1
84 ret i8 addrspace(1)* %res
85 }
86
87 ; Globals don't move and thus don't get relocated
88 define i8 addrspace(1)* @test5(i1 %always_true) gc "statepoint-example" {
89 ; CHECK-LABEL: @test5
90 ; CHECK: gc.statepoint
91 ; CHECK-NEXT: %res = extractelement <2 x i8 addrspace(1)*> , i32 0
92 entry:
93 call void @foo()
94 %res = extractelement <2 x i8 addrspace(1)*> , i32 0
95 ret i8 addrspace(1)* %res
96 }
1010 ; CHECK-LABEL: test_gep_const
1111 entry:
1212 %ptr = getelementptr i32, i32 addrspace(1)* %base, i32 15
13 call void @do_safepoint() [ "deopt"() ]
13 ; CHECK: getelementptr i32, i32 addrspace(1)* %base, i32 15
14 call void @do_safepoint() [ "deopt"() ]
15 ; CHECK: %base.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %statepoint_token, i32 7, i32 7)
16 ; CHECK: bitcast i8 addrspace(1)* %base.relocated to i32 addrspace(1)*
17 ; CHECK: getelementptr i32, i32 addrspace(1)* %base.relocated.casted, i32 15
1418 call void @use_obj32(i32 addrspace(1)* %base)
1519 call void @use_obj32(i32 addrspace(1)* %ptr)
1620 ret void
2024 ; CHECK-LABEL: test_gep_idx
2125 entry:
2226 %ptr = getelementptr i32, i32 addrspace(1)* %base, i32 %idx
23 call void @do_safepoint() [ "deopt"() ]
27 ; CHECK: getelementptr
28 call void @do_safepoint() [ "deopt"() ]
29 ; CHECK: %base.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %statepoint_token, i32 7, i32 7)
30 ; CHECK: %base.relocated.casted = bitcast i8 addrspace(1)* %base.relocated to i32 addrspace(1)*
31 ; CHECK: getelementptr i32, i32 addrspace(1)* %base.relocated.casted, i32 %idx
2432 call void @use_obj32(i32 addrspace(1)* %base)
2533 call void @use_obj32(i32 addrspace(1)* %ptr)
2634 ret void
3038 ; CHECK-LABEL: test_bitcast
3139 entry:
3240 %ptr = bitcast i32 addrspace(1)* %base to i64 addrspace(1)*
33 call void @do_safepoint() [ "deopt"() ]
41 ; CHECK: bitcast i32 addrspace(1)* %base to i64 addrspace(1)*
42 call void @do_safepoint() [ "deopt"() ]
43 ; CHECK: %base.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %statepoint_token, i32 7, i32 7)
44 ; CHECK: %base.relocated.casted = bitcast i8 addrspace(1)* %base.relocated to i32 addrspace(1)*
45 ; CHECK: bitcast i32 addrspace(1)* %base.relocated.casted to i64 addrspace(1)*
3446 call void @use_obj32(i32 addrspace(1)* %base)
3547 call void @use_obj64(i64 addrspace(1)* %ptr)
48 ret void
49 }
50
51 define void @test_bitcast_bitcast(i32 addrspace(1)* %base) gc "statepoint-example" {
52 ; CHECK-LABEL: test_bitcast_bitcast
53 entry:
54 %ptr1 = bitcast i32 addrspace(1)* %base to i64 addrspace(1)*
55 %ptr2 = bitcast i64 addrspace(1)* %ptr1 to i16 addrspace(1)*
56 ; CHECK: bitcast i32 addrspace(1)* %base to i64 addrspace(1)*
57 ; CHECK: bitcast i64 addrspace(1)* %ptr1 to i16 addrspace(1)*
58 call void @do_safepoint() [ "deopt"() ]
59
60 ; CHECK: %base.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %statepoint_token, i32 7, i32 7)
61 ; CHECK: %base.relocated.casted = bitcast i8 addrspace(1)* %base.relocated to i32 addrspace(1)*
62 ; CHECK: bitcast i32 addrspace(1)* %base.relocated.casted to i64 addrspace(1)*
63 ; CHECK: bitcast i64 addrspace(1)* %ptr1.remat to i16 addrspace(1)*
64 call void @use_obj32(i32 addrspace(1)* %base)
65 call void @use_obj16(i16 addrspace(1)* %ptr2)
66 ret void
67 }
68
69 define void @test_addrspacecast_addrspacecast(i32 addrspace(1)* %base) gc "statepoint-example" {
70 ; CHECK-LABEL: test_addrspacecast_addrspacecast
71 entry:
72 %ptr1 = addrspacecast i32 addrspace(1)* %base to i32*
73 %ptr2 = addrspacecast i32* %ptr1 to i32 addrspace(1)*
74 ; CHECK: addrspacecast i32 addrspace(1)* %base to i32*
75 ; CHECK: addrspacecast i32* %ptr1 to i32 addrspace(1)*
76 call void @do_safepoint() [ "deopt"() ]
77
78 ; CHECK: %base.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %statepoint_token, i32 7, i32 7)
79 ; CHECK: %base.relocated.casted = bitcast i8 addrspace(1)* %base.relocated to i32 addrspace(1)*
80 ; CHECK: %ptr2.relocated = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %statepoint_token, i32 7, i32 8)
81 ; CHECK: %ptr2.relocated.casted = bitcast i8 addrspace(1)* %ptr2.relocated to i32 addrspace(1)*
82 call void @use_obj32(i32 addrspace(1)* %base)
83 call void @use_obj32(i32 addrspace(1)* %ptr2)
3684 ret void
3785 }
3886
4088 ; CHECK-LABEL: test_bitcast_gep
4189 entry:
4290 %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
91 ; CHECK: getelementptr
92 ; CHECK: bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)*
4393 %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)*
4494 call void @do_safepoint() [ "deopt"() ]
95
96 ; CHECK: gc.relocate
97 ; CHECK: bitcast
98 ; CHECK: getelementptr
99 ; CHECK: bitcast
45100 call void @use_obj32(i32 addrspace(1)* %base)
46101 call void @use_obj64(i64 addrspace(1)* %ptr.cast)
47102 ret void
51106 ; CHECK-LABEL: test_intersecting_chains
52107 entry:
53108 %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
109 ; CHECK: getelementptr
54110 %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)*
111 ; CHECK: bitcast
55112 %ptr.cast2 = bitcast i32 addrspace(1)* %ptr.gep to i16 addrspace(1)*
56 call void @do_safepoint() [ "deopt"() ]
113 ; CHECK: bitcast
114 call void @do_safepoint() [ "deopt"() ]
115
116 ; CHECK: getelementptr
117 ; CHECK: bitcast
118 ; CHECK: getelementptr
119 ; CHECK: bitcast
57120 call void @use_obj64(i64 addrspace(1)* %ptr.cast)
58121 call void @use_obj16(i16 addrspace(1)* %ptr.cast2)
59122 ret void
63126 ; CHECK-LABEL: test_cost_threshold
64127 entry:
65128 %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
129 ; CHECK: getelementptr
66130 %ptr.gep2 = getelementptr i32, i32 addrspace(1)* %ptr.gep, i32 %idx1
131 ; CHECK: getelementptr
67132 %ptr.gep3 = getelementptr i32, i32 addrspace(1)* %ptr.gep2, i32 %idx2
133 ; CHECK: getelementptr
68134 %ptr.gep4 = getelementptr i32, i32 addrspace(1)* %ptr.gep3, i32 %idx3
135 ; CHECK: getelementptr
69136 %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep4 to i64 addrspace(1)*
70137 call void @do_safepoint() [ "deopt"() ]
138
139 ; CHECK: gc.relocate
140 ; CHECK: bitcast
141 ; CHECK: gc.relocate
142 ; CHECK: bitcast
71143 call void @use_obj64(i64 addrspace(1)* %ptr.cast)
72144 ret void
73145 }
77149 entry:
78150 %ptr = getelementptr i32, i32 addrspace(1)* %base, i32 15
79151 %ptr2 = getelementptr i32, i32 addrspace(1)* %base, i32 12
80 call void @do_safepoint() [ "deopt"() ]
152 ; CHECK: getelementptr
153 ; CHECK: getelementptr
154 call void @do_safepoint() [ "deopt"() ]
155
156 ; CHECK: gc.relocate
157 ; CHECK: bitcast
158 ; CHECK: getelementptr
159 ; CHECK: getelementptr
81160 call void @use_obj32(i32 addrspace(1)* %ptr)
82161 call void @use_obj32(i32 addrspace(1)* %ptr2)
83162 ret void
87166 ; CHECK-LABEL: test_gep_smallint_array
88167 entry:
89168 %ptr = getelementptr [3 x i32], [3 x i32] addrspace(1)* %base, i32 0, i32 2
90 call void @do_safepoint() [ "deopt"() ]
169 ; CHECK: getelementptr
170 call void @do_safepoint() [ "deopt"() ]
171
172 ; CHECK: gc.relocate
173 ; CHECK: bitcast
174 ; CHECK: getelementptr
91175 call void @use_obj32(i32 addrspace(1)* %ptr)
92176 ret void
93177 }
98182 ; CHECK-LABEL: test_invoke
99183 entry:
100184 %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
185 ; CHECK: getelementptr
101186 %ptr.cast = bitcast i32 addrspace(1)* %ptr.gep to i64 addrspace(1)*
187 ; CHECK: bitcast
102188 %ptr.cast2 = bitcast i32 addrspace(1)* %ptr.gep to i16 addrspace(1)*
189 ; CHECK: bitcast
103190 invoke void @do_safepoint() [ "deopt"() ]
104191 to label %normal unwind label %exception
105192
106 normal: ; preds = %entry
193 normal:
194 ; CHECK: normal:
195 ; CHECK: gc.relocate
196 ; CHECK: bitcast
197 ; CHECK: getelementptr
198 ; CHECK: bitcast
199 ; CHECK: getelementptr
200 ; CHECK: bitcast
107201 call void @use_obj64(i64 addrspace(1)* %ptr.cast)
108202 call void @use_obj16(i16 addrspace(1)* %ptr.cast2)
109203 ret void
110204
111 exception: ; preds = %entry
205 exception:
206 ; CHECK: exception:
112207 %landing_pad4 = landingpad token
113208 cleanup
209 ; CHECK: gc.relocate
210 ; CHECK: bitcast
211 ; CHECK: getelementptr
212 ; CHECK: bitcast
213 ; CHECK: getelementptr
214 ; CHECK: bitcast
114215 call void @use_obj64(i64 addrspace(1)* %ptr.cast)
115216 call void @use_obj16(i16 addrspace(1)* %ptr.cast2)
116217 ret void
120221 ; CHECK-LABEL: test_loop
121222 entry:
122223 %ptr.gep = getelementptr i32, i32 addrspace(1)* %base, i32 15
224 ; CHECK: getelementptr
123225 br label %loop
124226
125227 loop: ; preds = %loop, %entry
228 ; CHECK: phi i32 addrspace(1)* [ %ptr.gep, %entry ], [ %ptr.gep.remat, %loop ]
229 ; CHECK: phi i32 addrspace(1)* [ %base, %entry ], [ %base.relocated.casted, %loop ]
126230 call void @use_obj32(i32 addrspace(1)* %ptr.gep)
127231 call void @do_safepoint() [ "deopt"() ]
232 ; CHECK: gc.relocate
233 ; CHECK: bitcast
234 ; CHECK: getelementptr
128235 br label %loop
129236 }
130237
144251 %ptr.gep10 = getelementptr i32, i32 addrspace(1)* %ptr.gep9, i32 15
145252 %ptr.gep11 = getelementptr i32, i32 addrspace(1)* %ptr.gep10, i32 15
146253 call void @do_safepoint() [ "deopt"() ]
254 ; CHECK: gc.relocate
255 ; CHECK: bitcast
256 ; CHECK: gc.relocate
257 ; CHECK: bitcast
147258 call void @use_obj32(i32 addrspace(1)* %ptr.gep11)
148259 ret void
149260 }