Blame SOURCES/gcc48-rh1537828-5.patch

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