]> git.ipfire.org Git - thirdparty/gcc.git/commit
arm: prevent impossible tail- long-calls with static chain [PR119430]
authorAlexandre Oliva <oliva@gnu.org>
Fri, 11 Jul 2025 01:21:31 +0000 (22:21 -0300)
committerRichard Earnshaw <rearnsha@arm.com>
Fri, 9 Jan 2026 14:32:00 +0000 (14:32 +0000)
commitf5166f5badb190eec5d3707fe25ad33febf1969e
tree08bb93348af9a8014b7c2b64362171a5c00a098d
parenta40666202d19f2b7dd1290e1c2b0d5e2a010335e
arm: prevent impossible tail- long-calls with static chain [PR119430]

When a function call uses up all argument registers, and needs IP for
the static chain, there aren't any call-clobbered registers left for
reload to assign as the sibcall target, when -mlong-calls is enabled.
Use the same logic that does the job for indirect calls to prevent
tail calls in this case.

With this change, it is possible to bootstrap armv7a-linux-gnu with
both -O3 and lto, but only with both -mlong-calls and
-ffunction-sections.

Without -mlong-calls, linker veneer thunks may clobber the static
chain register set up by callers in one lto unit, preventing them from
reaching the callee in a separate lto unit.  -ffunction-sections is
required for -mlong-calls to be effective, because both caller and
callee are in the same section, and that disables long-calls when
!flag_reorder_blocks_and_partition.

gcc/ChangeLog

PR target/119430
* config/arm/arm.cc (arm_function_ok_for_sibcall): Disable
sibcalls for long-calls that use all call-clobbered
general-purpose registers, including the static chain.
gcc/config/arm/arm.cc