ipa: fix dumping with deleted multiversioning nodes
authorEvgeny Kudryashov <kudryashov@ispras.ru>
Thu, 21 Sep 2017 12:54:38 +0000 (12:54 +0000)
committerAlexander Monakov <amonakov@gcc.gnu.org>
Thu, 21 Sep 2017 12:54:38 +0000 (15:54 +0300)
2017-09-21  Evgeny Kudryashov <kudryashov@ispras.ru>

* cgraph.c (delete_function_version): New, broken out from...
(cgraph_node::delete_function_version): ...here.  Rename to
cgraph_node::delete_function_version_by_decl.  Update all uses.
(cgraph_node::remove): Call delete_function_version.

From-SVN: r253066

gcc/ChangeLog
gcc/cgraph.c
gcc/cgraph.h
gcc/cp/decl.c

index c743c21f9e8a24e007a29e6ba3fb7a7d047b8e4e..90dc208d572af44361b9d754e32d24daae216445 100644 (file)
@@ -1,3 +1,10 @@
+2017-09-21  Evgeny Kudryashov <kudryashov@ispras.ru>
+
+       * cgraph.c (delete_function_version): New, broken out from...
+       (cgraph_node::delete_function_version): ...here.  Rename to
+       cgraph_node::delete_function_version_by_decl.  Update all uses.
+       (cgraph_node::remove): Call delete_function_version.
+
 2017-09-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR sanitizer/81715
index 8bffdec8fb785e8e9abee7fa4e746c7803cde7ff..3d0cefbd46bacc1c9cb7b1cad8ee5d09a3e7eaf0 100644 (file)
@@ -190,30 +190,34 @@ cgraph_node::insert_new_function_version (void)
   return version_info_node;
 }
 
-/* Remove the cgraph_function_version_info and cgraph_node for DECL.  This
-   DECL is a duplicate declaration.  */
-void
-cgraph_node::delete_function_version (tree decl)
+/* Remove the cgraph_function_version_info node given by DECL_V.  */
+static void
+delete_function_version (cgraph_function_version_info *decl_v)
 {
-  cgraph_node *decl_node = cgraph_node::get (decl);
-  cgraph_function_version_info *decl_v = NULL;
-
-  if (decl_node == NULL)
-    return;
-
-  decl_v = decl_node->function_version ();
-
   if (decl_v == NULL)
     return;
 
   if (decl_v->prev != NULL)
-   decl_v->prev->next = decl_v->next;
+    decl_v->prev->next = decl_v->next;
 
   if (decl_v->next != NULL)
     decl_v->next->prev = decl_v->prev;
 
   if (cgraph_fnver_htab != NULL)
     cgraph_fnver_htab->remove_elt (decl_v);
+}
+
+/* Remove the cgraph_function_version_info and cgraph_node for DECL.  This
+   DECL is a duplicate declaration.  */
+void
+cgraph_node::delete_function_version_by_decl (tree decl)
+{
+  cgraph_node *decl_node = cgraph_node::get (decl);
+
+  if (decl_node == NULL)
+    return;
+
+  delete_function_version (decl_node->function_version ());
 
   decl_node->remove ();
 }
@@ -1844,6 +1848,7 @@ cgraph_node::remove (void)
   remove_callers ();
   remove_callees ();
   ipa_transforms_to_apply.release ();
+  delete_function_version (function_version ());
 
   /* Incremental inlining access removed nodes stored in the postorder list.
      */
index 7daca1e40cccc334e407caa88e3ce2453c66cb8b..1758e8b08c17fc217d703aded9a2bc584548cec7 100644 (file)
@@ -1272,7 +1272,7 @@ public:
 
   /* Remove the cgraph_function_version_info and cgraph_node for DECL.  This
      DECL is a duplicate declaration.  */
-  static void delete_function_version (tree decl);
+  static void delete_function_version_by_decl (tree decl);
 
   /* Add the function FNDECL to the call graph.
      Unlike finalize_function, this function is intended to be used
index 858747eecfc35c24e8de80f9bb2a947d1032f1f6..50fa1ba402ec94ed39b095dcb16d65cfdf16bbf4 100644 (file)
@@ -2566,7 +2566,7 @@ next_arg:;
       DECL_FUNCTION_VERSIONED (newdecl) = 1;
       /* newdecl will be purged after copying to olddecl and is no longer
          a version.  */
-      cgraph_node::delete_function_version (newdecl);
+      cgraph_node::delete_function_version_by_decl (newdecl);
     }
 
   if (TREE_CODE (newdecl) == FUNCTION_DECL)