Blame SOURCES/gcc48-pr63293.patch

25c7f1
2014-11-04  Jiong Wang  <jiong.wang@arm.com>
25c7f1
	    Wilco Dijkstra  <wilco.dijkstra@arm.com>
25c7f1
25c7f1
	PR target/63293
25c7f1
	* config/aarch64/aarch64.c (aarch64_expand_epiloue): Add barriers before
25c7f1
	stack adjustment.
25c7f1
25c7f1
--- gcc/config/aarch64/aarch64.c	(revision 217090)
25c7f1
+++ gcc/config/aarch64/aarch64.c	(revision 217091)
25c7f1
@@ -1989,6 +1989,9 @@ aarch64_expand_epilogue (bool for_sibcal
25c7f1
   rtx insn;
25c7f1
   rtx cfa_reg;
25c7f1
   rtx cfi_ops = NULL;
25c7f1
+  /* We need to add memory barrier to prevent read from deallocated stack.  */
25c7f1
+  bool need_barrier_p = (get_frame_size () != 0
25c7f1
+			 || cfun->machine->saved_varargs_size);
25c7f1
 
25c7f1
   aarch64_layout_frame ();
25c7f1
   original_frame_size = get_frame_size () + cfun->machine->saved_varargs_size;
25c7f1
@@ -2030,6 +2033,9 @@ aarch64_expand_epilogue (bool for_sibcal
25c7f1
   if (frame_pointer_needed
25c7f1
       && (crtl->outgoing_args_size || cfun->calls_alloca))
25c7f1
     {
25c7f1
+      if (cfun->calls_alloca)
25c7f1
+	emit_insn (gen_stack_tie (stack_pointer_rtx, stack_pointer_rtx));
25c7f1
+
25c7f1
       insn = emit_insn (gen_add3_insn (stack_pointer_rtx,
25c7f1
 				       hard_frame_pointer_rtx,
25c7f1
 				       GEN_INT (- fp_offset)));
25c7f1
@@ -2048,6 +2054,9 @@ aarch64_expand_epilogue (bool for_sibcal
25c7f1
   /* Restore the frame pointer and lr if the frame pointer is needed.  */
25c7f1
   if (offset > 0)
25c7f1
     {
25c7f1
+      if (need_barrier_p && (!frame_pointer_needed || !fp_offset))
25c7f1
+	emit_insn (gen_stack_tie (stack_pointer_rtx, stack_pointer_rtx));
25c7f1
+
25c7f1
       if (frame_pointer_needed)
25c7f1
 	{
25c7f1
 	  rtx mem_fp, mem_lr;
25c7f1
@@ -2067,6 +2076,10 @@ aarch64_expand_epilogue (bool for_sibcal
25c7f1
 						     + UNITS_PER_WORD));
25c7f1
 	      emit_insn (gen_load_pairdi (reg_fp, mem_fp, reg_lr, mem_lr));
25c7f1
 
25c7f1
+	      if (need_barrier_p)
25c7f1
+		emit_insn (gen_stack_tie (stack_pointer_rtx,
25c7f1
+					  stack_pointer_rtx));
25c7f1
+
25c7f1
 	      insn = emit_insn (gen_add2_insn (stack_pointer_rtx,
25c7f1
 					       GEN_INT (offset)));
25c7f1
 	    }
25c7f1
@@ -2128,6 +2141,9 @@ aarch64_expand_epilogue (bool for_sibcal
25c7f1
 
25c7f1
   if (frame_size > -1)
25c7f1
     {
25c7f1
+      if (need_barrier_p)
25c7f1
+	emit_insn (gen_stack_tie (stack_pointer_rtx, stack_pointer_rtx));
25c7f1
+
25c7f1
       if (frame_size >= 0x1000000)
25c7f1
 	{
25c7f1
 	  rtx op0 = gen_rtx_REG (Pmode, IP0_REGNUM);