On 09/18/2017 11:08 AM, Evgeny Kudryashov wrote:
> Hello,
> 
> The code below causes an internal compiler error in cc1plus (trunk on x86-64) 
> if it is compiled with -fdump-ipa-cgraph.
> 
> int foo () __attribute__ ((target ("default")));
> int foo () __attribute__ ((target ("sse4.2")));
> 
> __attribute__ ((target ("sse4.2")))
> int foo ()
> {
>   return 1;
> }
> 
> The error occurs in cgraph_node::dump (gcc/cgraph.c:2065), particularly, in 
> the following fragment:
> 
> cgraph_function_version_info *vi = function_version ();
> if (vi != NULL)
>   {
>     fprintf (f, "  Version info: ");
>     if (vi->prev != NULL)
>       {
>         fprintf (f, "prev: ");
>         fprintf (f, "%s ", vi->prev->this_node->dump_asm_name ());
>       }
>     if (vi->next != NULL)
>       {
>         fprintf (f, "next: ");
>         fprintf (f, "%s ", vi->next->this_node->dump_asm_name ());
>       }
>     if (vi->dispatcher_resolver != NULL_TREE)
>       fprintf (f, "dispatcher: %s",
>                lang_hooks.decl_printable_name (vi->dispatcher_resolver, 2));
> 
>     fprintf (f, "\n");
>   }
> 
> 
> The expression "vi->{prev,next}->this_node" can be null if it is a version of 
> an unused symbol that was removed.
> 
> Is it intentional that removing a cgraph node does not also remove versions?
> 
> As a solution I suggest to delete the version of the node too during node 
> removal.

Hi.

After reading and testing your patch, I think it's proper fix. Note that I'm 
not reviewer, but I'm adding Honza
who is.

Thanks,
Martin

> 
> Regards,
> Evgeny.
> 
>     * cgraph.c (delete_function_version): New, broken out from...
>     (cgraph_node::delete_function_version): ...here.  Rename to
>     cgraph_node::delete_function_version_by_decl.  Update all uses.
>     (cgraph_node::remove): Call delete_function_version.

Reply via email to