[Bug target/88167] [7/8/9 regression] [ARM] Function __builtin_return_address returns invalid address
rearnsha at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Oct 25 14:39:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88167
--- Comment #6 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
Author: rearnsha
Date: Fri Oct 25 14:39:06 2019
New Revision: 277454
URL: https://gcc.gnu.org/viewcvs?rev=277454&root=gcc&view=rev
Log:
[arm][PR88167] Fix __builtin_return_address returns invalid address
This patch fixes a problem with the thumb1 prologue code where the link
register could be unconditionally used as a scratch register even if the
return value was still live at the end of the prologue.
Additionally, the patch improves the code generated when we are not
using many low call-saved registers to make use of any unused call
clobbered registers to help with the saving of high registers that
cannot be pushed directly (quite rare in normal code as the register
allocator correctly prefers low registers).
2019-05-08 Mihail Ionescu <mihail.ionescu@arm.com>
Richard Earnshaw <rearnsha@arm.com>
gcc:
PR target/88167
* config/arm/arm.c (thumb1_prologue_unused_call_clobbered_lo_regs): New
function.
(thumb1_epilogue_unused_call_clobbered_lo_regs): New function.
(thumb1_compute_save_core_reg_mask): Don't force a spare work
register if both the epilogue and prologue can use call-clobbered
regs.
(thumb1_unexpanded_epilogue): Use
thumb1_epilogue_unused_call_clobbered_lo_regs. Reverse the logic for
picking temporaries for restoring high regs to match that of the
prologue where possible.
(thumb1_expand_prologue): Add any usable call-clobbered low registers
to
the list of work registers. Detect if the return address is still live
at the end of the prologue and avoid using it for a work register if
so.
If the return address is not live, add LR to the list of pushable regs
after the first pass.
gcc/testsuite:
PR target/88167
* gcc.target/arm/pr88167-1.c: New test.
* gcc.target/arm/pr88167-2.c: New test.
Added:
branches/gcc-7-branch/gcc/testsuite/gcc.target/arm/pr88167-1.c
branches/gcc-7-branch/gcc/testsuite/gcc.target/arm/pr88167-2.c
Modified:
branches/gcc-7-branch/gcc/ChangeLog
branches/gcc-7-branch/gcc/config/arm/arm.c
branches/gcc-7-branch/gcc/testsuite/ChangeLog
More information about the Gcc-bugs
mailing list