Skip to content

Commit 224e4cc

Browse files
committed
[BOLT] Sort BranchData in DataAggregator
Align perf reader to fdata behavior by sorting BranchData after reading samples, in the same way as DataReader: https://github.com/llvm/llvm-project/blob/20c66a0c66340f44f04b6526e45bcc5d872d480a/bolt/lib/Profile/DataReader.cpp#L1239 Namely, that order affects CallSiteInfo annotations which determine the construction order of CallGraph, which in turn affects function reordering. Reviewed By: #bolt, rafauler Differential Revision: https://reviews.llvm.org/D152731
1 parent eea865b commit 224e4cc

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,12 @@ void DataAggregator::processProfile(BinaryContext &BC) {
624624
BF.markProfiled(Flags);
625625
}
626626

627+
for (auto &FuncBranches : NamesToBranches)
628+
llvm::stable_sort(FuncBranches.second.Data);
629+
630+
for (auto &MemEvents : NamesToMemEvents)
631+
llvm::stable_sort(MemEvents.second.Data);
632+
627633
// Release intermediate storage.
628634
clear(BranchLBRs);
629635
clear(FallthroughLBRs);

bolt/test/runtime/X86/fdata-escape-chars.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ define internal void @static_symb_backslash_b() #0 {
8888
; INSTR_CHECK: {{([[:xdigit:]]+)}}: callq "symb whitespace" # Count: 1
8989

9090
; PREAGR_FDATA_CHECK: 1 main 0 1 static\ symb\ backslash\\/1 0 0 1
91-
; PREAGR_FDATA_CHECK: 1 main 0 1 symb\ whitespace 0 0 1
9291
; PREAGR_FDATA_CHECK: 1 main 0 1 symb\ backslash\\ 0 0 2
92+
; PREAGR_FDATA_CHECK: 1 main 0 1 symb\ whitespace 0 0 1
9393
; PREAGR_FDATA_CHECK: 1 static\ symb\ backslash\\/1 0 1 symb\ whitespace 0 0 1
9494
; PREAGR_FDATA_CHECK: 1 symb\ backslash\\ 0 1 symb\ whitespace 0 0 2
9595

0 commit comments

Comments
 (0)