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 4target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 5target triple = "x86_64-unknown-linux-gnu" 6 7@foo = common global i32* ()* null, align 8 8 9define i32* @func1() { 10 ret i32* null 11} 12 13define i32* @func2() { 14 ret i32* null 15} 16 17define i32* @func3() { 18 ret i32* null 19} 20 21define i32* @func4() { 22 ret i32* null 23} 24 25define i32* @bar() { 26entry: 27 %tmp = load i32* ()*, i32* ()** @foo, align 8 28; ICALL-PROM: [[CMP1:%[0-9]+]] = icmp eq i32* ()* %tmp, @func4 29; ICALL-PROM: br i1 [[CMP1]], label %if.true.direct_targ, label %[[L1:[0-9]+]], !prof [[BRANCH_WEIGHT1:![0-9]+]] 30; ICALL-PROM: if.true.direct_targ: 31; ICALL-PROM: [[DIRCALL_RET1:%[0-9]+]] = musttail call i32* @func4() 32; ICALL-PROM: ret i32* [[DIRCALL_RET1]] 33; ICALL-PROM: [[L1]]: 34; ICALL-PROM: [[CMP2:%[0-9]+]] = icmp eq i32* ()* %tmp, @func2 35; ICALL-PROM: br i1 [[CMP2]], label %if.true.direct_targ1, label %[[L2:[0-9]+]], !prof [[BRANCH_WEIGHT2:![0-9]+]] 36; ICALL-PROM: if.true.direct_targ1: 37; ICALL-PROM: [[DIRCALL_RET2:%[0-9]+]] = musttail call i32* @func2() 38; ICALL-PROM: ret i32* [[DIRCALL_RET2]] 39; ICALL-PROM: [[L2]]: 40; ICALL-PROM: [[CMP3:%[0-9]+]] = icmp eq i32* ()* %tmp, @func3 41; ICALL-PROM: br i1 [[CMP3]], label %if.true.direct_targ2, label %[[L3:[0-9]+]], !prof [[BRANCH_WEIGHT3:![0-9]+]] 42; ICALL-PROM: if.true.direct_targ2: 43; ICALL-PROM: [[DIRCALL_RET3:%[0-9]+]] = musttail call i32* @func3() 44; ICALL-PROM: ret i32* [[DIRCALL_RET3]] 45; ICALL-PROM: [[L3]]: 46; ICALL-PROM: %call = musttail call i32* %tmp() 47; ICALL-PROM: ret i32* %call 48 %call = musttail call i32* %tmp(), !prof !1 49 ret i32* %call 50} 51 52define i64* @bar2() { 53entry: 54 %tmp = load i32* ()*, i32* ()** @foo, align 8 55; ICALL-PROM: [[CMP1:%[0-9]+]] = icmp eq i32* ()* %tmp, @func4 56; ICALL-PROM: br i1 [[CMP1]], label %if.true.direct_targ, label %[[L4:[0-9]+]], !prof [[BRANCH_WEIGHT4:![0-9]+]] 57; ICALL-PROM: if.true.direct_targ: 58; ICALL-PROM: [[DIRCALL_RET1:%[0-9]+]] = musttail call i32* @func4() 59; ICALL-PROM: [[DIRCALL_RET2:%[0-9]+]] = bitcast i32* [[DIRCALL_RET1]] to i64* 60; ICALL-PROM: ret i64* [[DIRCALL_RET2]] 61; ICALL-PROM: [[L4]]: 62; ICALL-PROM: %call = musttail call i32* %tmp() 63; ICALL-PROM: %rv = bitcast i32* %call to i64* 64; ICALL-PROM: ret i64* %rv 65 %call = musttail call i32* %tmp(), !prof !2 66 %rv = bitcast i32* %call to i64* 67 ret i64* %rv 68} 69 70!1 = !{!"VP", i32 0, i64 1600, i64 7651369219802541373, i64 1030, i64 -4377547752858689819, i64 410, i64 -6929281286627296573, i64 150, i64 -2545542355363006406, i64 10} 71!2 = !{!"VP", i32 0, i64 100, i64 7651369219802541373, i64 100} 72 73; ICALL-PROM: [[BRANCH_WEIGHT1]] = !{!"branch_weights", i32 1030, i32 570} 74; ICALL-PROM: [[BRANCH_WEIGHT2]] = !{!"branch_weights", i32 410, i32 160} 75; ICALL-PROM: [[BRANCH_WEIGHT3]] = !{!"branch_weights", i32 150, i32 10} 76; ICALL-PROM: [[BRANCH_WEIGHT4]] = !{!"branch_weights", i32 100, i32 0} 77