[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 23:59:31 PDT 2026


labrinea wrote:

> @labrinea I took a look at this PR and evaluated it. The changes here make sense are do some good refactoring of the existing experimental relaxation pass, thanks!
> 
> When testing in a large binary for us, I realized we're now generating quite a few more thunks. The evaluation showed:
> 
> hot text 4% larger (+530kb) total code +800kb thunks-> 45K -> 64K branch thunks (new) 0 -> 279,167 peakRSS-> +1% wall time->flat
> 
> One of the things I saw is that because we're now creating a new cluster to hold only hot functions and another one just for their cold size (out of splitting them), we end up with one cluster that is 10MB (because hot size is usually quite small) and another one that is 6MB (the cold part of these hot funcs). Each in its own cluster. So previously we had 3 clusters for this workload and now we have 5.
> 
> So a lot of the branches that really didn't need thunks because the hot functions were co-located in the same cluster of other unprofiled functions (the bulk of functions in the binary) now get a thunk assigned. Some of them now get a long thunk because they're not adjacent anymore. And all of the new 280k new branch thunks are unnecessary.
> 
> So while the direction is technically correct, it is also overly conservative and does come with a price.

Hey Rafael, thanks for evaluating! Indeed with the patch in its current form some unnecessary thunks are expected. If you look at my comment https://github.com/llvm/llvm-project/pull/215825#discussion_r3851477392 it is possible to allow a cluster to span across multiple sections. This dramatically reduces the number of thunks. Note that I've also decreased the max cluster size to 120mb so that there's more room for error, which may contribute to additional thunks.

Would you like me to update the patch with cross section clusters and re-evaluate?

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


More information about the llvm-commits mailing list