]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR debug/70628 (ICE in get_reg_rtx, at emit-rtl.c:1025)
authorJakub Jelinek <jakub@redhat.com>
Thu, 7 Jul 2016 12:39:40 +0000 (14:39 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 7 Jul 2016 12:39:40 +0000 (14:39 +0200)
Backported from mainline
2016-04-13  Jakub Jelinek  <jakub@redhat.com>

PR debug/70628
* explow.c (convert_memory_address_addr_space_1): Formatting fix.

PR debug/70628
* rtl.h (convert_memory_address_addr_space_1): New prototype.
* explow.c (convert_memory_address_addr_space_1): No longer static,
add NO_EMIT argument and don't call convert_modes if true, pass
it down recursively, remove break after return.
(convert_memory_address_addr_space): Adjust caller.
* simplify-rtx.c (simplify_unary_operation_1): Call
convert_memory_address_addr_space_1 instead of convert_memory_address,
if it returns NULL, don't simplify.

* gcc.dg/torture/pr70628.c: New test.

From-SVN: r238092

gcc/ChangeLog
gcc/explow.c
gcc/rtl.h
gcc/simplify-rtx.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr70628.c [new file with mode: 0644]

index df88c29d8d650f27244a6fbe12af4b33292fcb84..89f0cab5f30298153c4cb475eaf9c7746c5c499b 100644 (file)
@@ -1,6 +1,21 @@
 2016-07-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2016-04-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/70628
+       * explow.c (convert_memory_address_addr_space_1): Formatting fix.
+
+       PR debug/70628
+       * rtl.h (convert_memory_address_addr_space_1): New prototype.
+       * explow.c (convert_memory_address_addr_space_1): No longer static,
+       add NO_EMIT argument and don't call convert_modes if true, pass
+       it down recursively, remove break after return.
+       (convert_memory_address_addr_space): Adjust caller.
+       * simplify-rtx.c (simplify_unary_operation_1): Call
+       convert_memory_address_addr_space_1 instead of convert_memory_address,
+       if it returns NULL, don't simplify.
+
        2016-04-08  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/70574
index de446a903fd3dec8fcdc8f55673c538adfedeaa6..9c766e1f2e2c5c825517811dd25d17383f5b11e8 100644 (file)
@@ -281,12 +281,14 @@ break_out_memory_refs (rtx x)
    which way).  We take advantage of the fact that pointers are not allowed to
    overflow by commuting arithmetic operations over conversions so that address
    arithmetic insns can be used. IN_CONST is true if this conversion is inside
-   a CONST.  */
+   a CONST. NO_EMIT is true if no insns should be emitted, and instead
+   it should return NULL if it can't be simplified without emitting insns.  */
 
-static rtx
+rtx
 convert_memory_address_addr_space_1 (machine_mode to_mode ATTRIBUTE_UNUSED,
                                     rtx x, addr_space_t as ATTRIBUTE_UNUSED,
-                                    bool in_const ATTRIBUTE_UNUSED)
+                                    bool in_const ATTRIBUTE_UNUSED,
+                                    bool no_emit ATTRIBUTE_UNUSED)
 {
 #ifndef POINTERS_EXTEND_UNSIGNED
   gcc_assert (GET_MODE (x) == to_mode || GET_MODE (x) == VOIDmode);
@@ -332,19 +334,16 @@ convert_memory_address_addr_space_1 (machine_mode to_mode ATTRIBUTE_UNUSED,
       temp = gen_rtx_LABEL_REF (to_mode, LABEL_REF_LABEL (x));
       LABEL_REF_NONLOCAL_P (temp) = LABEL_REF_NONLOCAL_P (x);
       return temp;
-      break;
 
     case SYMBOL_REF:
       temp = shallow_copy_rtx (x);
       PUT_MODE (temp, to_mode);
       return temp;
-      break;
 
     case CONST:
-      return gen_rtx_CONST (to_mode,
-                           convert_memory_address_addr_space_1
-                             (to_mode, XEXP (x, 0), as, true));
-      break;
+      temp = convert_memory_address_addr_space_1 (to_mode, XEXP (x, 0), as,
+                                                 true, no_emit);
+      return temp ? gen_rtx_CONST (to_mode, temp) : temp;
 
     case PLUS:
     case MULT:
@@ -360,18 +359,25 @@ convert_memory_address_addr_space_1 (machine_mode to_mode ATTRIBUTE_UNUSED,
              && CONST_INT_P (XEXP (x, 1))
              && ((in_const && POINTERS_EXTEND_UNSIGNED != 0)
                  || XEXP (x, 1) == convert_memory_address_addr_space_1
-                                    (to_mode, XEXP (x, 1), as, in_const)
+                                    (to_mode, XEXP (x, 1), as, in_const,
+                                     no_emit)
                   || POINTERS_EXTEND_UNSIGNED < 0)))
-       return gen_rtx_fmt_ee (GET_CODE (x), to_mode,
-                              convert_memory_address_addr_space_1
-                                (to_mode, XEXP (x, 0), as, in_const),
-                              XEXP (x, 1));
+       {
+         temp = convert_memory_address_addr_space_1 (to_mode, XEXP (x, 0),
+                                                     as, in_const, no_emit);
+         return (temp ? gen_rtx_fmt_ee (GET_CODE (x), to_mode,
+                                        temp, XEXP (x, 1))
+                      : temp);
+       }
       break;
 
     default:
       break;
     }
 
+  if (no_emit)
+    return NULL_RTX;
+
   return convert_modes (to_mode, from_mode,
                        x, POINTERS_EXTEND_UNSIGNED);
 #endif /* defined(POINTERS_EXTEND_UNSIGNED) */
@@ -386,7 +392,7 @@ convert_memory_address_addr_space_1 (machine_mode to_mode ATTRIBUTE_UNUSED,
 rtx
 convert_memory_address_addr_space (machine_mode to_mode, rtx x, addr_space_t as)
 {
-  return convert_memory_address_addr_space_1 (to_mode, x, as, false);
+  return convert_memory_address_addr_space_1 (to_mode, x, as, false, false);
 }
 \f
 
index 22e50f36bedeb5dc03eb00e3bc47e44a22045bcf..fb216b6f7d14cc9c4e197a54d9c8f4772a908a74 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2609,6 +2609,8 @@ extern unsigned int subreg_highpart_offset (machine_mode,
                                            machine_mode);
 extern int byte_lowpart_offset (machine_mode, machine_mode);
 extern rtx make_safe_from (rtx, rtx);
+extern rtx convert_memory_address_addr_space_1 (machine_mode, rtx,
+                                               addr_space_t, bool, bool);
 extern rtx convert_memory_address_addr_space (machine_mode, rtx,
                                              addr_space_t);
 #define convert_memory_address(to_mode,x) \
index cdad71fa3f77a44595c22467bdc0daf8d3ecc060..c85ae3e1928b1bd9ffa362352ffae17222700313 100644 (file)
@@ -1438,7 +1438,14 @@ simplify_unary_operation_1 (enum rtx_code code, machine_mode mode, rtx op)
                  && REG_P (SUBREG_REG (op))
                  && REG_POINTER (SUBREG_REG (op))
                  && GET_MODE (SUBREG_REG (op)) == Pmode)))
-       return convert_memory_address (Pmode, op);
+       {
+         temp
+           = convert_memory_address_addr_space_1 (Pmode, op,
+                                                  ADDR_SPACE_GENERIC, false,
+                                                  true);
+         if (temp)
+           return temp;
+       }
 #endif
       break;
 
@@ -1559,7 +1566,14 @@ simplify_unary_operation_1 (enum rtx_code code, machine_mode mode, rtx op)
                  && REG_P (SUBREG_REG (op))
                  && REG_POINTER (SUBREG_REG (op))
                  && GET_MODE (SUBREG_REG (op)) == Pmode)))
-       return convert_memory_address (Pmode, op);
+       {
+         temp
+           = convert_memory_address_addr_space_1 (Pmode, op,
+                                                  ADDR_SPACE_GENERIC, false,
+                                                  true);
+         if (temp)
+           return temp;
+       }
 #endif
       break;
 
index e35c249c4f8df34d03b7502b6c1e080f8b1b3447..c71657fb11baee3c492b6c3787335b3ae0cb5192 100644 (file)
@@ -1,6 +1,11 @@
 2016-07-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2016-04-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/70628
+       * gcc.dg/torture/pr70628.c: New test.
+
        2016-04-08  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/70574
diff --git a/gcc/testsuite/gcc.dg/torture/pr70628.c b/gcc/testsuite/gcc.dg/torture/pr70628.c
new file mode 100644 (file)
index 0000000..00acae7
--- /dev/null
@@ -0,0 +1,46 @@
+/* PR debug/70628 */
+/* { dg-do compile } */
+/* { dg-options "-g -w" } */
+
+struct S { char s[64]; int *t; } *a;
+char b[64];
+int *foo (void);
+struct S *bar (int *);
+int baz (void);
+
+void
+test (const char *p, long q)
+{
+  int *c;
+  c = foo ();
+  while (a = bar (c))
+    {
+      if (__builtin_strstr (p, "ABCD")
+         || __builtin_strstr (p, "EFGHI")
+         || __builtin_strstr (p, "JKL")
+         || __builtin_strstr (p, "MNOPQR")
+         || __builtin_strstr (p, "STUV")
+         || __builtin_strstr (p, "WXYZabcd")
+         || __builtin_strstr (p, "efghij")
+         || __builtin_strstr (p, "klmno")
+         || __builtin_strstr (p, "pqrstuvw")
+         || __builtin_strstr (b, "MNOPQR") != "EFGHI"
+         || __builtin_strstr (b, "JKL"))
+       if (__builtin_strstr (a->s, "xyz12"))
+         continue;
+      __builtin_printf ("%p\n", a->t);
+    }
+  bar (c);
+  while (a)
+    if (__builtin_strstr (p, "ABCD")
+       || __builtin_strstr (p, "EFGHI")
+       || __builtin_strstr (p, "JKL")
+       || __builtin_strstr (p, "MNOPQR")
+       || __builtin_strstr (p, "STUV")
+       || __builtin_strstr (p, "WXYZabcd")
+       || __builtin_strstr (p, "efghij")
+       || __builtin_strstr (p, "klmno")
+       || __builtin_strstr (p, "pqrstuvw")
+       || __builtin_strstr ((const char *) q, "MNOPQR"))
+      baz ();
+}