65 lines · plain
1; RUN: split-file %s %t2; RUN: llvm-ctxprof-util fromYAML --input %t/profile.yaml --output %t/profile.ctxprofdata3;4; In the given profile, in one of the contexts the indirect call is taken, the5; target we're trying to ICP - GUID:2000 - doesn't appear at all. That should6; 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, @one11; CHECK-NEXT: br i1 [[CND]], label %{{.*}}, label %{{.*}}, !prof ![[BW:[0-9]+]]12 13; CHECK: ![[BW]] = !{!"branch_weights", i32 10, i32 10}14 15;--- test.ll16declare 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 %ret22}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 %ret29}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, %b38 ret i32 %ret39 40}41 42attributes #0 = { alwaysinline }43attributes #1 = { noinline }44!0 = !{i64 1000}45!1 = !{i64 3000}46!2 = !{i64 4000}47 48;--- profile.yaml49Contexts:50 - Guid: 400051 TotalRootEntryCount: 1052 Counters: [10]53 Callsites: -54 - Guid: 300055 Counters: [10]56 Callsites: -57 - Guid: 100058 Counters: [10]59 -60 - Guid: 300061 Counters: [10]62 Callsites: -63 - Guid: 900064 Counters: [10]65