]> git.ipfire.org Git - thirdparty/gcc.git/commit
[ARC] Prevent moving stores to the frame before the stack adjustment.
authorclaziss <claziss@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 1 Jun 2017 09:42:49 +0000 (09:42 +0000)
committerclaziss <claziss@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 1 Jun 2017 09:42:49 +0000 (09:42 +0000)
commit225071eccc2a8c89e5c9309752d6f7ff069f8db9
tree88daa1be2a4a806cb29bc537e8228e901f7240ba
parent42cf27d38ce0d11ec9787f153acddb47057ccfc2
[ARC] Prevent moving stores to the frame before the stack adjustment.

If the stack pointer is needed, emit a special barrier that will prevent
the scheduler from moving stores to the frame before the stack adjustment.

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.

2017-06-01  Claudiu Zissulescu  <claziss@synopsys.com>

* config/arc/arc.c (arc_expand_prologue): Emit a special barrier
to prevent store reordering.
* config/arc/arc.md (UNSPEC_ARC_STKTIE): Define.
(type): Add block type.
(stack_tie): Define special instruction to be used in
expand_prologue.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@248781 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/config/arc/arc.c
gcc/config/arc/arc.md