https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93786

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Tried:
--- gcc/gimplify.c.jj   2020-02-09 08:16:19.399581468 +0100
+++ gcc/gimplify.c      2020-02-25 13:46:51.166409528 +0100
@@ -886,7 +886,29 @@ mostly_copy_tree_r (tree *tp, int *walk_

   /* Cope with the statement expression extension.  */
   else if (code == STATEMENT_LIST)
-    ;
+    {
+      if (!TREE_SIDE_EFFECTS (t))
+       {
+         tree nt = NULL_TREE;
+          tree_stmt_iterator i;
+         /* With -g we can get STATEMENT_LISTs without side-effects
+            that contain some debug stmts and exactly one other stmt.
+            "unshare" those by extracting the single other stmt in the
+            copy.  */
+         for (i = tsi_start (t); !tsi_end_p (i); tsi_next (&i))
+           if (TREE_CODE (tsi_stmt (i)) == DEBUG_BEGIN_STMT)
+             ;
+           else if (nt)
+             break;
+           else
+             nt = tsi_stmt (i);
+         if (nt && tsi_end_p (i) && TREE_TYPE (t) == TREE_TYPE (nt))
+           {
+             *tp = nt;
+             mostly_copy_tree_r (tp, walk_subtrees, data);
+           }
+       }
+    }

   /* Leave the bulk of the work to copy_tree_r itself.  */
   else
and while we don't ICE anymore on the testcase, it FAILs with -fcompare-debug:
-  _1 = s->_vptr.S;
+  struct S * retval.0;
+
+  # DEBUG BEGIN_STMT
+  # DEBUG BEGIN_STMT
+  retval.0 = s;
+  _1 = retval.0->_vptr.S;
gimple difference.

Reply via email to