55 lines · plain
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 %s2 3; The test verifies the presence of prof metadata for BranchInst, SwitchInst,4; and IndirectBrInst5 6@yydebug = dso_local global i32 0, align 47 8define dso_local i32 @foo() #0 {9entry:10 call void @llvm.pseudoprobe(i64 6699318081062747564, i64 1, i32 0, i64 -1)11 %0 = load i32, ptr @yydebug, align 412 %cmp = icmp ne i32 %0, 013 br i1 %cmp, label %b1, label %exit14; CHECK: br i1 %cmp, label %b1, label %exit, !prof ![[ENTRY_PROF:[0-9]+]]15 16b1:17 call void @llvm.pseudoprobe(i64 6699318081062747564, i64 2, i32 0, i64 -1)18 %1 = load i32, ptr @yydebug, align 419 switch i32 %1, label %b3 [20 i32 124, label %indirectgoto21 i32 92, label %b222 ]23; CHECK: ], !prof ![[SWITCH_PROF:[0-9]+]]24 25b2:26 call void @llvm.pseudoprobe(i64 6699318081062747564, i64 3, i32 0, i64 -1)27 br label %indirectgoto28 29b3:30 call void @llvm.pseudoprobe(i64 6699318081062747564, i64 4, i32 0, i64 -1)31 %2 = load i32, ptr @yydebug, align 432 ret i32 %233 34indirectgoto:35 %indirect.goto.dest = alloca i8, align 436 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]+]]39 40exit:41 call void @llvm.pseudoprobe(i64 6699318081062747564, i64 6, i32 0, i64 -1)42 %3 = load i32, ptr @yydebug, align 443 ret i32 %344 45}46 47attributes #0 = {"use-sample-profile"}48declare void @llvm.pseudoprobe(i64, i64, i32, i64) #149!llvm.pseudo_probe_desc = !{!4496}50!4496 = !{i64 6699318081062747564, i64 158517001042, !"foo", null}51 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}55