summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/PGOProfile/icp_covariant_call_return.ll44
-rw-r--r--llvm/test/Transforms/PGOProfile/icp_covariant_invoke_return.ll110
-rw-r--r--llvm/test/Transforms/PGOProfile/icp_invoke.ll104
-rw-r--r--llvm/test/Transforms/PGOProfile/icp_mismatch_msg.ll39
-rw-r--r--llvm/test/Transforms/PGOProfile/icp_vararg.ll33
-rw-r--r--llvm/test/Transforms/PGOProfile/indirect_call_promotion.ll54
6 files changed, 384 insertions, 0 deletions
diff --git a/llvm/test/Transforms/PGOProfile/icp_covariant_call_return.ll b/llvm/test/Transforms/PGOProfile/icp_covariant_call_return.ll
new file mode 100644
index 00000000000..0494ba97e37
--- /dev/null
+++ b/llvm/test/Transforms/PGOProfile/icp_covariant_call_return.ll
@@ -0,0 +1,44 @@
+; RUN: opt < %s -pgo-icall-prom -S | FileCheck %s --check-prefix=ICALL-PROM
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%struct.D = type { %struct.B }
+%struct.B = type { i32 (...)** }
+%struct.Base = type { i8 }
+%struct.Derived = type { i8 }
+
+declare noalias i8* @_Znwm(i64)
+declare void @_ZN1DC2Ev(%struct.D*);
+declare %struct.Derived* @_ZN1D4funcEv(%struct.D*);
+
+define i32 @bar() {
+entry:
+ %call = call noalias i8* @_Znwm(i64 8)
+ %tmp = bitcast i8* %call to %struct.D*
+ call void @_ZN1DC2Ev(%struct.D* %tmp)
+ %tmp1 = bitcast %struct.D* %tmp to %struct.B*
+ %tmp2 = bitcast %struct.B* %tmp1 to %struct.Base* (%struct.B*)***
+ %vtable = load %struct.Base* (%struct.B*)**, %struct.Base* (%struct.B*)*** %tmp2, align 8
+ %vfn = getelementptr inbounds %struct.Base* (%struct.B*)*, %struct.Base* (%struct.B*)** %vtable, i64 0
+ %tmp3 = load %struct.Base* (%struct.B*)*, %struct.Base* (%struct.B*)** %vfn, align 8
+; ICALL-PROM: [[BITCAST:%[0-9]+]] = bitcast %struct.Base* (%struct.B*)* %tmp3 to i8*
+; ICALL-PROM: [[CMP:%[0-9]+]] = icmp eq i8* [[BITCAST]], bitcast (%struct.Derived* (%struct.D*)* @_ZN1D4funcEv to i8*)
+; ICALL-PROM: br i1 [[CMP]], label %if.true.direct_targ, label %if.false.orig_indirect, !prof [[BRANCH_WEIGHT:![0-9]+]]
+; ICALL-PROM:if.true.direct_targ:
+; ICALL-PROM: [[ARG_BITCAST:%[0-9]+]] = bitcast %struct.B* %tmp1 to %struct.D*
+; ICALL-PROM: [[DIRCALL_RET:%[0-9]+]] = call %struct.Derived* @_ZN1D4funcEv(%struct.D* [[ARG_BITCAST]])
+; ICALL-PROM: [[DIRCALL_RET_CAST:%[0-9]+]] = bitcast %struct.Derived* [[DIRCALL_RET]] to %struct.Base*
+; ICALL-PROM: br label %if.end.icp
+; ICALL-PROM:if.false.orig_indirect:
+; ICALL-PROM: %call1 = call %struct.Base* %tmp3(%struct.B* %tmp1)
+; ICALL-PROM: br label %if.end.icp
+; ICALL-PROM:if.end.icp:
+; ICALL-PROM: [[PHI_RET:%[0-9]+]] = phi %struct.Base* [ %call1, %if.false.orig_indirect ], [ [[DIRCALL_RET_CAST]], %if.true.direct_targ ]
+ %call1 = call %struct.Base* %tmp3(%struct.B* %tmp1), !prof !1
+ ret i32 0
+}
+
+!1 = !{!"VP", i32 0, i64 12345, i64 -3913987384944532146, i64 12345}
+; ICALL-PROM-NOT: !1 = !{!"VP", i32 0, i64 12345, i64 -3913987384944532146, i64 12345}
+; ICALL-PROM: [[BRANCH_WEIGHT]] = !{!"branch_weights", i32 12345, i32 0}
+; ICALL-PROM-NOT: !1 = !{!"VP", i32 0, i64 12345, i64 -3913987384944532146, i64 12345}
diff --git a/llvm/test/Transforms/PGOProfile/icp_covariant_invoke_return.ll b/llvm/test/Transforms/PGOProfile/icp_covariant_invoke_return.ll
new file mode 100644
index 00000000000..4ee5521e7fb
--- /dev/null
+++ b/llvm/test/Transforms/PGOProfile/icp_covariant_invoke_return.ll
@@ -0,0 +1,110 @@
+; RUN: opt < %s -pgo-icall-prom -S | FileCheck %s --check-prefix=ICALL-PROM
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+%struct.D = type { %struct.B }
+%struct.B = type { i32 (...)** }
+%struct.Derived = type { %struct.Base, i32 }
+%struct.Base = type { i32 }
+
+@_ZTIi = external constant i8*
+declare i8* @_Znwm(i64)
+declare void @_ZN1DC2Ev(%struct.D*)
+declare %struct.Derived* @_ZN1D4funcEv(%struct.D*)
+declare void @_ZN1DD0Ev(%struct.D*)
+declare void @_ZdlPv(i8*)
+declare i32 @__gxx_personality_v0(...)
+declare i32 @llvm.eh.typeid.for(i8*)
+declare i8* @__cxa_begin_catch(i8*)
+declare void @__cxa_end_catch()
+
+
+define i32 @foo() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+entry:
+ %call = invoke i8* @_Znwm(i64 8)
+ to label %invoke.cont unwind label %lpad
+
+invoke.cont:
+ %tmp = bitcast i8* %call to %struct.D*
+ call void @_ZN1DC2Ev(%struct.D* %tmp)
+ %tmp1 = bitcast %struct.D* %tmp to %struct.B*
+ %tmp2 = bitcast %struct.B* %tmp1 to %struct.Base* (%struct.B*)***
+ %vtable = load %struct.Base* (%struct.B*)**, %struct.Base* (%struct.B*)*** %tmp2, align 8
+ %vfn = getelementptr inbounds %struct.Base* (%struct.B*)*, %struct.Base* (%struct.B*)** %vtable, i64 0
+ %tmp3 = load %struct.Base* (%struct.B*)*, %struct.Base* (%struct.B*)** %vfn, align 8
+; ICALL-PROM: [[BITCAST:%[0-9]+]] = bitcast %struct.Base* (%struct.B*)* %tmp3 to i8*
+; ICALL-PROM: [[CMP:%[0-9]+]] = icmp eq i8* [[BITCAST]], bitcast (%struct.Derived* (%struct.D*)* @_ZN1D4funcEv to i8*)
+; ICALL-PROM: br i1 [[CMP]], label %if.true.direct_targ, label %if.false.orig_indirect, !prof [[BRANCH_WEIGHT:![0-9]+]]
+; ICALL-PROM:if.true.direct_targ:
+; ICALL-PROM: [[ARG_BITCAST:%[0-9]+]] = bitcast %struct.B* %tmp1 to %struct.D*
+; ICALL-PROM: [[DIRCALL_RET:%[0-9]+]] = invoke %struct.Derived* @_ZN1D4funcEv(%struct.D* [[ARG_BITCAST]])
+; ICALL-PROM: to label %if.end.icp unwind label %lpad
+; ICALL-PROM:if.false.orig_indirect:
+; ICAll-PROM: %call2 = invoke %struct.Base* %tmp3(%struct.B* %tmp1)
+; ICAll-PROM: to label %invoke.cont1 unwind label %lpad
+; ICALL-PROM:if.end.icp:
+; ICALL-PROM: [[DIRCALL_RET_CAST:%[0-9]+]] = bitcast %struct.Derived* [[DIRCALL_RET]] to %struct.Base*
+; ICALL-PROM: br label %invoke.cont1
+ %call2 = invoke %struct.Base* %tmp3(%struct.B* %tmp1)
+ to label %invoke.cont1 unwind label %lpad, !prof !1
+
+invoke.cont1:
+; ICAll-PROM: [[PHI_RET:%[0-9]+]] = phi %struct.Base* [ %call2, %if.false.orig_indirect ], [ [[DIRCALL_RET_CAST]], %if.end.icp ]
+; ICAll-PROM: %isnull = icmp eq %struct.Base* [[PHI_RET]], null
+ %isnull = icmp eq %struct.Base* %call2, null
+ br i1 %isnull, label %delete.end, label %delete.notnull
+
+delete.notnull:
+ %tmp4 = bitcast %struct.Base* %call2 to i8*
+ call void @_ZdlPv(i8* %tmp4)
+ br label %delete.end
+
+delete.end:
+ %isnull3 = icmp eq %struct.B* %tmp1, null
+ br i1 %isnull3, label %delete.end8, label %delete.notnull4
+
+delete.notnull4:
+ %tmp5 = bitcast %struct.B* %tmp1 to void (%struct.B*)***
+ %vtable5 = load void (%struct.B*)**, void (%struct.B*)*** %tmp5, align 8
+ %vfn6 = getelementptr inbounds void (%struct.B*)*, void (%struct.B*)** %vtable5, i64 2
+ %tmp6 = load void (%struct.B*)*, void (%struct.B*)** %vfn6, align 8
+ invoke void %tmp6(%struct.B* %tmp1)
+ to label %invoke.cont7 unwind label %lpad
+
+invoke.cont7:
+ br label %delete.end8
+
+delete.end8:
+ br label %try.cont
+
+lpad:
+ %tmp7 = landingpad { i8*, i32 }
+ catch i8* bitcast (i8** @_ZTIi to i8*)
+ %tmp8 = extractvalue { i8*, i32 } %tmp7, 0
+ %tmp9 = extractvalue { i8*, i32 } %tmp7, 1
+ br label %catch.dispatch
+
+catch.dispatch:
+ %tmp10 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
+ %matches = icmp eq i32 %tmp9, %tmp10
+ br i1 %matches, label %catch, label %eh.resume
+
+catch:
+ %tmp11 = call i8* @__cxa_begin_catch(i8* %tmp8)
+ %tmp12 = bitcast i8* %tmp11 to i32*
+ %tmp13 = load i32, i32* %tmp12, align 4
+ call void @__cxa_end_catch()
+ br label %try.cont
+
+try.cont:
+ ret i32 0
+
+eh.resume:
+ %lpad.val = insertvalue { i8*, i32 } undef, i8* %tmp8, 0
+ %lpad.val11 = insertvalue { i8*, i32 } %lpad.val, i32 %tmp9, 1
+ resume { i8*, i32 } %lpad.val11
+}
+
+!1 = !{!"VP", i32 0, i64 12345, i64 -3913987384944532146, i64 12345}
+; ICALL-PROM-NOT: !1 = !{!"VP", i32 0, i64 12345, i64 -3913987384944532146, i64 12345}
+; ICALL-PROM: [[BRANCH_WEIGHT]] = !{!"branch_weights", i32 12345, i32 0}
+; ICALL-PROM-NOT: !1 = !{!"VP", i32 0, i64 12345, i64 -3913987384944532146, i64 12345}
diff --git a/llvm/test/Transforms/PGOProfile/icp_invoke.ll b/llvm/test/Transforms/PGOProfile/icp_invoke.ll
new file mode 100644
index 00000000000..773bd6fc816
--- /dev/null
+++ b/llvm/test/Transforms/PGOProfile/icp_invoke.ll
@@ -0,0 +1,104 @@
+; RUN: opt < %s -icp-lto -pgo-icall-prom -S -icp-count-threshold=0 | FileCheck %s --check-prefix=ICP
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo1 = global void ()* null, align 8
+@foo2 = global i32 ()* null, align 8
+@_ZTIi = external constant i8*
+
+define internal void @_ZL4bar1v() !PGOFuncName !0 {
+entry:
+ ret void
+}
+
+define internal i32 @_ZL4bar2v() !PGOFuncName !1 {
+entry:
+ ret i32 100
+}
+
+define i32 @_Z3goov() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+entry:
+ %tmp = load void ()*, void ()** @foo1, align 8
+; ICP: [[BITCAST_IC1:%[0-9]+]] = bitcast void ()* %tmp to i8*
+; ICP: [[CMP_IC1:%[0-9]+]] = icmp eq i8* [[BITCAST_IC1]], bitcast (void ()* @_ZL4bar1v to i8*)
+; ICP: br i1 [[CMP_IC1]], label %[[TRUE_LABEL_IC1:.*]], label %[[FALSE_LABEL_IC1:.*]], !prof [[BRANCH_WEIGHT:![0-9]+]]
+; ICP:[[TRUE_LABEL_IC1]]:
+; ICP: invoke void @_ZL4bar1v()
+; ICP: to label %[[DCALL_NORMAL_DEST_IC1:.*]] unwind label %lpad
+; ICP:[[FALSE_LABEL_IC1]]:
+ invoke void %tmp()
+ to label %try.cont unwind label %lpad, !prof !2
+
+; ICP:[[DCALL_NORMAL_DEST_IC1]]:
+; ICP: br label %try.cont
+
+lpad:
+ %tmp1 = landingpad { i8*, i32 }
+ catch i8* bitcast (i8** @_ZTIi to i8*)
+ %tmp2 = extractvalue { i8*, i32 } %tmp1, 0
+ %tmp3 = extractvalue { i8*, i32 } %tmp1, 1
+ %tmp4 = tail call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
+ %matches = icmp eq i32 %tmp3, %tmp4
+ br i1 %matches, label %catch, label %eh.resume
+
+catch:
+ %tmp5 = tail call i8* @__cxa_begin_catch(i8* %tmp2)
+ tail call void @__cxa_end_catch()
+ br label %try.cont
+
+try.cont:
+ %tmp6 = load i32 ()*, i32 ()** @foo2, align 8
+; ICP: [[BITCAST_IC2:%[0-9]+]] = bitcast i32 ()* %tmp6 to i8*
+; ICP: [[CMP_IC2:%[0-9]+]] = icmp eq i8* [[BITCAST_IC2]], bitcast (i32 ()* @_ZL4bar2v to i8*)
+; ICP: br i1 [[CMP_IC2]], label %[[TRUE_LABEL_IC2:.*]], label %[[FALSE_LABEL_IC2:.*]], !prof [[BRANCH_WEIGHT:![0-9]+]]
+; ICP:[[TRUE_LABEL_IC2]]:
+; ICP: [[RESULT_IC2:%[0-9]+]] = invoke i32 @_ZL4bar2v()
+; ICP: to label %[[DCALL_NORMAL_DEST_IC2:.*]] unwind label %lpad1
+; ICP:[[FALSE_LABEL_IC2]]:
+ %call = invoke i32 %tmp6()
+ to label %try.cont8 unwind label %lpad1, !prof !3
+
+; ICP:[[DCALL_NORMAL_DEST_IC2]]:
+; ICP: br label %try.cont8
+lpad1:
+ %tmp7 = landingpad { i8*, i32 }
+ catch i8* bitcast (i8** @_ZTIi to i8*)
+ %tmp8 = extractvalue { i8*, i32 } %tmp7, 0
+ %tmp9 = extractvalue { i8*, i32 } %tmp7, 1
+ %tmp10 = tail call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
+ %matches5 = icmp eq i32 %tmp9, %tmp10
+ br i1 %matches5, label %catch6, label %eh.resume
+
+catch6:
+ %tmp11 = tail call i8* @__cxa_begin_catch(i8* %tmp8)
+ tail call void @__cxa_end_catch()
+ br label %try.cont8
+
+try.cont8:
+ %i.0 = phi i32 [ undef, %catch6 ], [ %call, %try.cont ]
+; ICP: %i.0 = phi i32 [ undef, %catch6 ], [ %call, %[[FALSE_LABEL_IC2]] ], [ [[RESULT_IC2]], %[[DCALL_NORMAL_DEST_IC2]] ]
+ ret i32 %i.0
+
+eh.resume:
+ %ehselector.slot.0 = phi i32 [ %tmp9, %lpad1 ], [ %tmp3, %lpad ]
+ %exn.slot.0 = phi i8* [ %tmp8, %lpad1 ], [ %tmp2, %lpad ]
+ %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn.slot.0, 0
+ %lpad.val11 = insertvalue { i8*, i32 } %lpad.val, i32 %ehselector.slot.0, 1
+ resume { i8*, i32 } %lpad.val11
+}
+
+declare i32 @__gxx_personality_v0(...)
+
+declare i32 @llvm.eh.typeid.for(i8*)
+
+declare i8* @__cxa_begin_catch(i8*)
+
+declare void @__cxa_end_catch()
+
+!0 = !{!"invoke.ll:_ZL4bar1v"}
+!1 = !{!"invoke.ll:_ZL4bar2v"}
+!2 = !{!"VP", i32 0, i64 1, i64 -2732222848796217051, i64 1}
+!3 = !{!"VP", i32 0, i64 1, i64 -6116256810522035449, i64 1}
+; ICP-NOT !3 = !{!"VP", i32 0, i64 1, i64 -2732222848796217051, i64 1}
+; ICP-NOT !4 = !{!"VP", i32 0, i64 1, i64 -6116256810522035449, i64 1}
+; ICP: [[BRANCH_WEIGHT]] = !{!"branch_weights", i32 1, i32 0}
diff --git a/llvm/test/Transforms/PGOProfile/icp_mismatch_msg.ll b/llvm/test/Transforms/PGOProfile/icp_mismatch_msg.ll
new file mode 100644
index 00000000000..05002523451
--- /dev/null
+++ b/llvm/test/Transforms/PGOProfile/icp_mismatch_msg.ll
@@ -0,0 +1,39 @@
+; RUN: opt < %s -pgo-icall-prom -pass-remarks-missed=PGOIndirectCallPromotion -S 2>& 1 | FileCheck %s
+
+; CHECK: remark: <unknown>:0:0: Cannot promote indirect call to func4 with count of 1234: The number of arguments mismatch
+; CHECK: remark: <unknown>:0:0: Cannot promote indirect call to 11517462787082255043 with count of 2345: Cannot find the target
+; CHECK: remark: <unknown>:0:0: Cannot promote indirect call to func2 with count of 7890: Return type mismatch
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = common global i32 ()* null, align 8
+@foo2 = common global i32 ()* null, align 8
+@foo3 = common global i32 ()* null, align 8
+
+define i32 @func4(i32 %i) {
+entry:
+ ret i32 %i
+}
+
+define void @func2() {
+entry:
+ ret void
+}
+
+define i32 @bar() {
+entry:
+ %tmp = load i32 ()*, i32 ()** @foo, align 8
+ %call = call i32 %tmp(), !prof !1
+ %tmp2 = load i32 ()*, i32 ()** @foo2, align 8
+ %call1 = call i32 %tmp2(), !prof !2
+ %add = add nsw i32 %call1, %call
+ %tmp3 = load i32 ()*, i32 ()** @foo3, align 8
+ %call2 = call i32 %tmp3(), !prof !3
+ %add2 = add nsw i32 %add, %call2
+ ret i32 %add2
+}
+
+!1 = !{!"VP", i32 0, i64 1801, i64 7651369219802541373, i64 1234, i64 -4377547752858689819, i64 567}
+!2 = !{!"VP", i32 0, i64 3023, i64 -6929281286627296573, i64 2345, i64 -4377547752858689819, i64 678}
+!3 = !{!"VP", i32 0, i64 7890, i64 -4377547752858689819, i64 7890}
diff --git a/llvm/test/Transforms/PGOProfile/icp_vararg.ll b/llvm/test/Transforms/PGOProfile/icp_vararg.ll
new file mode 100644
index 00000000000..9692aaf4804
--- /dev/null
+++ b/llvm/test/Transforms/PGOProfile/icp_vararg.ll
@@ -0,0 +1,33 @@
+; RUN: opt < %s -pgo-icall-prom -S | FileCheck %s --check-prefix=ICALL-PROM
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = common global i32 (i32, ...)* null, align 8
+
+define i32 @va_func(i32 %num, ...) {
+entry:
+ ret i32 0
+}
+
+define i32 @bar() #1 {
+entry:
+ %tmp = load i32 (i32, ...)*, i32 (i32, ...)** @foo, align 8
+; ICALL-PROM: [[BITCAST:%[0-9]+]] = bitcast i32 (i32, ...)* %tmp to i8*
+; ICALL-PROM: [[CMP:%[0-9]+]] = icmp eq i8* [[BITCAST]], bitcast (i32 (i32, ...)* @va_func to i8*)
+; ICALL-PROM: br i1 [[CMP]], label %if.true.direct_targ, label %if.false.orig_indirect, !prof [[BRANCH_WEIGHT:![0-9]+]]
+; ICALL-PROM:if.true.direct_targ:
+; ICALL-PROM: [[DIRCALL_RET:%[0-9]+]] = call i32 (i32, ...) @va_func(i32 3, i32 12, i32 22, i32 4)
+; ICALL-PROM: br label %if.end.icp
+ %call = call i32 (i32, ...) %tmp(i32 3, i32 12, i32 22, i32 4), !prof !1
+; ICALL-PROM:if.false.orig_indirect:
+; ICALL-PROM: %call = call i32 (i32, ...) %tmp(i32 3, i32 12, i32 22, i32 4)
+; ICALL-PROM: br label %if.end.icp
+ ret i32 %call
+; ICALL-PROM:if.end.icp:
+; ICALL-PROM: [[PHI_RET:%[0-9]+]] = phi i32 [ %call, %if.false.orig_indirect ], [ [[DIRCALL_RET]], %if.true.direct_targ ]
+; ICALL-PROM: ret i32 [[PHI_RET]]
+
+}
+
+!1 = !{!"VP", i32 0, i64 12345, i64 989055279648259519, i64 12345}
+; ICALL-PROM: [[BRANCH_WEIGHT]] = !{!"branch_weights", i32 12345, i32 0}
diff --git a/llvm/test/Transforms/PGOProfile/indirect_call_promotion.ll b/llvm/test/Transforms/PGOProfile/indirect_call_promotion.ll
new file mode 100644
index 00000000000..01c10694ab6
--- /dev/null
+++ b/llvm/test/Transforms/PGOProfile/indirect_call_promotion.ll
@@ -0,0 +1,54 @@
+; RUN: opt < %s -pgo-icall-prom -S | FileCheck %s --check-prefix=ICALL-PROM
+; RUN: opt < %s -pgo-icall-prom -S -pass-remarks=PGOIndirectCallPromotion -icp-count-threshold=0 -icp-percent-threshold=0 -icp-max-prom=4 2>&1 | FileCheck %s --check-prefix=PASS-REMARK
+; PASS-REMARK: remark: <unknown>:0:0: Promote indirect call to func4 with count 1030 out of 1600
+; PASS-REMARK: remark: <unknown>:0:0: Promote indirect call to func2 with count 410 out of 570
+; PASS-REMARK: remark: <unknown>:0:0: Promote indirect call to func3 with count 150 out of 160
+; PASS-REMARK: remark: <unknown>:0:0: Promote indirect call to func1 with count 10 out of 10
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = common global i32 ()* null, align 8
+
+define i32 @func1() {
+entry:
+ ret i32 0
+}
+
+define i32 @func2() {
+entry:
+ ret i32 1
+}
+
+define i32 @func3() {
+entry:
+ ret i32 2
+}
+
+define i32 @func4() {
+entry:
+ ret i32 3
+}
+
+define i32 @bar() {
+entry:
+ %tmp = load i32 ()*, i32 ()** @foo, align 8
+; ICALL-PROM: [[BITCAST:%[0-9]+]] = bitcast i32 ()* %tmp to i8*
+; ICALL-PROM: [[CMP:%[0-9]+]] = icmp eq i8* [[BITCAST]], bitcast (i32 ()* @func4 to i8*)
+; ICALL-PROM: br i1 [[CMP]], label %if.true.direct_targ, label %if.false.orig_indirect, !prof [[BRANCH_WEIGHT:![0-9]+]]
+; ICALL-PROM: if.true.direct_targ:
+; ICALL-PROM: [[DIRCALL_RET:%[0-9]+]] = call i32 @func4()
+; ICALL-PROM: br label %if.end.icp
+ %call = call i32 %tmp(), !prof !1
+; ICALL-PROM: if.false.orig_indirect:
+; ICALL-PROM: %call = call i32 %tmp(), !prof [[NEW_VP_METADATA:![0-9]+]]
+ ret i32 %call
+; ICALL-PROM: if.end.icp:
+; ICALL-PROM: [[PHI_RET:%[0-9]+]] = phi i32 [ %call, %if.false.orig_indirect ], [ [[DIRCALL_RET]], %if.true.direct_targ ]
+; ICALL-PROM: ret i32 [[PHI_RET]]
+}
+
+!1 = !{!"VP", i32 0, i64 1600, i64 7651369219802541373, i64 1030, i64 -4377547752858689819, i64 410, i64 -6929281286627296573, i64 150, i64 -2545542355363006406, i64 10}
+
+; ICALL-PROM: [[BRANCH_WEIGHT]] = !{!"branch_weights", i32 1030, i32 570}
+; ICALL-PROM: [[NEW_VP_METADATA]] = !{!"VP", i32 0, i64 570, i64 -4377547752858689819, i64 410}
OpenPOWER on IntegriCloud