[PATCH] D152731: [BOLT] Sort BranchData in DataAggregator

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 12 10:36:47 PDT 2023


Amir created this revision.
Amir added a reviewer: bolt.
Herald added a reviewer: rafauler.
Herald added subscribers: treapster, ayermolo.
Herald added a reviewer: maksfb.
Herald added a project: All.
Amir requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.

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.

Additionally, the annotations are attached to CFG and affect output YAML
profile. Thus, this change aligns both perf vs fdata, and yaml vs fdata profile
use cases.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152731

Files:
  bolt/lib/Profile/DataAggregator.cpp
  bolt/test/runtime/X86/fdata-escape-chars.ll


Index: bolt/test/runtime/X86/fdata-escape-chars.ll
===================================================================
--- bolt/test/runtime/X86/fdata-escape-chars.ll
+++ bolt/test/runtime/X86/fdata-escape-chars.ll
@@ -88,8 +88,8 @@
 ; INSTR_CHECK: {{([[:xdigit:]]+)}}:   callq   "symb whitespace" # Count: 1
 
 ; PREAGR_FDATA_CHECK: 1 main 0 1 static\ symb\ backslash\\/1 0 0 1
-; PREAGR_FDATA_CHECK: 1 main 0 1 symb\ whitespace 0 0 1
 ; PREAGR_FDATA_CHECK: 1 main 0 1 symb\ backslash\\ 0 0 2
+; PREAGR_FDATA_CHECK: 1 main 0 1 symb\ whitespace 0 0 1
 ; PREAGR_FDATA_CHECK: 1 static\ symb\ backslash\\/1 0 1 symb\ whitespace 0 0 1
 ; PREAGR_FDATA_CHECK: 1 symb\ backslash\\ 0 1 symb\ whitespace 0 0 2
 
Index: bolt/lib/Profile/DataAggregator.cpp
===================================================================
--- bolt/lib/Profile/DataAggregator.cpp
+++ bolt/lib/Profile/DataAggregator.cpp
@@ -624,6 +624,12 @@
       BF.markProfiled(Flags);
   }
 
+  for (auto &FuncBranches : NamesToBranches)
+    llvm::stable_sort(FuncBranches.second.Data);
+
+  for (auto &MemEvents : NamesToMemEvents)
+    llvm::stable_sort(MemEvents.second.Data);
+
   // Release intermediate storage.
   clear(BranchLBRs);
   clear(FallthroughLBRs);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152731.530587.patch
Type: text/x-patch
Size: 1229 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230612/9fc572cb/attachment.bin>


More information about the llvm-commits mailing list