• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -icp-lto -pgo-icall-prom -S | FileCheck %s --check-prefix=ICP
2; RUN: opt < %s -icp-lto -passes=pgo-icall-prom -S | FileCheck %s --check-prefix=ICP
3target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-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:  [[CMP_IC1:%[0-9]+]] = icmp eq void ()* %tmp, @_ZL4bar1v
24; ICP:  br i1 [[CMP_IC1]], label %[[TRUE_LABEL_IC1:.*]], label %[[FALSE_LABEL_IC1:.*]], !prof [[BRANCH_WEIGHT:![0-9]+]]
25; ICP:[[TRUE_LABEL_IC1]]:
26; ICP:  invoke void @_ZL4bar1v()
27; ICP:          to label %[[DCALL_NORMAL_DEST_IC1:.*]] unwind label %lpad
28; ICP:[[FALSE_LABEL_IC1]]:
29  invoke void %tmp()
30          to label %try.cont unwind label %lpad, !prof !2
31
32; ICP:[[DCALL_NORMAL_DEST_IC1]]:
33; ICP:  br label %try.cont
34
35lpad:
36  %tmp1 = landingpad { i8*, i32 }
37          catch i8* bitcast (i8** @_ZTIi to i8*)
38  %tmp2 = extractvalue { i8*, i32 } %tmp1, 0
39  %tmp3 = extractvalue { i8*, i32 } %tmp1, 1
40  %tmp4 = tail call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
41  %matches = icmp eq i32 %tmp3, %tmp4
42  br i1 %matches, label %catch, label %eh.resume
43
44catch:
45  %tmp5 = tail call i8* @__cxa_begin_catch(i8* %tmp2)
46  tail call void @__cxa_end_catch()
47  br label %try.cont
48
49try.cont:
50  %tmp6 = load i32 ()*, i32 ()** @foo2, align 8
51; ICP:  [[CMP_IC2:%[0-9]+]] = icmp eq i32 ()* %tmp6, @_ZL4bar2v
52; ICP:  br i1 [[CMP_IC2]], label %[[TRUE_LABEL_IC2:.*]], label %[[FALSE_LABEL_IC2:.*]], !prof [[BRANCH_WEIGHT:![0-9]+]]
53; ICP:[[TRUE_LABEL_IC2]]:
54; ICP:  [[RESULT_IC2_0:%[0-9]+]] = invoke i32 @_ZL4bar2v()
55; ICP:          to label %[[MERGE_BB:.*]] unwind label %lpad1
56; ICP:[[FALSE_LABEL_IC2]]:
57; ICP:  [[RESULT_IC2_1:%.+]] = invoke i32 %tmp6()
58; ICP:          to label %[[MERGE_BB]] unwind label %lpad1
59  %call = invoke i32 %tmp6()
60          to label %try.cont8 unwind label %lpad1, !prof !3
61
62; ICP:[[MERGE_BB]]:
63; ICP:  [[MERGE_PHI:%.+]] = phi i32 [ [[RESULT_IC2_1]], %[[FALSE_LABEL_IC2]] ], [ [[RESULT_IC2_0]], %[[TRUE_LABEL_IC2]] ]
64; ICP:  br label %try.cont8
65lpad1:
66  %tmp7 = landingpad { i8*, i32 }
67          catch i8* bitcast (i8** @_ZTIi to i8*)
68  %tmp8 = extractvalue { i8*, i32 } %tmp7, 0
69  %tmp9 = extractvalue { i8*, i32 } %tmp7, 1
70  %tmp10 = tail call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
71  %matches5 = icmp eq i32 %tmp9, %tmp10
72  br i1 %matches5, label %catch6, label %eh.resume
73
74catch6:
75  %tmp11 = tail call i8* @__cxa_begin_catch(i8* %tmp8)
76  tail call void @__cxa_end_catch()
77  br label %try.cont8
78
79try.cont8:
80  %i.0 = phi i32 [ undef, %catch6 ], [ %call, %try.cont ]
81; ICP:  %i.0 = phi i32 [ undef, %catch6 ], [ [[MERGE_PHI]], %[[MERGE_BB]] ]
82  ret i32 %i.0
83
84eh.resume:
85  %ehselector.slot.0 = phi i32 [ %tmp9, %lpad1 ], [ %tmp3, %lpad ]
86  %exn.slot.0 = phi i8* [ %tmp8, %lpad1 ], [ %tmp2, %lpad ]
87  %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn.slot.0, 0
88  %lpad.val11 = insertvalue { i8*, i32 } %lpad.val, i32 %ehselector.slot.0, 1
89  resume { i8*, i32 } %lpad.val11
90}
91
92declare i32 @__gxx_personality_v0(...)
93
94declare i32 @llvm.eh.typeid.for(i8*)
95
96declare i8* @__cxa_begin_catch(i8*)
97
98declare void @__cxa_end_catch()
99
100!0 = !{!"invoke.ll:_ZL4bar1v"}
101!1 = !{!"invoke.ll:_ZL4bar2v"}
102!2 = !{!"VP", i32 0, i64 1, i64 -2732222848796217051, i64 1}
103!3 = !{!"VP", i32 0, i64 1, i64 -6116256810522035449, i64 1}
104; ICP-NOT: !3 = !{!"VP", i32 0, i64 1, i64 -2732222848796217051, i64 1}
105; ICP-NOT: !4 = !{!"VP", i32 0, i64 1, i64 -6116256810522035449, i64 1}
106; ICP: [[BRANCH_WEIGHT]] = !{!"branch_weights", i32 1, i32 0}
107