Fix overvactive check in cgraph_node::release_body
authorJan Hubicka <jh@suse.cz>
Wed, 31 Mar 2021 18:10:31 +0000 (20:10 +0200)
committerJan Hubicka <jh@suse.cz>
Wed, 31 Mar 2021 18:10:31 +0000 (20:10 +0200)
gcc/ChangeLog:

PR lto/99447
* cgraph.c (cgraph_node::release_body): Fix overactive check.

gcc/cgraph.c

index b77c676..d7c78d5 100644 (file)
@@ -1860,7 +1860,15 @@ cgraph_node::release_body (bool keep_arguments)
       lto_free_function_in_decl_state_for_node (this);
       lto_file_data = NULL;
     }
-  gcc_assert (!clones);
+  if (flag_checking && clones)
+    {
+      /* It is invalid to release body before materializing clones except
+        for thunks that don't really need a body.  Verify also that we do
+        not leak pointers to the call statements.  */
+      for (cgraph_node *node = clones; node;
+          node = node->next_sibling_clone)
+       gcc_assert (node->thunk && !node->callees->call_stmt);
+    }
   remove_callees ();
   remove_all_references ();
 }