• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -icp-lto -pgo-icall-prom -S -icp-count-threshold=0 | FileCheck %s --check-prefix=ICP
2; RUN: opt < %s -icp-lto -passes=pgo-icall-prom -S -icp-count-threshold=0 | FileCheck %s --check-prefix=ICP
3target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4target triple = "x86_64-unknown-linux-gnu"
5
6@foo1 = global void ()* null, align 8
7@foo2 = global i32 ()* null, align 8
8@_ZTIi = external constant i8*
9
10define internal void @_ZL4bar1v() !PGOFuncName !0 {
11entry:
12  ret void
13}
14
15define internal i32 @_ZL4bar2v() !PGOFuncName !1 {
16entry:
17  ret i32 100
18}
19
20define i32 @_Z3goov() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
21entry:
22  %tmp = load void ()*, void ()** @foo1, align 8
23; ICP:  [[BITCAST_IC1:%[0-9]+]] = bitcast void ()* %tmp to i8*
24; ICP:  [[CMP_IC1:%[0-9]+]] = icmp eq i8* [[BITCAST_IC1]], bitcast (void ()* @_ZL4bar1v to i8*)
25; ICP:  br i1 [[CMP_IC1]], label %[[TRUE_LABEL_IC1:.*]], label %[[FALSE_LABEL_IC1:.*]], !prof [[BRANCH_WEIGHT:![0-9]+]]
26; ICP:[[TRUE_LABEL_IC1]]:
27; ICP:  invoke void @_ZL4bar1v()
28; ICP:          to label %[[DCALL_NORMAL_DEST_IC1:.*]] unwind label %lpad
29; ICP:[[FALSE_LABEL_IC1]]:
30  invoke void %tmp()
31          to label %try.cont unwind label %lpad, !prof !2
32
33; ICP:[[DCALL_NORMAL_DEST_IC1]]:
34; ICP:  br label %try.cont
35
36lpad:
37  %tmp1 = landingpad { i8*, i32 }
38          catch i8* bitcast (i8** @_ZTIi to i8*)
39  %tmp2 = extractvalue { i8*, i32 } %tmp1, 0
40  %tmp3 = extractvalue { i8*, i32 } %tmp1, 1
41  %tmp4 = tail call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
42  %matches = icmp eq i32 %tmp3, %tmp4
43  br i1 %matches, label %catch, label %eh.resume
44
45catch:
46  %tmp5 = tail call i8* @__cxa_begin_catch(i8* %tmp2)
47  tail call void @__cxa_end_catch()
48  br label %try.cont
49
50try.cont:
51  %tmp6 = load i32 ()*, i32 ()** @foo2, align 8
52; ICP:  [[BITCAST_IC2:%[0-9]+]] = bitcast i32 ()* %tmp6 to i8*
53; ICP:  [[CMP_IC2:%[0-9]+]] = icmp eq i8* [[BITCAST_IC2]], bitcast (i32 ()* @_ZL4bar2v to i8*)
54; ICP:  br i1 [[CMP_IC2]], label %[[TRUE_LABEL_IC2:.*]], label %[[FALSE_LABEL_IC2:.*]], !prof [[BRANCH_WEIGHT:![0-9]+]]
55; ICP:[[TRUE_LABEL_IC2]]:
56; ICP:  [[RESULT_IC2:%[0-9]+]] = invoke i32 @_ZL4bar2v()
57; ICP:          to label %[[DCALL_NORMAL_DEST_IC2:.*]] unwind label %lpad1
58; ICP:[[FALSE_LABEL_IC2]]:
59  %call = invoke i32 %tmp6()
60          to label %try.cont8 unwind label %lpad1, !prof !3
61
62; ICP:[[DCALL_NORMAL_DEST_IC2]]:
63; ICP:  br label %try.cont8
64lpad1:
65  %tmp7 = landingpad { i8*, i32 }
66          catch i8* bitcast (i8** @_ZTIi to i8*)
67  %tmp8 = extractvalue { i8*, i32 } %tmp7, 0
68  %tmp9 = extractvalue { i8*, i32 } %tmp7, 1
69  %tmp10 = tail call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
70  %matches5 = icmp eq i32 %tmp9, %tmp10
71  br i1 %matches5, label %catch6, label %eh.resume
72
73catch6:
74  %tmp11 = tail call i8* @__cxa_begin_catch(i8* %tmp8)
75  tail call void @__cxa_end_catch()
76  br label %try.cont8
77
78try.cont8:
79  %i.0 = phi i32 [ undef, %catch6 ], [ %call, %try.cont ]
80; ICP:  %i.0 = phi i32 [ undef, %catch6 ], [ %call, %[[FALSE_LABEL_IC2]] ], [ [[RESULT_IC2]], %[[DCALL_NORMAL_DEST_IC2]] ]
81  ret i32 %i.0
82
83eh.resume:
84  %ehselector.slot.0 = phi i32 [ %tmp9, %lpad1 ], [ %tmp3, %lpad ]
85  %exn.slot.0 = phi i8* [ %tmp8, %lpad1 ], [ %tmp2, %lpad ]
86  %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn.slot.0, 0
87  %lpad.val11 = insertvalue { i8*, i32 } %lpad.val, i32 %ehselector.slot.0, 1
88  resume { i8*, i32 } %lpad.val11
89}
90
91declare i32 @__gxx_personality_v0(...)
92
93declare i32 @llvm.eh.typeid.for(i8*)
94
95declare i8* @__cxa_begin_catch(i8*)
96
97declare void @__cxa_end_catch()
98
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}
106