[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)

Shaw Young via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jul 26 07:46:41 PDT 2024


================
@@ -478,10 +675,34 @@ matchWeightsByHashes(BinaryContext &BC,
     Blocks.push_back(&Func.Blocks[I + 1]);
     BlendedBlockHash BlendedHash(BB->getHash());
     BlendedHashes.push_back(BlendedHash);
+    // Collects pseudo probes attached to the BB for use in the StaleMatcher.
+    if (opts::ProfileUsePseudoProbes &&
+        opts::StaleMatchingWithBlockPseudoProbes && PseudoProbeDecoder) {
+      const AddressProbesMap &ProbeMap =
+          PseudoProbeDecoder->getAddress2ProbesMap();
+      const uint64_t FuncAddr = BF.getAddress();
+      const std::pair<uint64_t, uint64_t> &BlockRange =
+          BB->getInputAddressRange();
+      const auto &BlockProbes =
+          llvm::make_range(ProbeMap.lower_bound(FuncAddr + BlockRange.first),
+                           ProbeMap.lower_bound(FuncAddr + BlockRange.second));
+      for (const auto &[_, Probes] : BlockProbes) {
+        for (const MCDecodedPseudoProbe &Probe : Probes) {
+          if (Probe.getType() != static_cast<uint8_t>(PseudoProbeType::Block))
+            continue;
+          if (Probe.getInlineTreeNode()->hasInlineSite())
+            Matcher.mapGUIDAndIndexToProbe(Probe.getGuid(), Probe.getIndex(),
+                                           &Probe);
+          else
+            Matcher.mapIndexToProbe(Probe.getIndex(), &Probe);
----------------
shawbyoung wrote:

Hm perhaps the binary I looked at wasn't representative. Thanks for your comment. I think I was thinking in too granular in terms of map optimization, I'll change this.

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


More information about the llvm-branch-commits mailing list