1 ; RUN: split-file %s %t
2 ; RUN: llvm-ctxprof-util fromJSON --input %t/profile.json --output %t/profile.ctxprofdata
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
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]+]]
13 ; CHECK: ![[BW]] = !{!"branch_weights", i32 10, i32 10}
16 declare i32 @external(i32 %x)
17 define 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)
24 define 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)
31 define 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)
42 attributes #0 = { alwaysinline }
43 attributes #1 = { noinline }
50 "Guid": 4000, "Counters":[10], "Callsites": [
51 [{"Guid":3000, "Counters":[10], "Callsites":[[{"Guid":1000, "Counters":[10]}]]}],
52 [{"Guid":3000, "Counters":[10], "Callsites":[[{"Guid":9000, "Counters":[10]}]]}]