[llvm] c9260e2 - [CodeLayout] Do not rebuild chains with -apply-ext-tsp-for-size (#115934)

via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 18 09:16:12 PST 2024


Author: Ellis Hoag
Date: 2024-11-18T09:16:09-08:00
New Revision: c9260e21d092c3acbb77bb9f6fcd0820f6a138c1

URL: https://github.com/llvm/llvm-project/commit/c9260e21d092c3acbb77bb9f6fcd0820f6a138c1
DIFF: https://github.com/llvm/llvm-project/commit/c9260e21d092c3acbb77bb9f6fcd0820f6a138c1.diff

LOG: [CodeLayout] Do not rebuild chains with -apply-ext-tsp-for-size (#115934)

https://github.com/llvm/llvm-project/pull/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.

Added: 
    

Modified: 
    llvm/lib/CodeGen/MachineBlockPlacement.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index bdad63f368dfec..0f68313e64f542 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -3558,14 +3558,16 @@ bool MachineBlockPlacement::runOnMachineFunction(MachineFunction &MF) {
 
     if (BF.OptimizeFunction(MF, TII, MF.getSubtarget().getRegisterInfo(), MLI,
                             /*AfterPlacement=*/true)) {
-      // Redo the layout if tail merging creates/removes/moves blocks.
-      BlockToChain.clear();
-      ComputedEdges.clear();
       // Must redo the post-dominator tree if blocks were changed.
       if (MPDT)
         MPDT->recalculate(MF);
-      ChainAllocator.DestroyAll();
-      buildCFGChains();
+      if (!UseExtTspForSize) {
+        // Redo the layout if tail merging creates/removes/moves blocks.
+        BlockToChain.clear();
+        ComputedEdges.clear();
+        ChainAllocator.DestroyAll();
+        buildCFGChains();
+      }
     }
   }
 


        


More information about the llvm-commits mailing list