1 ; RUN: opt < %s -passes=pseudo-probe,sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile-metadata.prof -sample-profile-use-profi=0 -S | FileCheck %s
3 ; The test verifies the presence of prof metadata for BranchInst, SwitchInst,
6 @yydebug = dso_local global i32 0, align 4
8 define dso_local i32 @foo() #0 {
10 call void @llvm.pseudoprobe(i64 6699318081062747564, i64 1, i32 0, i64 -1)
11 %0 = load i32, ptr @yydebug, align 4
12 %cmp = icmp ne i32 %0, 0
13 br i1 %cmp, label %b1, label %exit
14 ; CHECK: br i1 %cmp, label %b1, label %exit, !prof ![[ENTRY_PROF:[0-9]+]]
17 call void @llvm.pseudoprobe(i64 6699318081062747564, i64 2, i32 0, i64 -1)
18 %1 = load i32, ptr @yydebug, align 4
19 switch i32 %1, label %b3 [
20 i32 124, label %indirectgoto
23 ; CHECK: ], !prof ![[SWITCH_PROF:[0-9]+]]
26 call void @llvm.pseudoprobe(i64 6699318081062747564, i64 3, i32 0, i64 -1)
27 br label %indirectgoto
30 call void @llvm.pseudoprobe(i64 6699318081062747564, i64 4, i32 0, i64 -1)
31 %2 = load i32, ptr @yydebug, align 4
35 %indirect.goto.dest = alloca i8, align 4
36 call void @llvm.pseudoprobe(i64 6699318081062747564, i64 5, i32 0, i64 -1)
37 indirectbr ptr %indirect.goto.dest, [label %b1, label %b3, label %b2]
38 ; CHECK: indirectbr ptr %indirect.goto.dest, [label %b1, label %b3, label %b2], !prof ![[GOTO_PROF:[0-9]+]]
41 call void @llvm.pseudoprobe(i64 6699318081062747564, i64 6, i32 0, i64 -1)
42 %3 = load i32, ptr @yydebug, align 4
47 attributes #0 = {"use-sample-profile"}
48 declare void @llvm.pseudoprobe(i64, i64, i32, i64) #1
49 !llvm.pseudo_probe_desc = !{!4496}
50 !4496 = !{i64 6699318081062747564, i64 158517001042, !"foo", null}
52 ; CHECK: ![[ENTRY_PROF]] = !{!"branch_weights", i32 10, i32 6}
53 ; CHECK: ![[SWITCH_PROF]] = !{!"branch_weights", i32 1, i32 9536, i32 1}
54 ; CHECK: ![[GOTO_PROF]] = !{!"branch_weights", i32 17739, i32 1, i32 1}