Skip to content

Commit c9260e2

Browse files
authored
[CodeLayout] Do not rebuild chains with -apply-ext-tsp-for-size (#115934)
#109711 disables `buildCFGChains()` when `-apply-ext-tsp-for-size` is used to improve codesize. Tail merging can change the layout and normally requires `buildCFGChains()` to be called again, but we want to prevent this when optimizing for codesize. We saw slight size improvement on large binaries with this change. If `-apply-ext-tsp-for-size` is not used, this should be a NFC.
1 parent 2444b6f commit c9260e2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

llvm/lib/CodeGen/MachineBlockPlacement.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3558,14 +3558,16 @@ bool MachineBlockPlacement::runOnMachineFunction(MachineFunction &MF) {
35583558

35593559
if (BF.OptimizeFunction(MF, TII, MF.getSubtarget().getRegisterInfo(), MLI,
35603560
/*AfterPlacement=*/true)) {
3561-
// Redo the layout if tail merging creates/removes/moves blocks.
3562-
BlockToChain.clear();
3563-
ComputedEdges.clear();
35643561
// Must redo the post-dominator tree if blocks were changed.
35653562
if (MPDT)
35663563
MPDT->recalculate(MF);
3567-
ChainAllocator.DestroyAll();
3568-
buildCFGChains();
3564+
if (!UseExtTspForSize) {
3565+
// Redo the layout if tail merging creates/removes/moves blocks.
3566+
BlockToChain.clear();
3567+
ComputedEdges.clear();
3568+
ChainAllocator.DestroyAll();
3569+
buildCFGChains();
3570+
}
35693571
}
35703572
}
35713573

0 commit comments

Comments
 (0)