Fix simdclones
authorJan Hubicka <jh@suse.cz>
Mon, 26 Oct 2020 13:10:45 +0000 (14:10 +0100)
committerJan Hubicka <jh@suse.cz>
Mon, 26 Oct 2020 13:11:35 +0000 (14:11 +0100)
gcc/ChangeLog:

PR ipa/97576
* cgraphclones.c (cgraph_node::materialize_clone): Clear stmt
references.
* cgraphunit.c (mark_functions_to_output): Do not clear them here.
* ipa-inline-transform.c (inline_transform): Clear stmt references.
* symtab.c (symtab_node::clear_stmts_in_references): Make recursive
for clones.
* tree-ssa-structalias.c (ipa_pta_execute): Do not clear references.

gcc/testsuite/ChangeLog:

PR ipa/97576
* gcc.c-torture/compile/pr97576.c: New test.

gcc/cgraphclones.c
gcc/cgraphunit.c
gcc/ipa-inline-transform.c
gcc/symtab.c
gcc/testsuite/gcc.c-torture/compile/pr97576.c [new file with mode: 0644]
gcc/tree-ssa-structalias.c

index 41c6efb10aca20d128bf573451bf1cfd23a7c3eb..0ed63078c91b7ee22c77c38b7376250c4f25287a 100644 (file)
@@ -1115,6 +1115,7 @@ cgraph_node::materialize_clone ()
       if (clone.param_adjustments)
        clone.param_adjustments->dump (symtab->dump_file);
     }
+  clear_stmts_in_references ();
   /* Copy the OLD_VERSION_NODE function tree to the new version.  */
   tree_function_versioning (clone_of->decl, decl,
                            clone.tree_map, clone.param_adjustments,
index d2d98c8dc8a09e448c678c7fcef74ea3f1c645e2..08b93cb00ee56af233383e19ae14ea2671a8decd 100644 (file)
@@ -1600,7 +1600,6 @@ mark_functions_to_output (void)
   FOR_EACH_FUNCTION (node)
     {
       tree decl = node->decl;
-      node->clear_stmts_in_references ();
 
       gcc_assert (!node->process || node->same_comdat_group);
       if (node->process)
index 279ba2f7cb0abee6648181887fdc0c5b24bbc29c..4df1b7fb9eebb447463607e2f4e26065c786d706 100644 (file)
@@ -716,6 +716,7 @@ inline_transform (struct cgraph_node *node)
       if (n->decl != node->decl)
        n->materialize_clone ();
     }
+  node->clear_stmts_in_references ();
 
   /* We might need the body of this function so that we can expand
      it inline somewhere else.  */
index bc2865f41210ba468d835d19b63e0996ec959aaf..067ae2e28a0a9d8190888e35e95c2717fa230957 100644 (file)
@@ -752,7 +752,8 @@ symtab_node::remove_stmt_references (gimple *stmt)
       i++;
 }
 
-/* Remove all stmt references in non-speculative references.
+/* Remove all stmt references in non-speculative references in THIS
+   and all clones.
    Those are not maintained during inlining & cloning.
    The exception are speculative references that are updated along
    with callgraph edges associated with them.  */
@@ -770,6 +771,13 @@ symtab_node::clear_stmts_in_references (void)
        r->lto_stmt_uid = 0;
        r->speculative_id = 0;
       }
+  cgraph_node *cnode = dyn_cast <cgraph_node *> (this);
+  if (cnode)
+    {
+      if (cnode->clones)
+       for (cnode = cnode->clones; cnode; cnode = cnode->next_sibling_clone)
+         cnode->clear_stmts_in_references ();
+    }
 }
 
 /* Remove all references in ref list.  */
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr97576.c b/gcc/testsuite/gcc.c-torture/compile/pr97576.c
new file mode 100644 (file)
index 0000000..28294c8
--- /dev/null
@@ -0,0 +1,18 @@
+void
+pc (void);
+
+void __attribute__ ((simd))
+ty (void);
+
+void __attribute__ ((simd))
+gf ()
+{
+  ty ();
+}
+
+void __attribute__ ((simd))
+ty (void)
+{
+  gf (pc);
+  gf (gf);
+}
index 9bac06f97af9dd26abbedbdcb682a3965a2b0434..a4832b7543639224f734c804382f3d4b2de1ac4f 100644 (file)
@@ -8138,10 +8138,6 @@ ipa_pta_execute (void)
       from = constraints.length ();
     }
 
-  /* FIXME: Clone materialization is not preserving stmt references.  */
-  FOR_EACH_DEFINED_FUNCTION (node)
-    node->clear_stmts_in_references ();
-
   /* Build the constraints.  */
   FOR_EACH_DEFINED_FUNCTION (node)
     {