[ARM] Fix register r3 wrongly used to save ip in nested APCS frame
Eric Botcazou
ebotcazou@adacore.com
Thu Sep 5 14:09:00 GMT 2013
Hi,
in case the ip register needs to be saved before establishing an APCS frame,
i.e. when it is used as the static chain register, the prologue tries various
tricks in the following order:
1. The last argument register r3.
2. A slot on the stack above the frame. (This only
works if the function is not a varargs function).
3. Register r3 again, after pushing the argument registers
onto the stack.
#3 doesn't really work since its implementation reads:
{
/* Store the args on the stack. */
if (cfun->machine->uses_anonymous_args)
insn = emit_multi_reg_push
((0xf0 >> (args_to_push / 4)) & 0xf);
else
insn = emit_insn
(gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
GEN_INT (- args_to_push)));
RTX_FRAME_RELATED_P (insn) = 1;
saved_pretend_args = 1;
fp_offset = args_to_push;
args_to_push = 0;
/* Now reuse r3 to preserve IP. */
emit_set_insn (gen_rtx_REG (SImode, 3), ip_rtx);
}
It works only if cfun->machine->uses_anonymous_args is true, because in this
case r3 is pushed onto the stack as part of the multi-reg push. Otherwise,
the contents of r3 are simply overwritten by the last line.
Fixed by saving ip on the stack in this latter case, using one of the slots to
be used by the pushed arguments. This eliminates the last ACATS failures on
ARM/VxWorks. OK for the mainline?
2013-09-05 Eric Botcazou <ebotcazou@adacore.com>
* config/arm/arm.c (arm_expand_prologue): In a nested APCS frame with
arguments to push onto the stack and no varargs, save ip into a stack
slot if r3 isn't available on entry.
--
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-patch
Size: 2453 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20130905/c8292831/attachment.bin>
More information about the Gcc-patches
mailing list