1; RUN: split-file %s %t 2; RUN: llvm-ctxprof-util fromYAML --input %t/profile.yaml --output %t/profile.ctxprofdata 3; 4; In the given profile, in one of the contexts the indirect call is taken, the 5; target we're trying to ICP - GUID:2000 - doesn't appear at all. That should 6; contribute to the count of the "indirect call BB". 7; RUN: opt %t/test.ll -S -passes='require<ctx-prof-analysis>,module-inline,ctx-prof-flatten' -use-ctx-profile=%t/profile.ctxprofdata -ctx-prof-promote-alwaysinline 8 9; CHECK-LABEL: define i32 @caller(ptr %c) 10; CHECK-NEXT: [[CND:[0-9]+]] = icmp eq ptr %c, @one 11; CHECK-NEXT: br i1 [[CND]], label %{{.*}}, label %{{.*}}, !prof ![[BW:[0-9]+]] 12 13; CHECK: ![[BW]] = !{!"branch_weights", i32 10, i32 10} 14 15;--- test.ll 16declare i32 @external(i32 %x) 17define i32 @one() #0 !guid !0 { 18 call void @llvm.instrprof.increment(ptr @one, i64 123, i32 1, i32 0) 19 call void @llvm.instrprof.callsite(ptr @one, i64 123, i32 1, i32 0, ptr @external) 20 %ret = call i32 @external(i32 1) 21 ret i32 %ret 22} 23 24define i32 @caller(ptr %c) #1 !guid !1 { 25 call void @llvm.instrprof.increment(ptr @caller, i64 567, i32 1, i32 0) 26 call void @llvm.instrprof.callsite(ptr @caller, i64 567, i32 1, i32 0, ptr %c) 27 %ret = call i32 %c() 28 ret i32 %ret 29} 30 31define i32 @root(ptr %c) !guid !2 { 32 call void @llvm.instrprof.increment(ptr @root, i64 432, i32 1, i32 0) 33 call void @llvm.instrprof.callsite(ptr @root, i64 432, i32 2, i32 0, ptr @caller) 34 %a = call i32 @caller(ptr %c) 35 call void @llvm.instrprof.callsite(ptr @root, i64 432, i32 2, i32 1, ptr @caller) 36 %b = call i32 @caller(ptr %c) 37 %ret = add i32 %a, %b 38 ret i32 %ret 39 40} 41 42attributes #0 = { alwaysinline } 43attributes #1 = { noinline } 44!0 = !{i64 1000} 45!1 = !{i64 3000} 46!2 = !{i64 4000} 47 48;--- profile.yaml 49- Guid: 4000 50 Counters: [10] 51 Callsites: - 52 - Guid: 3000 53 Counters: [10] 54 Callsites: - 55 - Guid: 1000 56 Counters: [10] 57 - 58 - Guid: 3000 59 Counters: [10] 60 Callsites: - 61 - Guid: 9000 62 Counters: [10] 63