This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [PATCH 6/7] [ARC] Prevent moving stores to the frame before the stack adjustment.
- From: Claudiu Zissulescu <Claudiu dot Zissulescu at synopsys dot com>
- To: Andrew Burgess <andrew dot burgess at embecosm dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, "Francois dot Bedard at synopsys dot com" <Francois dot Bedard at synopsys dot com>
- Date: Thu, 1 Jun 2017 08:30:11 +0000
- Subject: RE: [PATCH 6/7] [ARC] Prevent moving stores to the frame before the stack adjustment.
- Authentication-results: sourceware.org; auth=none
- References: <1495189862-20533-1-git-send-email-claziss@synopsys.com> <1495189862-20533-7-git-send-email-claziss@synopsys.com> <20170531163313.GI25719@embecosm.com>
> Given the description the code looks fine. It would be nice to see
> more of a _why_ in the commit message. I'm guessing this is either
> something related to signal handling, or debugging... I don't see why
> this would be needed for functional correctness.
>
The issue is how we generate a function prologue when we use fno-omit-frame-pointer, for example:
[snip]
mov_s fp,sp ; frame pointer is set here
[snip]
st r1,[fp,-24] ; frame pointer is used here
[snip]
sub_s sp,sp,0x20 ; stack pointer adjusted
So we can easily see that any interrupt between the `st` and `sub` instruction will lead to faulty code as the interrupt routine will use a faulty sp register, and, potentially, overwriting the value stored by 'st' instruction. Thus, adding a scheduler barrier will force the compiler to emit the `sub` instruction before the store one.
Thanks,
Claudiu