[PATCH] ipa/96291: don't crash on unoptimized lto functions

Martin Jambor mjambor@suse.cz
Mon Jul 27 12:36:43 GMT 2020


Hi,

On Sat, Jul 25 2020, Sergei Trofimovich wrote:
> From: Sergei Trofimovich <siarheit@google.com>
>
> In PR ipa/96291 the test contained an SCC with one
> unoptimized function. This tricked ipa-cp into NULL dereference.
>
> has_undead_caller_from_outside_scc_p() did not take into account
> that unoptimized funtions don't have IPA summary analysis. and
> dereferenced NULL pointer causing an ICE.
>
> 	PR ipa/96291
> 	* ipa-cp.c (has_undead_caller_from_outside_scc_p): Consider
> 	unoptimized callers as undead.
> ---
>  gcc/ipa-cp.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
> index b0c8f405260..d5082576962 100644
> --- a/gcc/ipa-cp.c
> +++ b/gcc/ipa-cp.c
> @@ -5666,9 +5666,15 @@ has_undead_caller_from_outside_scc_p (struct cgraph_node *node,
>  	&& cs->caller->call_for_symbol_thunks_and_aliases
>  	  (has_undead_caller_from_outside_scc_p, NULL, true))
>        return true;
> -    else if (!ipa_edge_within_scc (cs)
> -	     && !IPA_NODE_REF (cs->caller)->node_dead)
> -      return true;
> +    else if (!ipa_edge_within_scc (cs))
> +      {
> +	/* Unoptimized callers don't have IPA information.
> +	   Conservatively assume callers are undead.  */
> +	if (!IPA_NODE_REF (cs->caller))
> +	  return true;
> +	if (!IPA_NODE_REF (cs->caller)->node_dead)
> +	  return true;

I'd prefer a single condition, i.e.:

    else if (!ipa_edge_within_scc (cs)
	     && (!IPA_NODE_REF (cs->caller)
		 || !IPA_NODE_REF (cs->caller)->node_dead))
      return true;


so OK with that change.

Thanks a lot for looking into this.

Martin


More information about the Gcc-patches mailing list