[PATCH, middle-end/82577] Fix DECL_ASSEMBLER_NAME ICE
authorNathan Sidwell <nathan@acm.org>
Tue, 17 Oct 2017 15:42:19 +0000 (15:42 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 17 Oct 2017 15:42:19 +0000 (15:42 +0000)
https://gcc.gnu.org/ml/gcc-patches/2017-10/msg01067.html
gcc/
PR middle-end/82577
* alias.c (compare_base_decls): Check HAS_DECL_ASSEMBLER_NAME_P,
use DECL_ASSEMBLER_NAME_RAW.

gcc/testsuite/
PR middle-end/82577
* g++.dg/opt/pr82577.C: New.

From-SVN: r253819

gcc/ChangeLog
gcc/alias.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr82577.C [new file with mode: 0644]

index 02d8e313d287173f972edf8a118ba6ec13a33df7..14f0d01613c1db1963f594077dd65ffa84cc7f5e 100644 (file)
@@ -1,5 +1,9 @@
 2017-10-17  Nathan Sidwell  <nathan@acm.org>
 
+       PR middle-end/82577
+       * alias.c (compare_base_decls): Check HAS_DECL_ASSEMBLER_NAME_P,
+       use DECL_ASSEMBLER_NAME_RAW.
+
        PR middle-end/82546
        * tree.c (tree_code_size): Reformat.  Punt to lang hook for unknown
        TYPE nodes.
index e4865729a9b5685488cca5f516789b44b04d0a71..cb57c6a10ff125a128110e06822d6ff6bb4a37fe 100644 (file)
@@ -2047,13 +2047,15 @@ compare_base_decls (tree base1, tree base2)
     return 1;
 
   /* If we have two register decls with register specification we
-     cannot decide unless their assembler name is the same.  */
+     cannot decide unless their assembler names are the same.  */
   if (DECL_REGISTER (base1)
       && DECL_REGISTER (base2)
+      && HAS_DECL_ASSEMBLER_NAME_P (base1)
+      && HAS_DECL_ASSEMBLER_NAME_P (base2)
       && DECL_ASSEMBLER_NAME_SET_P (base1)
       && DECL_ASSEMBLER_NAME_SET_P (base2))
     {
-      if (DECL_ASSEMBLER_NAME (base1) == DECL_ASSEMBLER_NAME (base2))
+      if (DECL_ASSEMBLER_NAME_RAW (base1) == DECL_ASSEMBLER_NAME_RAW (base2))
        return 1;
       return -1;
     }
index bf9f4f3e3f0a399b57f4a9de35fbb29bced6083f..694c23bd1712f7340953f8312597f2304e410dda 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-17  Nathan Sidwell  <nathan@acm.org>
+
+       PR middle-end/82577
+       * g++.dg/opt/pr82577.C: New.
+
 2017-10-17  Qing Zhao <qing.zhao@oracle.com>
            Wilco Dijkstra <wilco.dijkstra@arm.com>
 
diff --git a/gcc/testsuite/g++.dg/opt/pr82577.C b/gcc/testsuite/g++.dg/opt/pr82577.C
new file mode 100644 (file)
index 0000000..73ae0f5
--- /dev/null
@@ -0,0 +1,17 @@
+// { dg-additional-options "-O2" }
+// PR c++/82577 ICE when optimizing
+
+class a {
+public:
+  int *b();
+};
+struct c {
+  int d;
+  a e;
+} f;
+void fn1(register c *g) {
+  register int *h;
+  do
+    (h) = g->e.b() + (g)->d;
+  while (&f);
+}