[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jul 24 13:55:10 PDT 2024
================
@@ -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
More information about the llvm-branch-commits
mailing list