This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[pretty-ipa] Fix C++ tester ICEs


Hi,
it looks like mainline merge brought in change that makes inliner a lot
more active on removing unreachable blocks and uncovered some issues
with my updating code.

Honza

	* cgraph.c (cgraph_remove_node_and_inline_clones): Fix.
	* cgraphunit.c (save_inlined_function_body): Update cgraph before
	versioning.
	* tree-inline.c (remove_unreachable_blocks_update_callgraph): Fix.
	(tree_function_versioning): Sanity check.
Index: cgraph.c
===================================================================
--- cgraph.c	(revision 145914)
+++ cgraph.c	(working copy)
@@ -1211,6 +1210,7 @@
       if (!e->inline_failed)
         cgraph_remove_node_and_inline_clones (e->callee);
     }
+  cgraph_remove_node (node);
 }
 
 /* Notify finalize_compilation_unit that given node is reachable.  */
Index: cgraphunit.c
===================================================================
--- cgraphunit.c	(revision 145914)
+++ cgraphunit.c	(working copy)
@@ -1640,6 +1640,24 @@
   first_clone->clone_of = NULL;
   node->clones = NULL;
 
+  if (first_clone->clones)
+    for (n = first_clone->clones; n != first_clone;)
+      {
+        gcc_assert (n->decl == node->decl);
+	n->decl = first_clone->decl;
+	if (n->clones)
+	  n = n->clones;
+	else if (n->next_sibling_clone)
+	  n = n->next_sibling_clone;
+	else
+	  {
+	    while (n != first_clone && !n->next_sibling_clone)
+	      n = n->clone_of;
+	    if (n != first_clone)
+	      n = n->next_sibling_clone;
+	  }
+      }
+
   /* Copy the OLD_VERSION_NODE function tree to the new version.  */
   tree_function_versioning (node->decl, first_clone->decl, NULL, true, NULL);
 
@@ -1648,22 +1666,6 @@
   TREE_PUBLIC (first_clone->decl) = 0;
   DECL_COMDAT (first_clone->decl) = 0;
 
-  if (first_clone->clones)
-    for (node = first_clone->clones; node != first_clone;)
-      {
-	node->decl = first_clone->decl;
-	if (node->clones)
-	  node = node->clones;
-	else if (node->next_sibling_clone)
-	  node = node->next_sibling_clone;
-	else
-	  {
-	    while (node != first_clone && !node->next_sibling_clone)
-	      node = node->clone_of;
-	    if (node != first_clone)
-	      node = node->next_sibling_clone;
-	  }
-      }
 #ifdef ENABLE_CHECKING
   verify_cgraph_node (first_clone);
 #endif
Index: tree-inline.c
===================================================================
--- tree-inline.c	(revision 145914)
+++ tree-inline.c	(working copy)
@@ -4913,7 +4913,7 @@
 		    && id->dst_node->clones)
      		  for (node = id->dst_node->clones; node != id->dst_node;)
 		    {
-	              if ((e = cgraph_edge (id->dst_node, gsi_stmt (bsi))) != NULL)
+	              if ((e = cgraph_edge (node, gsi_stmt (bsi))) != NULL)
 			{
 		          if (!e->inline_failed)
 		            cgraph_remove_node_and_inline_clones (e->callee);
@@ -4941,6 +4941,30 @@
 
   if (changed)
     tidy_fallthru_edges ();
+#ifdef ENABLE_CHECKING
+  verify_cgraph_node (id->dst_node);
+  if (id->transform_call_graph_edges == CB_CGE_MOVE_CLONES
+      && id->dst_node->clones)
+    {
+      struct cgraph_node *node;
+      for (node = id->dst_node->clones; node != id->dst_node;)
+	{
+	  verify_cgraph_node (node);
+	   
+	  if (node->clones)
+	    node = node->clones;
+	  else if (node->next_sibling_clone)
+	    node = node->next_sibling_clone;
+	  else
+	    {
+	      while (node != id->dst_node && !node->next_sibling_clone)
+		node = node->clone_of;
+	      if (node != id->dst_node)
+		node = node->next_sibling_clone;
+	    }
+	}
+     }
+#endif
   return changed;
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]