[llvm] [BOLT][AArch64] Relax calls and branches with fragment clusters (PR #215825)

Alexandros Lamprineas via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 08:04:25 PDT 2026


labrinea wrote:

> This appears to address one of the main problems described in #218885: calls from main and cold fragments were previously grouped by whole function and could be redirected to a thunk in the wrong section.
> 
> The issue also contains reproducers involving function padding, boundary markers, skipped functions, hugify placement and alignment. It may be useful to test this patch against those cases as well.

I had a look at the failing examples. This patch does not take into account user defined padding before/after a given function, so I expect some tests to keep failing. I am not concerned about such synthetic cases though. User defined padding is a debug option. If you look at my tests I am creating large hot functions between split fragments to simulate big gaps.

We could extend the patch to account for such padding, but only to correctly estimate what goes into each cluster. If a Function Fragment (including its padding) exceeds the MaxClusterSize then there's not much we can do with the current design. Function-list insertion is too coarse to guarantee where the thunk lands when large padding is emitted inside function emission.

To handle it properly, we’d need one of:
  - BB/local thunk insertion for these edges instead of output-function thunk insertion.
  - A new emitter-level hook to insert thunks before/after function padding.
  - Model padding as separate output fragments/functions, which is probably overkill.
  - something else?

The assumptions of this patch is that sections are contiguous, with small enough gaps (i.e. hufigy alignment) for thunks to reach across to the next thunk in the chain. I think it's a realistic assumption.

https://github.com/llvm/llvm-project/pull/215825


More information about the llvm-commits mailing list