Blame SOURCES/gcc48-rh1537828-5.patch

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