[PATCH] D159488: [BOLT] matching stale entry blocks
Sergey Pupyrev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 8 11:38:11 PDT 2023
spupyrev created this revision.
Herald added a reviewer: rafauler.
Herald added subscribers: treapster, ayermolo.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
spupyrev edited the summary of this revision.
spupyrev published this revision for review.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.
Two (minor) improvements for stale matching:
- always match entry blocks to each other, even if there is a hash mismatch;
- ignore nops in (loose) hash computation.
I record a small improvement in inference quality on my benchmarks. Tests are not affected
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D159488
Files:
bolt/lib/Core/HashUtilities.cpp
bolt/lib/Profile/StaleProfileMatching.cpp
Index: bolt/lib/Profile/StaleProfileMatching.cpp
===================================================================
--- bolt/lib/Profile/StaleProfileMatching.cpp
+++ bolt/lib/Profile/StaleProfileMatching.cpp
@@ -389,6 +389,9 @@
assert(YamlBB.Hash != 0 && "empty hash of BinaryBasicBlockProfile");
BlendedBlockHash YamlHash(YamlBB.Hash);
const FlowBlock *MatchedBlock = Matcher.matchBlock(YamlHash);
+ // Always match the entry block.
+ if (MatchedBlock == nullptr && YamlBB.Index == 0)
+ MatchedBlock = Blocks[0];
if (MatchedBlock != nullptr) {
MatchedBlocks[YamlBB.Index] = MatchedBlock;
BlendedBlockHash BinHash = BlendedHashes[MatchedBlock->Index - 1];
Index: bolt/lib/Core/HashUtilities.cpp
===================================================================
--- bolt/lib/Core/HashUtilities.cpp
+++ bolt/lib/Core/HashUtilities.cpp
@@ -139,7 +139,8 @@
// instruction opcodes, which is then hashed with std::hash.
std::set<std::string> Opcodes;
for (const MCInst &Inst : BB) {
- if (BC.MIB->isPseudo(Inst))
+ // Skip pseudo instructions and nops.
+ if (BC.MIB->isPseudo(Inst) || BC.MIB->isNoop(Inst))
continue;
// Ignore unconditional jumps, as they can be added / removed as a result
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159488.556292.patch
Type: text/x-patch
Size: 1265 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230908/e76af62b/attachment.bin>
More information about the llvm-commits
mailing list