Blame SOURCES/gcc48-rh1469697-7.patch

56d343
commit 2bb044f9734259945e2b5048d92bc8d0af707d27
56d343
Author: law <law@138bc75d-0d04-0410-961f-82ee72b054a4>
56d343
Date:   Wed Sep 20 05:43:28 2017 +0000
56d343
56d343
            * combine-stack-adj.c (combine_stack_adjustments_for_block): Do
56d343
            nothing for stack adjustments with REG_STACK_CHECK.
56d343
            * sched-deps.c (parse_add_or_inc): Reject insns with
56d343
            REG_STACK_CHECK from dependency breaking.
56d343
            * config/i386/i386.c (pro_epilogue_adjust_stack): Return insn.
56d343
            (ix86_adjust_satck_and_probe_stack_clash): Add REG_STACK_NOTEs.
56d343
            * reg-notes.def (STACK_CHECK): New note.
56d343
    
56d343
            * gcc.target/i386/stack-check-11.c: New test.
56d343
    
56d343
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@252999 138bc75d-0d04-0410-961f-82ee72b054a4
56d343
56d343
diff --git a/gcc/combine-stack-adj.c b/gcc/combine-stack-adj.c
56d343
index 0a4d8a51d1d..ee66c28ca35 100644
56d343
--- a/gcc/combine-stack-adj.c
56d343
+++ b/gcc/combine-stack-adj.c
56d343
@@ -441,6 +441,8 @@ combine_stack_adjustments_for_block (basic_block bb)
56d343
 	continue;
56d343
 
56d343
       set = single_set_for_csa (insn);
56d343
+      if (set && find_reg_note (insn, REG_STACK_CHECK, NULL_RTX))
56d343
+	set = NULL_RTX;
56d343
       if (set)
56d343
 	{
56d343
 	  rtx dest = SET_DEST (set);
56d343
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
56d343
index a07104d304d..a9072f58f50 100644
56d343
--- a/gcc/config/i386/i386.c
56d343
+++ b/gcc/config/i386/i386.c
56d343
@@ -9502,7 +9502,7 @@ ix86_add_queued_cfa_restore_notes (rtx insn)
56d343
    zero if %r11 register is live and cannot be freely used and positive
56d343
    otherwise.  */
56d343
 
56d343
-static void
56d343
+static rtx
56d343
 pro_epilogue_adjust_stack (rtx dest, rtx src, rtx offset,
56d343
 			   int style, bool set_cfa)
56d343
 {
56d343
@@ -9589,6 +9589,7 @@ pro_epilogue_adjust_stack (rtx dest, rtx src, rtx offset,
56d343
       m->fs.sp_offset = ooffset - INTVAL (offset);
56d343
       m->fs.sp_valid = valid;
56d343
     }
56d343
+  return insn;
56d343
 }
56d343
 
56d343
 /* Find an available register to be used as dynamic realign argument
56d343
@@ -9902,9 +9903,11 @@ ix86_adjust_stack_and_probe_stack_clash (const HOST_WIDE_INT size)
56d343
       for (i = probe_interval; i <= size; i += probe_interval)
56d343
 	{
56d343
 	  /* Allocate PROBE_INTERVAL bytes.  */
56d343
-	  pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx,
56d343
-				     GEN_INT (-probe_interval), -1,
56d343
-				     m->fs.cfa_reg == stack_pointer_rtx);
56d343
+	  rtx insn
56d343
+	    = pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx,
56d343
+					 GEN_INT (-PROBE_INTERVAL), -1,
56d343
+					 m->fs.cfa_reg == stack_pointer_rtx);
56d343
+	  add_reg_note (insn, REG_STACK_CHECK, const0_rtx);
56d343
 
56d343
 	  /* And probe at *sp.  */
56d343
 	  emit_stack_probe (stack_pointer_rtx);
56d343
diff --git a/gcc/reg-notes.def b/gcc/reg-notes.def
56d343
index db61c092aab..1d7a4356a85 100644
56d343
--- a/gcc/reg-notes.def
56d343
+++ b/gcc/reg-notes.def
56d343
@@ -216,3 +216,7 @@ REG_NOTE (ARGS_SIZE)
56d343
    that the return value of a call can be used to reinitialize a
56d343
    pseudo reg.  */
56d343
 REG_NOTE (RETURNED)
56d343
+
56d343
+/* Indicates the instruction is a stack check probe that should not
56d343
+   be combined with other stack adjustments.  */
56d343
+REG_NOTE (STACK_CHECK)
56d343
diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c
56d343
index 4ac2542a3af..75780150e34 100644
56d343
--- a/gcc/sched-deps.c
56d343
+++ b/gcc/sched-deps.c
56d343
@@ -4607,6 +4607,11 @@ parse_add_or_inc (struct mem_inc_info *mii, rtx insn, bool before_mem)
56d343
   if (RTX_FRAME_RELATED_P (insn) || !pat)
56d343
     return false;
56d343
 
56d343
+  /* Do not allow breaking data dependencies for insns that are marked
56d343
+     with REG_STACK_CHECK.  */
56d343
+  if (find_reg_note (insn, REG_STACK_CHECK, NULL))
56d343
+    return false;
56d343
+
56d343
   /* Result must be single reg.  */
56d343
   if (!REG_P (SET_DEST (pat)))
56d343
     return false;
56d343
diff --git a/gcc/testsuite/gcc.target/i386/stack-check-11.c b/gcc/testsuite/gcc.target/i386/stack-check-11.c
56d343
new file mode 100644
56d343
index 00000000000..183103f01e5
56d343
--- /dev/null
56d343
+++ b/gcc/testsuite/gcc.target/i386/stack-check-11.c
56d343
@@ -0,0 +1,16 @@
56d343
+/* { dg-do compile } */
56d343
+/* { dg-options "-O2 -fstack-clash-protection" } */
56d343
+/* { dg-require-effective-target supports_stack_clash_protection } */
56d343
+
56d343
+extern void arf (unsigned long int *, unsigned long int *);
56d343
+void
56d343
+frob ()
56d343
+{
56d343
+  unsigned long int num[859];
56d343
+  unsigned long int den[859];
56d343
+  arf (den, num);
56d343
+}
56d343
+
56d343
+/* { dg-final { scan-assembler-times "subq" 4 } } */
56d343
+/* { dg-final { scan-assembler-times "orq" 3 } } */
56d343
+