1 ; RUN: opt -analyze -branch-prob < %s -enable-new-pm=0 | FileCheck %s
2 ; RUN: opt < %s -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s
4 declare i32* @"personality_function"() #1
7 declare void @llvm.experimental.deoptimize.isVoid(...)
8 declare void @cold() cold
10 ; Even though the likeliness of 'invoke' to throw an exception is assessed as low
11 ; all other paths are even less likely. Check that hot paths leads to excepion handler.
12 define void @test1(i32 %0) personality i32* ()* @"personality_function" !prof !1 {
13 ;CHECK: edge entry -> unreached probability is 0x00000001 / 0x80000000 = 0.00%
14 ;CHECK: edge entry -> invoke probability is 0x7fffffff / 0x80000000 = 100.00% [HOT edge]
15 ;CHECK: edge invoke -> invoke.cont.unreached probability is 0x00000000 / 0x80000000 = 0.00%
16 ;CHECK: edge invoke -> land.pad probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
17 ;CHECK: edge land.pad -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
20 br i1 undef, label %unreached, label %invoke, !prof !2
22 invoke void @foo(i32 %0)
23 to label %invoke.cont.unreached unwind label %land.pad
24 invoke.cont.unreached:
25 call void (...) @llvm.experimental.deoptimize.isVoid(i32 10) [ "deopt"() ]
32 %v20 = landingpad { i8*, i32 }
34 %v21 = load i8 addrspace(1)*, i8 addrspace(1)* addrspace(256)* inttoptr (i64 8 to i8 addrspace(1)* addrspace(256)*), align 8
42 define void @test2(i32 %0) personality i32* ()* @"personality_function" {
43 ;CHECK: edge entry -> unreached probability is 0x00000000 / 0x80000000 = 0.00%
44 ;CHECK: edge entry -> invoke probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
45 ;CHECK: edge invoke -> invoke.cont.cold probability is 0x7fff8000 / 0x80000000 = 100.00% [HOT edge]
46 ;CHECK: edge invoke -> land.pad probability is 0x00008000 / 0x80000000 = 0.00%
47 ;CHECK: edge land.pad -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
50 br i1 undef, label %unreached, label %invoke
52 invoke void @foo(i32 %0)
53 to label %invoke.cont.cold unwind label %land.pad
62 %v20 = landingpad { i8*, i32 }
64 %v21 = load i8 addrspace(1)*, i8 addrspace(1)* addrspace(256)* inttoptr (i64 8 to i8 addrspace(1)* addrspace(256)*), align 8
72 define void @test3(i32 %0) personality i32* ()* @"personality_function" {
73 ;CHECK: edge entry -> unreached probability is 0x00000000 / 0x80000000 = 0.00%
74 ;CHECK: edge entry -> invoke probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
75 ;CHECK: edge invoke -> invoke.cont.cold probability is 0x7fff8000 / 0x80000000 = 100.00% [HOT edge]
76 ;CHECK: edge invoke -> land.pad probability is 0x00008000 / 0x80000000 = 0.00%
77 ;CHECK: edge land.pad -> exit probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge]
79 br i1 undef, label %unreached, label %invoke
81 invoke void @foo(i32 %0)
82 to label %invoke.cont.cold unwind label %land.pad
91 %v20 = landingpad { i8*, i32 }
93 %v21 = load i8 addrspace(1)*, i8 addrspace(1)* addrspace(256)* inttoptr (i64 8 to i8 addrspace(1)* addrspace(256)*), align 8
103 attributes #1 = { nounwind }
105 !1 = !{!"function_entry_count", i64 32768}
106 !2 = !{!"branch_weights", i32 1, i32 983040}