[llvm] [BOLT][AArch64] Add support for compact code model (PR #112110)
Maksim Panchenko via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 22 15:31:21 PDT 2024
maksfb wrote:
> Unconditional branches are split with a trampoline.
Yes, they are isolated in a separate basic block and registered as a trampoline so that we can re-use them if needed. Otherwise the code should stay the same.
> Conditional branches (excluding indirects), are relaxed/split with trampolines as needed, until we converge. During relaxation (`relaxBranch`), it is attempted to add cold-branch trampolines at the end of the fragment. If out of range, those are added at the next block (just like with hot ones).
Correct.
> > Note that the new `.text` has to be smaller than 128MB
>
> Could this be checked? Or do we pass this responsibility to the user since compact mode flag was their choice?
We will know the final layout only after JITLink pass. At that point, JITLink would fail if the binary exceeds the limits. O/c we can print the warning if the input binary was already larger than 128MB. At the moment, before we add thunk support to JITLink, we do pass the responsibility to the user.
> > produces slightly smaller code
>
> Do we anticipate some trampoline duplication on unconditional branches to say common cold functions? Do we consistently expect code size to get smaller? Also, I'm curious if those code size reductions are still observed since we have now merged:
>
> * [[AArch64][BOLT] Ensure tentative code layout for cold BBs runs. #96609](https://github.com/llvm/llvm-project/pull/96609)
I don't think we have such expectation. Just something I've noticed.
https://github.com/llvm/llvm-project/pull/112110
More information about the llvm-commits
mailing list