Skip to content

Conversation

@maksfb
Copy link
Contributor

@maksfb maksfb commented Dec 17, 2025

On AArch64, a larger cold code size can result in more veneers, increasing potential overhead for hot code. This change minimizes cold code size when the --use-compact-aligner option (default) is enabled.

@llvmbot
Copy link
Member

llvmbot commented Dec 17, 2025

@llvm/pr-subscribers-bolt

Author: Maksim Panchenko (maksfb)

Changes

On AArch64, a larger cold code size can result in more veneers, increasing potential overhead for hot code. This change minimizes cold code size when the --use-compact-aligner option (default) is enabled.


Full diff: https://github.com/llvm/llvm-project/pull/172598.diff

1 Files Affected:

  • (modified) bolt/lib/Passes/Aligner.cpp (+7)
diff --git a/bolt/lib/Passes/Aligner.cpp b/bolt/lib/Passes/Aligner.cpp
index 5d21bdb3f154a..c631120e9de09 100644
--- a/bolt/lib/Passes/Aligner.cpp
+++ b/bolt/lib/Passes/Aligner.cpp
@@ -77,6 +77,13 @@ static void alignCompact(BinaryFunction &Function,
   size_t HotSize = 0;
   size_t ColdSize = 0;
 
+  // On AArch64, larger cold code size may lead to more veneers and higher
+  // potential overhead for hot code. Minimize the cold code size.
+  if (!Function.hasProfile() && BC.isAArch64()) {
+    Function.setAlignment(Function.getMinAlignment());
+    return;
+  }
+
   for (const BinaryBasicBlock &BB : Function)
     if (BB.isSplit())
       ColdSize += BC.computeCodeSize(BB.begin(), BB.end(), Emitter);

@maksfb maksfb changed the title [BOLT][AArch64] Use minumal code alignment for cold functions [BOLT][AArch64] Use minimal code alignment for cold functions Dec 17, 2025
On AArch64, a larger cold code size can result in more veneers,
increasing potential overhead for hot code. This change minimizes cold
code size when the `--use-compact-aligner` option (default) is enabled.
@maksfb maksfb force-pushed the gh-aarch64-min-align-cold branch from 78db16e to 3c15943 Compare December 17, 2025 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants