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