> Hi,
> 
> With r221574 (https://gcc.gnu.org/ml/gcc-cvs/2015-03/msg00495.html) thunks 
> don't get comdat groups assigned and this causes a failure in cgraph checker 
> for instrumentation thunks.  It happens because instrumentation thunk may 
> reference local symbol in comdat not being in comdat by itself.  This patch 
> fixes the problem.  Doesn't affect not instrumented code.  Testing is in 
> progress.  Does it look OK?
> 
> Thanks,
> Ilya
> --
> gcc/
> 
> 2015-04-02  Ilya Enkovich  <ilya.enkov...@intel.com>
> 
>       * ipa-comdats.c (ipa_comdats): Visit all instrumentation
>       thunks to set proper comdat group.
> 
> gcc/testsuite/
> 
> 2015-04-02  Ilya Enkovich  <ilya.enkov...@intel.com>
> 
>       * gcc.target/i386/mpx/chkp-thunk-comdat-1.cc: New.
>       * gcc.target/i386/mpx/chkp-thunk-comdat-2.cc: New.
> 
> 
> diff --git a/gcc/ipa-comdats.c b/gcc/ipa-comdats.c
> index f349f9f..30bcad8 100644
> --- a/gcc/ipa-comdats.c
> +++ b/gcc/ipa-comdats.c
> @@ -348,10 +348,9 @@ ipa_comdats (void)
>      }
>  
>    /* Finally assign symbols to the sections.  */
> -
> +  cgraph_node *fun;
>    FOR_EACH_DEFINED_SYMBOL (symbol)
>      {
> -      struct cgraph_node *fun;
>        symbol->aux = NULL; 
>        if (!symbol->get_comdat_group ()
>         && !symbol->alias
> @@ -388,6 +387,20 @@ ipa_comdats (void)
>                  true);
>       }
>      }
> +
> +  /* Instrumentation thunks reference original node and thus
> +     need to be in the same comdat group.  Otherwise we may
> +     get a local instrumented symbol in a comdat group and
> +     the referencing original node outside of it.  */
> +  FOR_EACH_DEFINED_FUNCTION (fun)
> +    if (fun->instrumentation_clone
> +     && fun->instrumented_version
> +     && !fun->instrumented_version->alias
> +     && fun->get_comdat_group ()
> +     && !fun->instrumented_version->get_comdat_group ())
> +      fun->instrumented_version->call_for_symbol_and_aliases
> +     (set_comdat_group_1, fun, true);

I think you want to handle them same way as the aliases&thunks are handled.
This fix is symptomatic: the code may assign them to different comdat groups
and may propagate that furhter.

Honza

Reply via email to