Blame SOURCES/gcc48-pr63293.patch

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