|
|
22033d |
commit 5fdcac79eb72406c59fa72073dfb3ba21380f56d
|
|
|
22033d |
Author: ktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
|
|
|
22033d |
Date: Tue Apr 10 09:58:57 2018 +0000
|
|
|
22033d |
|
|
|
22033d |
[explow] PR target/85173: validize memory before passing it on to target probe_stack
|
|
|
22033d |
|
|
|
22033d |
In this PR the expansion code emits an invalid memory address for the stack probe, which the backend fails to recognise.
|
|
|
22033d |
The address is created explicitly in anti_adjust_stack_and_probe_stack_clash in explow.c and passed down to gen_probe_stack
|
|
|
22033d |
without any validation in emit_stack_probe.
|
|
|
22033d |
|
|
|
22033d |
This patch fixes the ICE by calling validize_mem on the memory location before passing it down to the target.
|
|
|
22033d |
Jakub pointed out that we also want to create valid addresses for the probe_stack_address case, so this patch
|
|
|
22033d |
creates an expand operand and legitimizes it before passing it down to the probe_stack_address expander.
|
|
|
22033d |
|
|
|
22033d |
This patch passes bootstrap and testing on arm-none-linux-gnueabihf and aarch64-none-linux-gnu
|
|
|
22033d |
and ppc64le-redhat-linux on gcc112 in the compile farm.
|
|
|
22033d |
|
|
|
22033d |
PR target/85173
|
|
|
22033d |
* explow.c (emit_stack_probe): Call validize_mem on memory location
|
|
|
22033d |
before passing it to gen_probe_stack. Create address operand and
|
|
|
22033d |
legitimize it for the probe_stack_address case.
|
|
|
22033d |
|
|
|
22033d |
* gcc.target/arm/pr85173.c: New test.
|
|
|
22033d |
|
|
|
22033d |
|
|
|
22033d |
|
|
|
22033d |
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@259266 138bc75d-0d04-0410-961f-82ee72b054a4
|
|
|
22033d |
|
|
|
22033d |
diff --git a/gcc/explow.c b/gcc/explow.c
|
|
|
22033d |
index 9386489..e2253ae 100644
|
|
|
22033d |
--- a/gcc/explow.c
|
|
|
22033d |
+++ b/gcc/explow.c
|
|
|
22033d |
@@ -1549,13 +1549,20 @@ emit_stack_probe (rtx address)
|
|
|
22033d |
{
|
|
|
22033d |
#ifdef HAVE_probe_stack_address
|
|
|
22033d |
if (HAVE_probe_stack_address)
|
|
|
22033d |
- emit_insn (gen_probe_stack_address (address));
|
|
|
22033d |
+ {
|
|
|
22033d |
+ struct expand_operand ops[1];
|
|
|
22033d |
+ insn_code icode = targetm.code_for_probe_stack_address;
|
|
|
22033d |
+ create_address_operand (ops, address);
|
|
|
22033d |
+ maybe_legitimize_operands (icode, 0, 1, ops);
|
|
|
22033d |
+ expand_insn (icode, 1, ops);
|
|
|
22033d |
+ }
|
|
|
22033d |
else
|
|
|
22033d |
#endif
|
|
|
22033d |
{
|
|
|
22033d |
rtx memref = gen_rtx_MEM (word_mode, address);
|
|
|
22033d |
|
|
|
22033d |
MEM_VOLATILE_P (memref) = 1;
|
|
|
22033d |
+ memref = validize_mem (memref);
|
|
|
22033d |
|
|
|
22033d |
/* See if we have an insn to probe the stack. */
|
|
|
22033d |
#ifdef HAVE_probe_stack
|
|
|
22033d |
diff --git a/gcc/testsuite/gcc.target/arm/pr85173.c b/gcc/testsuite/gcc.target/arm/pr85173.c
|
|
|
22033d |
new file mode 100644
|
|
|
22033d |
index 0000000..36105c9
|
|
|
22033d |
--- /dev/null
|
|
|
22033d |
+++ b/gcc/testsuite/gcc.target/arm/pr85173.c
|
|
|
22033d |
@@ -0,0 +1,20 @@
|
|
|
22033d |
+/* PR target/85173. */
|
|
|
22033d |
+
|
|
|
22033d |
+/* { dg-do compile } */
|
|
|
22033d |
+/* { dg-options "-O2 -fstack-clash-protection --param stack-clash-protection-probe-interval=14" } */
|
|
|
22033d |
+/* { dg-require-effective-target arm_thumb2_ok } */
|
|
|
22033d |
+
|
|
|
22033d |
+__attribute__((noinline, noclone)) void
|
|
|
22033d |
+foo (char *p)
|
|
|
22033d |
+{
|
|
|
22033d |
+ asm volatile ("" : : "r" (p) : "memory");
|
|
|
22033d |
+}
|
|
|
22033d |
+
|
|
|
22033d |
+/* Nonconstant alloca, small local frame. */
|
|
|
22033d |
+__attribute__((noinline, noclone)) void
|
|
|
22033d |
+f5 (int x)
|
|
|
22033d |
+{
|
|
|
22033d |
+ char locals[128];
|
|
|
22033d |
+ char *vla = __builtin_alloca (x);
|
|
|
22033d |
+ foo (vla);
|
|
|
22033d |
+}
|