================
@@ -478,10 +605,31 @@ 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 && 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.getInlineTreeNode()->hasInlineSite())
+            continue;
+          if (Probe.getType() != static_cast<uint8_t>(PseudoProbeType::Block))
+            continue;
+          Matcher.mapIndexToProbe(Probe.getIndex(), &Probe);
+          Matcher.mapProbeToBB(&Probe, Blocks[I]);
----------------
WenleiHe wrote:

Where do we guard all of this by CFG hash check? I was looking for something 
like `BFPseudoProbeDescHash == YamlBF.PseudoProbeDescHash`.

I can see `YamlBFGUID` is being checked in `matchWithPseudoProbes`, but 1) this 
isn't obvious from readability POV, 2) we don't need to populate the mapping if 
we are not gonna trust probe at all (`BFPseudoProbeDescHash == 
YamlBF.PseudoProbeDescHash`). 

https://github.com/llvm/llvm-project/pull/99891
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to