This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, rs6000] Avoid clobbering stack pointer via P8 fusion peephole
- From: David Edelsohn <dje dot gcc at gmail dot com>
- To: Ulrich Weigand <uweigand at de dot ibm dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Michael Meissner <meissner at linux dot vnet dot ibm dot com>, "William J. Schmidt" <wschmidt at linux dot vnet dot ibm dot com>
- Date: Thu, 27 Mar 2014 17:33:00 -0400
- Subject: Re: [PATCH, rs6000] Avoid clobbering stack pointer via P8 fusion peephole
- Authentication-results: sourceware.org; auth=none
- References: <201403271849 dot s2RIn7hS028947 at d03av02 dot boulder dot ibm dot com>
On Thu, Mar 27, 2014 at 2:49 PM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
> Hello,
>
> when trying to build Ada for powerpc64le-linux, I ran into an ICE
> in fixup_args_size_notes.
>
> It turns out that the p8 fusion peephole acts on these two insns
> from the epilog sequence:
>
> (insn 1693 1078 1079 91 (set (reg:DI 7 7)
> (plus:DI (reg/f:DI 31 31)
> (const_int 65536 [0x10000]))) 82 {*adddi3_internal1}
> (nil))
> (insn 1079 1693 1511 91 (set (reg/f:DI 1 1)
> (mem/c:DI (plus:DI (reg:DI 7 7)
> (const_int -16096 [0xffffffffffffc120])) [233 %sfp+49440 S8 A64])) 519 {*movdi_internal64}
> (expr_list:REG_DEAD (reg:DI 7 7)
> (expr_list:REG_ARGS_SIZE (const_int 0 [0])
> (nil))))
>
> and replaces them by:
>
> (insn 1776 1078 1777 91 (set (reg/f:DI 1 1)
> (plus:DI (reg/f:DI 31 31)
> (const_int 65536 [0x10000]))) -1
> (nil))
>
> (insn 1777 1776 1511 91 (set (reg/f:DI 1 1)
> (mem/c:DI (plus:DI (reg/f:DI 1 1)
> (const_int -16096 [0xffffffffffffc120])) [233 S8 A8])) -1
> (expr_list:REG_ARGS_SIZE (const_int 0 [0])
> (nil)))
>
> Then peephole common code thinks it needs to re-create the REG_ARGS_SIZE
> note and fails since the code is too complex for it to understand. (Which
> is reasonable since it doesn't know what value is being restored from the
> stack here.)
>
> However, the more fundamental problem seems to be that this transformation
> should be invalid anyway, since it creates an intermediate state where
> the stack pointer points to a location without proper backchain, which
> violates the ABI.
>
> The following patch fixes this by disabling the fusion peephole in those
> cases where it would introduce a new use of the stack pointer as temporary
> register.
>
> Tested on powerpc64le-linux. OK for mainline (and 4.8 after the big patch
> series is committed)?
>
> Bye,
> Ulrich
>
> ChangeLog:
>
> * config/rs6000/rs6000.c (fusion_gpr_load_p): Refuse optimization
> if it would clobber the stack pointer, even temporarily.
Okay.
Thanks, David