diff mbox

[AArch64] Fix PR63293

Message ID 541C2CFD.9040407@arm.com
State New
Headers show

Commit Message

Jiong Wang Sept. 19, 2014, 1:17 p.m. UTC
when generating instructions to access local variable, for example a local array,

if the array size very big, then we need a temp reg to keep the intermediate index,
then use that temp reg as base reg, so that ldr is capable of indexing the element.

while this will cause trouble, because the introduce of temp reg break the dependence
between the stack variable access and stack adjustment instructions which is unsafe
when signal trampoline executed.

this patch add barrier before stack adjustment in epilogue.

ok for trunk?

thanks.

gcc/
   * gcc/config/aarch64.c (aarch64_expand_epilogue): Add barrier before stack adjustment.

-- Jiong

Comments

Wilco Sept. 19, 2014, 2:35 p.m. UTC | #1
> Jiong Wang wrote:
> 
> when generating instructions to access local variable, for example a local array,
> 
> if the array size very big, then we need a temp reg to keep the intermediate index,
> then use that temp reg as base reg, so that ldr is capable of indexing the element.
> 
> while this will cause trouble, because the introduce of temp reg break the dependence
> between the stack variable access and stack adjustment instructions which is unsafe
> when signal trampoline executed.
> 
> this patch add barrier before stack adjustment in epilogue.
> 
> ok for trunk?

I believe you need more barriers. Ie. for all SP modifying instructions (including ldp
with writeback) except for ones that just remove the outgoing arguments. You can avoid
emitting barriers if alloca is not used and there are no locals in the frame (common case).

Basically without that any memory access that may alias with the locals could be
scheduled incorrectly. It seems odd that the scheduler does not understand this by 
default.

Wilco
diff mbox

Patch

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 023f9fd..8eed9cf 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -2431,6 +2431,8 @@  aarch64_expand_epilogue (bool for_sibcall)

   if (frame_size > 0)
     {
+      emit_insn (gen_stack_tie (stack_pointer_rtx, stack_pointer_rtx));
+
       if (frame_size >= 0x1000000)
 	{
 	  rtx op0 = gen_rtx_REG (Pmode, IP0_REGNUM);