This is the mail archive of the
mailing list for the GCC project.
RE: [PATCH] Fix stack red zone bug (PR38644)
- From: "Jiangning Liu" <jiangning dot liu at arm dot com>
- To: "'Richard Henderson'" <rth at redhat dot com>
- Cc: "'Jakub Jelinek'" <jakub at redhat dot com>, "'Richard Guenther'" <richard dot guenther at gmail dot com>, "Andrew Pinski" <pinskia at gmail dot com>, <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 9 Oct 2011 16:11:52 +0800
- Subject: RE: [PATCH] Fix stack red zone bug (PR38644)
- References: <CAFiYyc0gH=RMdLrOd0uXHrffesN3CL3G+2qGERECi6UVpwtMXg@mail.gmail.com> <4e827d57.83c5e30a.4985.3501SMTPIN_ADDED@mx.google.com> <CAFiYyc3J_trr5cWXaJdL2ukdT3ouRkMAYV9EXOyqfgDLnncJDQ@mail.gmail.com> <4e82e494.54cee30a.18a4.ffff94c3SMTPIN_ADDED@mx.google.com> <CAFiYyc3h5ps42N70QVN1PW58BwV9DhzZsme=nGnY76SO1MmPYg@mail.gmail.com> <4e82eba7.d3c7e30a.57a3.ffffa1c9SMTPIN_ADDED@mx.google.com> <CAFiYyc0N0hhxWwUt_sYF12TggmSZvC-S8bCtQHs_3-QBrsi6UA@mail.gmail.com> <4e83e254.8fcae30a.7f90.1ca2SMTPIN_ADDED@mx.google.com> <CAFiYyc3BePLLBv38Do9bcGdKVd4DV4Y=vcPKHxGNpKD33m4EUg@mail.gmail.com> <000401cc7e8f$cc1bf870$6453e950$@firstname.lastname@example.org> <20110929101332.GR2687@tyan-ft48-01.lab.bos.redhat.com> <000501cc7f0e$2b28b6e0$817a24a0$@email@example.com> <4E8612DD.firstname.lastname@example.org>
> -----Original Message-----
> From: Richard Henderson [mailto:email@example.com]
> Sent: Saturday, October 01, 2011 3:05 AM
> To: Jiangning Liu
> Cc: 'Jakub Jelinek'; 'Richard Guenther'; Andrew Pinski; gcc-
> Subject: Re: [PATCH] Fix stack red zone bug (PR38644)
> On 09/29/2011 06:13 PM, Jiangning Liu wrote:
> >> -----Original Message-----
> >> From: Jakub Jelinek [mailto:firstname.lastname@example.org]
> >> Sent: Thursday, September 29, 2011 6:14 PM
> >> To: Jiangning Liu
> >> Cc: 'Richard Guenther'; Andrew Pinski; email@example.com
> >> Subject: Re: [PATCH] Fix stack red zone bug (PR38644)
> >> On Thu, Sep 29, 2011 at 06:08:50PM +0800, Jiangning Liu wrote:
> >>> As far as I know different back-ends are implementing different
> >>> prologue/epilogue in GCC. If one day this part can be refined and
> >> abstracted
> >>> as well, I would say solving this stack-red-zone problem in shared
> >>> prologue/epilogue code would be a perfect solution, and barrier can
> >> be
> >>> inserted there.
> >>> I'm not saying you are wrong on keeping scheduler using a pure
> >> barrier
> >>> interface. From engineering point of view, I only feel my proposal
> >> so far
> >>> so good, because this patch at least solve the problem for all
> >> targets in a
> >>> quite simple way. Maybe it can be improved in future based on this.
> >> But you don't want to listen about any other alternative, other
> >> backends are
> >> happy with being able to put the best kind of barrier at the best
> >> in the epilogue and don't need a "generic" solution which won't
> >> very
> >> well the target diversity anyway.
> > Jakub,
> > Appreciate for your attention on this issue,
> > 1) Can you clarify who are the "others back-ends"? Does it cover most
> of the
> > back-ends being supported by GCC right now?
> Your red-stack barrier issue is *exactly* the same as the frame pointer
> barrier issue, which affects many backends.
> That is, if the frame pointer is initialized before the local stack
> is allocated, then one has to add a barrier such that memory references
> based on the frame pointer are not scheduled before the local stack
> One example of this is in the i386 port, where the prologue looks like
> push %ebp
> mov %esp, %ebp
> sub $frame, %esp
> The rtl we emit for that subtraction looks like
> (define_insn "pro_epilogue_adjust_stack_<mode>_add"
> [(set (match_operand:P 0 "register_operand" "=r,r")
> (plus:P (match_operand:P 1 "register_operand" "0,r")
> (match_operand:P 2 "<nonmemory_operand>" "r<i>,l<i>")))
> (clobber (reg:CC FLAGS_REG))
> (clobber (mem:BLK (scratch)))]
> Note the final clobber, which is a memory scheduling barrier.
> Other targets use similar tricks. For instance arm "stack_tie".
> Honestly, I've found nothing convincing throughout this thread that
> suggests to me that this problem should be handled generically.
Thanks for your explanation by giving an example in x86.
The key is if possible, fixing it in middle end can benefit all ports
directly and avoid bug fixing burden in back-ends, rather than fix this
problem port by port.
Actually now the debating here is whether memory barrier is properly
modeling through whole GCC rather than a single component, because my
current understanding is scheduler is not the only component using memory