Blame SOURCES/gcc48-rh1537828-5.patch

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