[PATCH] D129397: Do not merge cold with hot chains
Sergey Pupyrev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 8 13:34:31 PDT 2022
spupyrev created this revision.
Herald added a reviewer: rafauler.
Herald added a subscriber: ayermolo.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
spupyrev requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D129397
Files:
bolt/lib/Passes/ExtTSPReorderAlgorithm.cpp
Index: bolt/lib/Passes/ExtTSPReorderAlgorithm.cpp
===================================================================
--- bolt/lib/Passes/ExtTSPReorderAlgorithm.cpp
+++ bolt/lib/Passes/ExtTSPReorderAlgorithm.cpp
@@ -642,20 +642,25 @@
}
}
- /// Merge cold blocks to reduce code size
+ /// Merge remaining blocks into chains w/o taking jump counts into
+ /// consideration. This allows to maintain the original block order in the
+ /// absense of profile data
void mergeColdChains() {
for (BinaryBasicBlock *SrcBB : BF.layout()) {
// Iterating in reverse order to make sure original fallthrough jumps are
- // merged first
+ // merged first; this might be beneficial for code size.
for (auto Itr = SrcBB->succ_rbegin(); Itr != SrcBB->succ_rend(); ++Itr) {
BinaryBasicBlock *DstBB = *Itr;
size_t SrcIndex = SrcBB->getLayoutIndex();
size_t DstIndex = DstBB->getLayoutIndex();
Chain *SrcChain = AllBlocks[SrcIndex].CurChain;
Chain *DstChain = AllBlocks[DstIndex].CurChain;
+ bool IsColdSrc = SrcChain->executionCount() == 0;
+ bool IsColdDst = DstChain->executionCount() == 0;
if (SrcChain != DstChain && !DstChain->isEntryPoint() &&
SrcChain->blocks().back()->Index == SrcIndex &&
- DstChain->blocks().front()->Index == DstIndex)
+ DstChain->blocks().front()->Index == DstIndex &&
+ IsColdSrc == IsColdDst)
mergeChains(SrcChain, DstChain, 0, MergeTypeTy::X_Y);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129397.443339.patch
Type: text/x-patch
Size: 1544 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220708/89f2b9ba/attachment.bin>
More information about the llvm-commits
mailing list