diff mbox series

ipa: Fix segmentation fault in function_summary<clone_info*>::get(cgraph_node*) (PR 97660)

Message ID 20201101155947.2138610-1-ibuclaw@gdcproject.org
State New
Headers show
Series ipa: Fix segmentation fault in function_summary<clone_info*>::get(cgraph_node*) (PR 97660) | expand

Commit Message

Iain Buclaw Nov. 1, 2020, 3:59 p.m. UTC
Hi,

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.

Tested on x86_64-freebsd12.2 to confirm the bootstrap regression no
longer happens.  OK for mainline?

Regards
Iain

---
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 | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Jan Hubicka Nov. 1, 2020, 5:07 p.m. UTC | #1
> Hi,
> 
> 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.
> 
> Tested on x86_64-freebsd12.2 to confirm the bootstrap regression no
> longer happens.  OK for mainline?
> 
> Regards
> Iain
> 
> ---
> 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.

OK, thanks!
Honza
diff mbox series

Patch

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 9f3a7284310..36bdb009bf8 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -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);