aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2021-04-16 12:38:01 +0100
committerRichard Sandiford <richard.sandiford@arm.com>2021-04-16 12:38:01 +0100
commitb4d6af55fe55c0eab87ab875bfd0346677e12236 (patch)
treec1bc27d7b5157e117320030c3c35573bfa31fe1e /gcc/builtins.c
parent69e7f04ff677d5e402f937b23422567c10243ee9 (diff)
downloadgcc-b4d6af55fe55c0eab87ab875bfd0346677e12236.zip
gcc-b4d6af55fe55c0eab87ab875bfd0346677e12236.tar.gz
gcc-b4d6af55fe55c0eab87ab875bfd0346677e12236.tar.bz2
rtlanal: Don't assume that calls write to a global SP [PR99596]
This patch is a GCC 11 regression caused by the rtl-ssa code. Normally we treat calls as containing a potential set of a global register, but DF makes a sensible exception for the stack pointer: if (i == STACK_POINTER_REGNUM) /* The stack ptr is used (honorarily) by a CALL insn. */ df_ref_record (DF_REF_BASE, collection_rec, regno_reg_rtx[i], NULL, bb, insn_info, DF_REF_REG_USE, DF_REF_CALL_STACK_USAGE | flags); else if (global_regs[i]) { /* Calls to const functions cannot access any global registers and calls to pure functions cannot set them. All other calls may reference any of the global registers, so they are recorded as used. */ The only DF definition of SP was therefore the one in the entry block. However, the rtlanal.c rtx_properties code (wrongly) assumed that calls also clobbered the global SP. This led to multiple definitions of SP when we only expected one. This patch tightens the rtlanal.c handling of global registers to match the DF approach. gcc/ PR rtl-optimization/99596 * rtlanal.c (rtx_properties::try_to_add_insn): Don't add global register accesses for const calls. Assume that pure functions can only read from global registers. Ignore cases in which the stack pointer has been marked global. gcc/testsuite/ PR rtl-optimization/99596 * gcc.target/arm/pr99596.c: New test.
Diffstat (limited to 'gcc/builtins.c')
0 files changed, 0 insertions, 0 deletions