mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
6f2c43f053
Currently prof metadata with branch counts is added only for BranchInst and SwitchInst, but not for IndirectBrInst. As a result, BPI/BFI make incorrect inferences for indirect branches, which can be very hot. This diff adds metadata for IndirectBrInst, in addition to BranchInst and SwitchInst. Reviewed By: wmi, wenlei Differential Revision: https://reviews.llvm.org/D99550
55 lines
1.9 KiB
LLVM
55 lines
1.9 KiB
LLVM
; RUN: opt < %s -passes=pseudo-probe,sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile-metadata.prof -S | FileCheck %s
|
|
|
|
; The test verifies the presence of prof metadata for BranchInst, SwitchInst,
|
|
; and IndirectBrInst
|
|
|
|
@yydebug = dso_local global i32 0, align 4
|
|
|
|
define dso_local i32 @foo() #0 {
|
|
entry:
|
|
call void @llvm.pseudoprobe(i64 6699318081062747564, i64 1, i32 0, i64 -1)
|
|
%0 = load i32, i32* @yydebug, align 4
|
|
%cmp = icmp ne i32 %0, 0
|
|
br i1 %cmp, label %b1, label %exit
|
|
; CHECK: br i1 %cmp, label %b1, label %exit, !prof ![[ENTRY_PROF:[0-9]+]]
|
|
|
|
b1:
|
|
call void @llvm.pseudoprobe(i64 6699318081062747564, i64 2, i32 0, i64 -1)
|
|
%1 = load i32, i32* @yydebug, align 4
|
|
switch i32 %1, label %b3 [
|
|
i32 124, label %indirectgoto
|
|
i32 92, label %b2
|
|
]
|
|
; CHECK: ], !prof ![[SWITCH_PROF:[0-9]+]]
|
|
|
|
b2:
|
|
call void @llvm.pseudoprobe(i64 6699318081062747564, i64 3, i32 0, i64 -1)
|
|
br label %indirectgoto
|
|
|
|
b3:
|
|
call void @llvm.pseudoprobe(i64 6699318081062747564, i64 4, i32 0, i64 -1)
|
|
%2 = load i32, i32* @yydebug, align 4
|
|
ret i32 %2
|
|
|
|
indirectgoto:
|
|
%indirect.goto.dest = alloca i8, align 4
|
|
call void @llvm.pseudoprobe(i64 6699318081062747564, i64 5, i32 0, i64 -1)
|
|
indirectbr i8* %indirect.goto.dest, [label %b1, label %b3, label %b2]
|
|
; CHECK: indirectbr i8* %indirect.goto.dest, [label %b1, label %b3, label %b2], !prof ![[GOTO_PROF:[0-9]+]]
|
|
|
|
exit:
|
|
call void @llvm.pseudoprobe(i64 6699318081062747564, i64 6, i32 0, i64 -1)
|
|
%3 = load i32, i32* @yydebug, align 4
|
|
ret i32 %3
|
|
|
|
}
|
|
|
|
attributes #0 = {"use-sample-profile"}
|
|
declare void @llvm.pseudoprobe(i64, i64, i32, i64) #1
|
|
!llvm.pseudo_probe_desc = !{!4496}
|
|
!4496 = !{i64 6699318081062747564, i64 158517001042, !"foo", null}
|
|
|
|
; CHECK: ![[ENTRY_PROF]] = !{!"branch_weights", i32 10, i32 6}
|
|
; CHECK: ![[SWITCH_PROF]] = !{!"branch_weights", i32 1, i32 9536, i32 1}
|
|
; CHECK: ![[GOTO_PROF]] = !{!"branch_weights", i32 17739, i32 1, i32 1}
|