================
@@ -208,11 +212,33 @@ class StaleMatcher {
     }
   }
 
-  /// Find the most similar block for a given hash.
-  const FlowBlock *matchBlock(BlendedBlockHash BlendedHash,
-                              uint64_t CallHash) const {
+  /// Creates a mapping from a pseudo probe index to pseudo probe.
+  void mapIndexToProbe(uint64_t Index, const MCDecodedPseudoProbe *Probe) {
+    IndexToBBPseudoProbes[Index].push_back(Probe);
+  }
+
+  /// Creates a mapping from a pseudo probe to a flow block.
+  void mapProbeToBB(const MCDecodedPseudoProbe *Probe, FlowBlock *Block) {
+    BBPseudoProbeToBlock[Probe] = Block;
+  }
+
+  /// Find the most similar flow block for a profile block given its hashes and
+  /// pseudo probe information.
+  const FlowBlock *
+  matchBlock(BlendedBlockHash BlendedHash, uint64_t CallHash,
+             const std::vector<yaml::bolt::PseudoProbeInfo> &PseudoProbes) {
     const FlowBlock *BestBlock = matchWithOpcodes(BlendedHash);
-    return BestBlock ? BestBlock : matchWithCalls(BlendedHash, CallHash);
+    if (BestBlock) {
+      ++MatchedWithOpcodes;
+      return BestBlock;
+    }
+    BestBlock = matchWithCalls(BlendedHash, CallHash);
+    if (BestBlock)
+      return BestBlock;
+    BestBlock = matchWithPseudoProbes(BlendedHash, PseudoProbes);
----------------
WenleiHe wrote:

I'm a bit unsure about the strategy here. This is assuming matching of each 
individual block/node is an isolated problem. But the reality is, it's not, 
instead we're matching two sets of nodes (or rather two graphs) holistically.

I.e. if we function's CFG hash matches that from probe desc, we should be able 
to have high confidence exact mapping for all blocks based on probe, and 
shouldn't need to treat probe based matching as a fallback?   

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