Blame SOURCES/gcc48-rh1537828-5.patch

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