1 ; RUN: opt < %s -icp-lto -passes=pgo-icall-prom -S | FileCheck %s --check-prefix=ICP
2 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
3 target triple = "x86_64-unknown-linux-gnu"
5 @foo1 = global ptr null, align 8
6 @foo2 = global ptr null, align 8
7 @_ZTIi = external constant ptr
9 define internal void @_ZL4bar1v() !PGOFuncName !0 {
14 define internal i32 @_ZL4bar2v() !PGOFuncName !1 {
19 define i32 @_Z3goov() personality ptr @__gxx_personality_v0 {
21 %tmp = load ptr, ptr @foo1, align 8
22 ; ICP: [[CMP_IC1:%[0-9]+]] = icmp eq ptr %tmp, @_ZL4bar1v
23 ; ICP: br i1 [[CMP_IC1]], label %[[TRUE_LABEL_IC1:.*]], label %[[FALSE_LABEL_IC1:.*]], !prof [[BRANCH_WEIGHT:![0-9]+]]
24 ; ICP:[[TRUE_LABEL_IC1]]:
25 ; ICP: invoke void @_ZL4bar1v()
26 ; ICP: to label %[[DCALL_NORMAL_DEST_IC1:.*]] unwind label %lpad
27 ; ICP:[[FALSE_LABEL_IC1]]:
29 to label %try.cont unwind label %lpad, !prof !2
31 ; ICP:[[DCALL_NORMAL_DEST_IC1]]:
32 ; ICP: br label %try.cont
35 %tmp1 = landingpad { ptr, i32 }
37 %tmp2 = extractvalue { ptr, i32 } %tmp1, 0
38 %tmp3 = extractvalue { ptr, i32 } %tmp1, 1
39 %tmp4 = tail call i32 @llvm.eh.typeid.for(ptr @_ZTIi)
40 %matches = icmp eq i32 %tmp3, %tmp4
41 br i1 %matches, label %catch, label %eh.resume
44 %tmp5 = tail call ptr @__cxa_begin_catch(ptr %tmp2)
45 tail call void @__cxa_end_catch()
49 %tmp6 = load ptr, ptr @foo2, align 8
50 ; ICP: [[CMP_IC2:%[0-9]+]] = icmp eq ptr %tmp6, @_ZL4bar2v
51 ; ICP: br i1 [[CMP_IC2]], label %[[TRUE_LABEL_IC2:.*]], label %[[FALSE_LABEL_IC2:.*]], !prof [[BRANCH_WEIGHT:![0-9]+]]
52 ; ICP:[[TRUE_LABEL_IC2]]:
53 ; ICP: [[RESULT_IC2_0:%[0-9]+]] = invoke i32 @_ZL4bar2v()
54 ; ICP: to label %[[MERGE_BB:.*]] unwind label %lpad1
55 ; ICP:[[FALSE_LABEL_IC2]]:
56 ; ICP: [[RESULT_IC2_1:%.+]] = invoke i32 %tmp6()
57 ; ICP: to label %[[MERGE_BB]] unwind label %lpad1
58 %call = invoke i32 %tmp6()
59 to label %try.cont8 unwind label %lpad1, !prof !3
62 ; ICP: [[MERGE_PHI:%.+]] = phi i32 [ [[RESULT_IC2_1]], %[[FALSE_LABEL_IC2]] ], [ [[RESULT_IC2_0]], %[[TRUE_LABEL_IC2]] ]
63 ; ICP: br label %try.cont8
65 %tmp7 = landingpad { ptr, i32 }
67 %tmp8 = extractvalue { ptr, i32 } %tmp7, 0
68 %tmp9 = extractvalue { ptr, i32 } %tmp7, 1
69 %tmp10 = tail call i32 @llvm.eh.typeid.for(ptr @_ZTIi)
70 %matches5 = icmp eq i32 %tmp9, %tmp10
71 br i1 %matches5, label %catch6, label %eh.resume
74 %tmp11 = tail call ptr @__cxa_begin_catch(ptr %tmp8)
75 tail call void @__cxa_end_catch()
79 %i.0 = phi i32 [ undef, %catch6 ], [ %call, %try.cont ]
80 ; ICP: %i.0 = phi i32 [ undef, %catch6 ], [ [[MERGE_PHI]], %[[MERGE_BB]] ]
84 %ehselector.slot.0 = phi i32 [ %tmp9, %lpad1 ], [ %tmp3, %lpad ]
85 %exn.slot.0 = phi ptr [ %tmp8, %lpad1 ], [ %tmp2, %lpad ]
86 %lpad.val = insertvalue { ptr, i32 } undef, ptr %exn.slot.0, 0
87 %lpad.val11 = insertvalue { ptr, i32 } %lpad.val, i32 %ehselector.slot.0, 1
88 resume { ptr, i32 } %lpad.val11
91 declare i32 @__gxx_personality_v0(...)
93 declare i32 @llvm.eh.typeid.for(ptr)
95 declare ptr @__cxa_begin_catch(ptr)
97 declare void @__cxa_end_catch()
99 !0 = !{!"invoke.ll:_ZL4bar1v"}
100 !1 = !{!"invoke.ll:_ZL4bar2v"}
101 !2 = !{!"VP", i32 0, i64 1, i64 -2732222848796217051, i64 1}
102 !3 = !{!"VP", i32 0, i64 1, i64 -6116256810522035449, i64 1}
103 ; ICP-NOT: !3 = !{!"VP", i32 0, i64 1, i64 -2732222848796217051, i64 1}
104 ; ICP-NOT: !4 = !{!"VP", i32 0, i64 1, i64 -6116256810522035449, i64 1}
105 ; ICP: [[BRANCH_WEIGHT]] = !{!"branch_weights", i32 1, i32 0}