This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix IPA CP where it forgot to add a reference in cgraph


> >> 2016-12-19  Martin Liska  <mliska@suse.cz>
> >>
> >> 	* cgraphclones.c (cgraph_node::create_virtual_clone):
> >> 	Create either IPA_REF_LOAD of IPA_REF_READ depending on
> >> 	whether new_tree is a VAR_DECL or an ADDR_EXPR.
> >> 	* ipa-cp.c (create_specialized_node): Add reference just for
> >> 	ADDR_EXPRs.
> >> 	* symtab.c (symtab_node::maybe_create_reference): Remove guard
> >> 	as it's guarded in callers.

Path is OK
>  ipa_ref *
> -symtab_node::maybe_create_reference (tree val, enum ipa_ref_use use_type,
> -				     gimple *stmt)
> +symtab_node::maybe_create_reference (tree val, gimple *stmt)
>  {
>    STRIP_NOPS (val);
> -  if (TREE_CODE (val) != ADDR_EXPR)
> -    return NULL;
> +  ipa_ref_use use_type;
> +
> +  switch (TREE_CODE (val))
> +    {
> +    case VAR_DECL:
> +      use_type = IPA_REF_LOAD;
> +      break;
> +    case ADDR_EXPR:
> +      use_type = IPA_REF_ADDR;
> +      break;
> +    default:
> +      return NULL;
> +    }

I would add assert into default that we don't get handled_component_ref here so we are sure
we don't miss any declarations (because the bug leads to quite esoteric issues, it is better
to be safe than sorry)

Honza


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]