| 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 |
| 2 |
|
| 3 |
; The test verifies the presence of prof metadata for BranchInst, SwitchInst, |
| 4 |
; and IndirectBrInst |
| 5 |
|
| 6 |
@yydebug = dso_local global i32 0, align 4 |
| 7 |
|
| 8 |
define dso_local i32 @foo() #0 { |
| 9 |
entry: |
| 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]+]] |
| 15 |
|
| 16 |
b1: |
| 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 |
| 21 |
i32 92, label %b2 |
| 22 |
] |
| 23 |
; CHECK: ], !prof ![[SWITCH_PROF:[0-9]+]] |
| 24 |
|
| 25 |
b2: |
| 26 |
call void @llvm.pseudoprobe(i64 6699318081062747564, i64 3, i32 0, i64 -1) |
| 27 |
br label %indirectgoto |
| 28 |
|
| 29 |
b3: |
| 30 |
call void @llvm.pseudoprobe(i64 6699318081062747564, i64 4, i32 0, i64 -1) |
| 31 |
%2 = load i32, ptr @yydebug, align 4 |
| 32 |
ret i32 %2 |
| 33 |
|
| 34 |
indirectgoto: |
| 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]+]] |
| 39 |
|
| 40 |
exit: |
| 41 |
call void @llvm.pseudoprobe(i64 6699318081062747564, i64 6, i32 0, i64 -1) |
| 42 |
%3 = load i32, ptr @yydebug, align 4 |
| 43 |
ret i32 %3 |
| 44 |
|
| 45 |
} |
| 46 |
|
| 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} |
| 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} |