[llvm-branch-commits] [llvm] [BOLT] Add pseudo probe inline tree to YAML profile (PR #107137)

Amir Ayupov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Sep 11 19:52:43 PDT 2024


================
@@ -2421,11 +2433,14 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
             const uint32_t InputOffset = BAT->translate(
                 FuncAddr, OutputAddress - FuncAddr, /*IsBranchSrc=*/true);
             const unsigned BlockIndex = getBlock(InputOffset).second;
-            YamlBF.Blocks[BlockIndex].PseudoProbes.emplace_back(
-                yaml::bolt::PseudoProbeInfo{Probe.getGuid(), Probe.getIndex(),
-                                            Probe.getType()});
+            BlockProbes[BlockIndex].emplace_back(Probe);
           }
         }
+
+        for (auto &[Block, Probes] : BlockProbes) {
+          YamlBF.Blocks[Block].PseudoProbes =
+              YAMLProfileWriter::writeBlockProbes(Probes, InlineTreeNodeId);
----------------
aaupov wrote:

We have two places where YAML function profile is constructed: 
- YAMLProfileWriter for the regular case: the profile is dumped from function CFG, 
- DataAggregator for BOLTed binaries/functions where we want the profile for the original function: the profile is reconstructed using [BAT](https://github.com/llvm/llvm-project/blob/8168088f0a9015bc6d930e8bc1c639dee06ca82c/bolt/docs/BAT.md) (BOLT Address Translation) tables.

In DataAggregator/BAT case we want to write profile for original/pre-BOLT binary including probe information, and there's no explicit way to iterate over probes in original/pre-BOLT order while they're encoded in optimized/BOLTed order.

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


More information about the llvm-branch-commits mailing list