1 ; RUN: opt < %s -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s
3 declare ptr @"personality_function"() #1
6 declare void @llvm.experimental.deoptimize.isVoid(...)
7 declare void @cold() cold
9 ; Even though the likeliness of 'invoke' to throw an exception is assessed as low
10 ; all other paths are even less likely. Check that hot paths leads to excepion handler.
11 define void @test1(i32 %0, i1 %arg) personality ptr @"personality_function" !prof !1 {
12 ;CHECK: edge %entry -> %unreached probability is 0x00000001 / 0x80000000 = 0.00%
13 ;CHECK: edge %entry -> %invoke probability is 0x7fffffff / 0x80000000 = 100.00% [HOT edge]
14 ;CHECK: edge %invoke -> %invoke.cont.unreached probability is 0x00000000 / 0x80000000 = 0.00%
15 ;CHECK: edge %invoke -> %land.pad probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
16 ;CHECK: edge %land.pad -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
19 br i1 %arg, label %unreached, label %invoke, !prof !2
21 invoke void @foo(i32 %0)
22 to label %invoke.cont.unreached unwind label %land.pad
23 invoke.cont.unreached:
24 call void (...) @llvm.experimental.deoptimize.isVoid(i32 10) [ "deopt"() ]
31 %v20 = landingpad { ptr, i32 }
33 %v21 = load ptr addrspace(1), ptr addrspace(256) inttoptr (i64 8 to ptr addrspace(256)), align 8
41 define void @test2(i32 %0, i1 %arg) personality ptr @"personality_function" {
42 ;CHECK: edge %entry -> %unreached probability is 0x00000000 / 0x80000000 = 0.00%
43 ;CHECK: edge %entry -> %invoke probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
44 ;CHECK: edge %invoke -> %invoke.cont.cold probability is 0x7fff8000 / 0x80000000 = 100.00% [HOT edge]
45 ;CHECK: edge %invoke -> %land.pad probability is 0x00008000 / 0x80000000 = 0.00%
46 ;CHECK: edge %land.pad -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
49 br i1 %arg, label %unreached, label %invoke
51 invoke void @foo(i32 %0)
52 to label %invoke.cont.cold unwind label %land.pad
61 %v20 = landingpad { ptr, i32 }
63 %v21 = load ptr addrspace(1), ptr addrspace(256) inttoptr (i64 8 to ptr addrspace(256)), align 8
71 define void @test3(i32 %0, i1 %arg) personality ptr @"personality_function" {
72 ;CHECK: edge %entry -> %unreached probability is 0x00000000 / 0x80000000 = 0.00%
73 ;CHECK: edge %entry -> %invoke probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
74 ;CHECK: edge %invoke -> %invoke.cont.cold probability is 0x7fff8000 / 0x80000000 = 100.00% [HOT edge]
75 ;CHECK: edge %invoke -> %land.pad probability is 0x00008000 / 0x80000000 = 0.00%
76 ;CHECK: edge %land.pad -> %exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
78 br i1 %arg, label %unreached, label %invoke
80 invoke void @foo(i32 %0)
81 to label %invoke.cont.cold unwind label %land.pad
90 %v20 = landingpad { ptr, i32 }
92 %v21 = load ptr addrspace(1), ptr addrspace(256) inttoptr (i64 8 to ptr addrspace(256)), align 8
102 attributes #1 = { nounwind }
104 !1 = !{!"function_entry_count", i64 32768}
105 !2 = !{!"branch_weights", i32 1, i32 983040}