ipa: Fix segmentation fault in function_summary<clone_info*>::get(cgraph_node*)
authorIain Buclaw <ibuclaw@gdcproject.org>
Sun, 1 Nov 2020 15:39:10 +0000 (16:39 +0100)
committerIain Buclaw <ibuclaw@gdcproject.org>
Sun, 1 Nov 2020 17:21:35 +0000 (18:21 +0100)
PR 97660 occurs when cgraph_node::get returns NULL, and this NULL
cgraph_node is then passed to clone_info::get.  As the original assert
prior to the regressing change in r11-4587 allowed for the cgraph_node
to be NULL, clone_info::get is now only called when cgraph_node::get
returns a nonnull value.

gcc/ChangeLog:

PR ipa/97660
* cgraph.c (cgraph_edge::redirect_call_stmt_to_callee): Don't call
clone_info::get when cgraph_node::get returns NULL.

gcc/cgraph.c

index 9f3a72843105dbfe72fe203b10d70ad7c05f3cc4..36bdb009bf85c20fe6173de76703d070cb7d8d5e 100644 (file)
@@ -1491,9 +1491,11 @@ cgraph_edge::redirect_call_stmt_to_callee (cgraph_edge *e)
     }
   if (flag_checking && decl)
     {
-      cgraph_node *node = cgraph_node::get (decl);
-      clone_info *info = clone_info::get (node);
-      gcc_assert (!node || !info || !info->param_adjustments);
+      if (cgraph_node *node = cgraph_node::get (decl))
+       {
+         clone_info *info = clone_info::get (node);
+         gcc_assert (!info || !info->param_adjustments);
+       }
     }
 
   clone_info *callee_info = clone_info::get (e->callee);