1; RUN: opt < %s -pgo-icall-prom -S | FileCheck %s --check-prefix=ICALL-PROM 2; RUN: opt < %s -passes=pgo-icall-prom -S | FileCheck %s --check-prefix=ICALL-PROM 3; RUN: opt < %s -pgo-icall-prom -S -pass-remarks=pgo-icall-prom -icp-count-threshold=0 -icp-percent-threshold=0 -icp-max-prom=4 2>&1 | FileCheck %s --check-prefix=PASS-REMARK 4; RUN: opt < %s -passes=pgo-icall-prom -S -pass-remarks=pgo-icall-prom -icp-count-threshold=0 -icp-percent-threshold=0 -icp-max-prom=4 2>&1 | FileCheck %s --check-prefix=PASS-REMARK 5; PASS-REMARK: remark: <unknown>:0:0: Promote indirect call to func4 with count 1030 out of 1600 6; PASS-REMARK: remark: <unknown>:0:0: Promote indirect call to func2 with count 410 out of 570 7; PASS-REMARK: remark: <unknown>:0:0: Promote indirect call to func3 with count 150 out of 160 8; PASS-REMARK: remark: <unknown>:0:0: Promote indirect call to func1 with count 10 out of 10 9 10target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 11target triple = "x86_64-unknown-linux-gnu" 12 13@foo = common global i32 ()* null, align 8 14 15define i32 @func1() { 16entry: 17 ret i32 0 18} 19 20define i32 @func2() { 21entry: 22 ret i32 1 23} 24 25define i32 @func3() { 26entry: 27 ret i32 2 28} 29 30define i32 @func4() { 31entry: 32 ret i32 3 33} 34 35define i32 @bar() { 36entry: 37 %tmp = load i32 ()*, i32 ()** @foo, align 8 38; ICALL-PROM: [[BITCAST:%[0-9]+]] = bitcast i32 ()* %tmp to i8* 39; ICALL-PROM: [[CMP:%[0-9]+]] = icmp eq i8* [[BITCAST]], bitcast (i32 ()* @func4 to i8*) 40; ICALL-PROM: br i1 [[CMP]], label %if.true.direct_targ, label %if.false.orig_indirect, !prof [[BRANCH_WEIGHT:![0-9]+]] 41; ICALL-PROM: if.true.direct_targ: 42; ICALL-PROM: [[DIRCALL_RET:%[0-9]+]] = call i32 @func4() 43; ICALL-PROM: br label %if.end.icp 44 %call = call i32 %tmp(), !prof !1 45; ICALL-PROM: if.false.orig_indirect: 46; ICALL-PROM: %call = call i32 %tmp(), !prof [[NEW_VP_METADATA:![0-9]+]] 47 ret i32 %call 48; ICALL-PROM: if.end.icp: 49; ICALL-PROM: [[PHI_RET:%[0-9]+]] = phi i32 [ %call, %if.false.orig_indirect ], [ [[DIRCALL_RET]], %if.true.direct_targ ] 50; ICALL-PROM: ret i32 [[PHI_RET]] 51} 52 53!1 = !{!"VP", i32 0, i64 1600, i64 7651369219802541373, i64 1030, i64 -4377547752858689819, i64 410, i64 -6929281286627296573, i64 150, i64 -2545542355363006406, i64 10} 54 55; ICALL-PROM: [[BRANCH_WEIGHT]] = !{!"branch_weights", i32 1030, i32 570} 56; ICALL-PROM: [[NEW_VP_METADATA]] = !{!"VP", i32 0, i64 570, i64 -4377547752858689819, i64 410} 57