[clang] [llvm] [AArch64] Add support for -mlong-calls code generation (PR #142982)

dong jianqiang via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 5 09:07:57 PDT 2025


dongjianqiang2 wrote:

> My understanding is that this will make all calls to global functions into long calls.
> 
> In AArch64 static linkes are required to insert range extension thunks for out of range BLs. In the best case this is just another direct branch, at worst case for `--pic-veneer` this is just `adrp, add, br`. I would expect that on-demand linker inserted thunks would outperform making all calls long for the majority of programs. I'm interested in any data that shows that long calls works better, and whether that could feed back into the lld thunk generation code. For example are the thunks too far away from the caller which causes page faults etc.
> 
> I note that with `-ffunction-sections` and certain linker options calls to static functions can go out of range too. These would get handled by linker thunks though.

This option is explicitly designed to ‌enable reliable patching workflows‌ when compiling object files. It is to guarantee call range safety in patches‌. When modifying/recompiling ‌individual object files‌ (e.g., during security patches),final memory layouts are ‌unknown at compile time‌, patched functions might end up >128MB away from callers. -mlong-calls forces all cross-object calls to use ‌64-bit absolute addressing‌.

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


More information about the llvm-commits mailing list