[llvm-branch-commits] [BOLT] Use aggregated FuncBranchData in writeBATYAML (PR #91289)

Amir Ayupov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon May 13 12:21:09 PDT 2024


================
@@ -2386,25 +2362,26 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
         return std::pair(BlockIt->first, BlockIt->second.getBBIndex());
       };
 
-      for (const auto &[FromOffset, SuccKV] : Branches.IntraIndex) {
-        const auto &[_, Index] = getBlock(FromOffset);
-        yaml::bolt::BinaryBasicBlockProfile &YamlBB = YamlBF.Blocks[Index];
-        for (const auto &[SuccOffset, SuccDataIdx] : SuccKV)
-          if (BlockMap.isInputBlock(SuccOffset))
-            YamlBB.Successors.emplace_back(
-                getSuccessorInfo(SuccOffset, SuccDataIdx));
-      }
-      for (const auto &[FromOffset, CallTo] : Branches.InterIndex) {
-        const auto &[BlockOffset, BlockIndex] = getBlock(FromOffset);
-        yaml::bolt::BinaryBasicBlockProfile &YamlBB = YamlBF.Blocks[BlockIndex];
-        const uint32_t Offset = FromOffset - BlockOffset;
-        for (const auto &[CallToLoc, CallToIdx] : CallTo)
-          YamlBB.CallSites.emplace_back(
-              getCallSiteInfo(CallToLoc, CallToIdx, Offset));
-        llvm::sort(YamlBB.CallSites, [](yaml::bolt::CallSiteInfo &A,
-                                        yaml::bolt::CallSiteInfo &B) {
-          return A.Offset < B.Offset;
-        });
+      for (const llvm::bolt::BranchInfo &BI : Branches.Data) {
----------------
aaupov wrote:

Unfortunately we need a FQ name:
`llvm::bolt::BranchInfo`:
https://github.com/llvm/llvm-project/blob/5944579ab20cfcb6d1a9d1a2fe3d4b478ea24c64/bolt/include/bolt/Profile/DataReader.h#L78
```
`llvm::bolt::DataAggregator::BranchInfo`:
https://github.com/llvm/llvm-project/blob/5944579ab20cfcb6d1a9d1a2fe3d4b478ea24c64/bolt/include/bolt/Profile/DataAggregator.h#L125

I thought about renaming the latter to `TakenInfo` to match its counterpart `FTInfo`: https://github.com/llvm/llvm-project/blob/5944579ab20cfcb6d1a9d1a2fe3d4b478ea24c64/bolt/include/bolt/Profile/DataAggregator.h#L120
WDYT?

https://github.com/llvm/llvm-project/pull/91289


More information about the llvm-branch-commits mailing list