1
1
; RUN: opt < %s -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s
2
2
3
- define i32 @test1 (i32 %i , i32* %a ) {
3
+ define i32 @test1 (i32 %i , ptr %a ) {
4
4
; CHECK: Printing analysis {{.*}} for function 'test1'
5
5
entry:
6
6
br label %body
9
9
body:
10
10
%iv = phi i32 [ 0 , %entry ], [ %next , %body ]
11
11
%base = phi i32 [ 0 , %entry ], [ %sum , %body ]
12
- %arrayidx = getelementptr inbounds i32 , i32* %a , i32 %iv
13
- %0 = load i32 , i32* %arrayidx
12
+ %arrayidx = getelementptr inbounds i32 , ptr %a , i32 %iv
13
+ %0 = load i32 , ptr %arrayidx
14
14
%sum = add nsw i32 %0 , %base
15
15
%next = add i32 %iv , 1
16
16
%exitcond = icmp eq i32 %next , %i
@@ -197,7 +197,7 @@ exit:
197
197
198
198
!3 = !{!"branch_weights" , i32 100 , i32 1 }
199
199
200
- define i32 @test_cold_call_sites (i32* %a ) {
200
+ define i32 @test_cold_call_sites (ptr %a ) {
201
201
; Test that edges to blocks post-dominated by cold call sites
202
202
; are marked as not expected to be taken.
203
203
; TODO(dnovillo) The calls to regular_function should not be merged, but
@@ -209,8 +209,8 @@ define i32 @test_cold_call_sites(i32* %a) {
209
209
; CHECK: edge entry -> else probability is 0x78787f1d / 0x80000000 = 94.12% [HOT edge]
210
210
211
211
entry:
212
- %gep1 = getelementptr i32 , i32* %a , i32 1
213
- %val1 = load i32 , i32* %gep1
212
+ %gep1 = getelementptr i32 , ptr %a , i32 1
213
+ %val1 = load i32 , ptr %gep1
214
214
%cond1 = icmp ugt i32 %val1 , 1
215
215
br i1 %cond1 , label %then , label %else
216
216
@@ -220,8 +220,8 @@ then:
220
220
br label %exit
221
221
222
222
else:
223
- %gep2 = getelementptr i32 , i32* %a , i32 2
224
- %val2 = load i32 , i32* %gep2
223
+ %gep2 = getelementptr i32 , ptr %a , i32 2
224
+ %val2 = load i32 , ptr %gep2
225
225
%val3 = call i32 @regular_function (i32 %val2 )
226
226
br label %exit
227
227
@@ -231,7 +231,7 @@ exit:
231
231
}
232
232
233
233
; CHECK-LABEL: test_invoke_code_callsite1
234
- define i32 @test_invoke_code_callsite1 (i1 %c ) personality i8* bitcast ( i32 (...)* @__gxx_personality_v0 to i8* ) {
234
+ define i32 @test_invoke_code_callsite1 (i1 %c ) personality ptr @__gxx_personality_v0 {
235
235
entry:
236
236
br i1 %c , label %if.then , label %if.end
237
237
; Edge "entry->if.end" should have higher probability based on the cold call
@@ -251,7 +251,7 @@ invoke.cont:
251
251
br label %if.end
252
252
253
253
lpad:
254
- %ll = landingpad { i8* , i32 }
254
+ %ll = landingpad { ptr , i32 }
255
255
cleanup
256
256
br label %if.end
257
257
@@ -260,7 +260,7 @@ if.end:
260
260
}
261
261
262
262
; CHECK-LABEL: test_invoke_code_callsite2
263
- define i32 @test_invoke_code_callsite2 (i1 %c ) personality i8* bitcast ( i32 (...)* @__gxx_personality_v0 to i8* ) {
263
+ define i32 @test_invoke_code_callsite2 (i1 %c ) personality ptr @__gxx_personality_v0 {
264
264
entry:
265
265
br i1 %c , label %if.then , label %if.end
266
266
@@ -277,7 +277,7 @@ invoke.cont:
277
277
br label %if.end
278
278
279
279
lpad:
280
- %ll = landingpad { i8* , i32 }
280
+ %ll = landingpad { ptr , i32 }
281
281
cleanup
282
282
call void @ColdFunc () #0
283
283
br label %if.end
@@ -287,7 +287,7 @@ if.end:
287
287
}
288
288
289
289
; CHECK-LABEL: test_invoke_code_callsite3
290
- define i32 @test_invoke_code_callsite3 (i1 %c ) personality i8* bitcast ( i32 (...)* @__gxx_personality_v0 to i8* ) {
290
+ define i32 @test_invoke_code_callsite3 (i1 %c ) personality ptr @__gxx_personality_v0 {
291
291
entry:
292
292
br i1 %c , label %if.then , label %if.end
293
293
; CHECK: edge entry -> if.then probability is 0x078780e3 / 0x80000000 = 5.88%
@@ -306,7 +306,7 @@ invoke.cont:
306
306
br label %if.end
307
307
308
308
lpad:
309
- %ll = landingpad { i8* , i32 }
309
+ %ll = landingpad { ptr , i32 }
310
310
cleanup
311
311
call void @ColdFunc () #0
312
312
br label %if.end
@@ -316,7 +316,7 @@ if.end:
316
316
}
317
317
318
318
; CHECK-LABEL: test_invoke_code_profiled
319
- define void @test_invoke_code_profiled (i1 %c ) personality i8* bitcast ( i32 (...)* @__gxx_personality_v0 to i8* ) {
319
+ define void @test_invoke_code_profiled (i1 %c ) personality ptr @__gxx_personality_v0 {
320
320
entry:
321
321
; CHECK: edge entry -> invoke.to0 probability is 0x7ffff800 / 0x80000000 = 100.00% [HOT edge]
322
322
; CHECK: edge entry -> lpad probability is 0x00000800 / 0x80000000 = 0.00%
@@ -339,7 +339,7 @@ invoke.to2:
339
339
ret void
340
340
341
341
lpad:
342
- %ll = landingpad { i8* , i32 }
342
+ %ll = landingpad { ptr , i32 }
343
343
cleanup
344
344
ret void
345
345
}
0 commit comments