Re: Support for V2 plugin API

2011-10-06 Thread Jan Hubicka
> On Mon, Oct 3, 2011 at 9:52 AM, Jan Hubicka  wrote:
> >> This caused:
> >>
> >> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50601
> > Hi,
> > do you use linker with V2 API?
> >
> 
> No.
Hi,
the problem is that partitioning algorithm forgets about the aliase and don't 
put it into any partition.
I am surprised this is not causing problems elsewhere.  This patch should fix 
it, but I would like to give
it a try on firefox that is not currently in buildable shape. Will try tomorrow.

Honza

Index: lto.c
===
--- lto.c   (revision 179627)
+++ lto.c   (working copy)
@@ -1400,6 +1400,14 @@ add_references_to_partition (ltrans_part
&& !varpool_node_in_set_p (ipa_ref_varpool_node (ref), 
part->varpool_set))
  add_varpool_node_to_partition (part, ipa_ref_varpool_node (ref));
 }
+  for (i = 0; ipa_ref_list_refering_iterate (refs, i, ref); i++)
+if (ref->use == IPA_REF_ALIAS)
+  {
+   if (ref->refering_type == IPA_REF_CGRAPH)
+ add_cgraph_node_to_partition (part, ipa_ref_refering_node (ref));
+   else
+ add_varpool_node_to_partition (part, ipa_ref_refering_varpool_node 
(ref));
+  }
 }
 
 /* Worker for add_cgraph_node_to_partition.  */


Re: Support for V2 plugin API

2011-10-03 Thread H.J. Lu
On Mon, Oct 3, 2011 at 9:52 AM, Jan Hubicka  wrote:
>> This caused:
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50601
> Hi,
> do you use linker with V2 API?
>

No.


-- 
H.J.


Re: Support for V2 plugin API

2011-10-03 Thread Jan Hubicka
> This caused:
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50601
Hi,
do you use linker with V2 API?

Honza
> 
> -- 
> H.J.


Re: Support for V2 plugin API

2011-10-03 Thread H.J. Lu
On Wed, Sep 28, 2011 at 5:29 AM, Jan Hubicka  wrote:
> Hi,
> this patch adds support for V2 plugin API (thanks, Cary) that adds
> LDPR_PREVAILING_DEF_IRONLY_EXP.
> The reoslution is like LDPR_PREVAILING_DEF_IRONLY but the symbol is exported
> out of DSO.  It is up to the compiler to optimize it out or keep it based on
> the knowledge whether the symbol can be optimized out at all (i.e. most 
> COMDATs
> can, other types can't).
>
> This solve quite few problems with building C++ APPS, see the PR log.
>
> I was originally wrong about gold implementation being buggy. The problem 
> turned
> out to be subtle lto-symtab bug that was mostly latent because of the COMDAT 
> hack
> we use. lto_symtab_resolve_symbols is supposed to honor plugin decision when 
> it is
> available but it doesn't when resolution of very first entry in the list is 
> UNKNOWN.
> This can happen because we add into symtab also declarations that are not in
> varpool (i.e. they are neither defined or used by the object file), but they 
> are
> used otherwise, i.e. referred from stuff used for debug info or TB 
> devirtualization.
>
> To ensure backward compatibility I am keeping the COMDAT hack in place.  It 
> won't help
> letting compiler know the plugin API version, since we decide on that at a 
> time
> we output object files and thus we are not called from plugin.  I suppose we 
> could
> keep the hack in place for next release and remove it afterwards penalizing 
> builds
> with old binutils? Or perhaps even in GCC 4.7 if GNU LD gets updated in time.
>
> Bootstrapped/regtested x86_64-linux, built Mozilla and lto-bootstrap in 
> progress.
> OK if it passes?
>
> Honza
>
>        PR lto/47247
>        * lto-plugin.c (get_symbols_v2): New variable.
>        (write_resolution): Use V2 API when available.
>        (onload): Handle LDPT_GET_SYMBOLS_V2.
>
>        * lto-symtab.c (lto_symtab_resolve_symbols): Do not resolve
>        when resolution is already availbale from plugin.
>        (lto_symtab_merge_decls_1): Handle LDPR_PREVAILING_DEF_IRONLY_EXP.
>        * cgraph.c (ld_plugin_symbol_resolution): Add 
> prevailing_def_ironly_exp.
>        * lto-cgraph.c (LDPR_NUM_KNOWN): Update.
>        * ipa.c (varpool_externally_visible_p): IRONLY variables are never
>        externally visible.
>        * varasm.c (resolution_to_local_definition_p): Add
>        LDPR_PREVAILING_DEF_IRONLY_EXP.
>        (resolution_local_p): Likewise.
>
>        * common.c (lto_resolution_str): Add new resolution.
>        * common.h (lto_resolution_str): Likewise.

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50601

-- 
H.J.


Re: Support for V2 plugin API

2011-09-28 Thread Richard Guenther
On Wed, 28 Sep 2011, Jan Hubicka wrote:

> Hi,
> this patch adds support for V2 plugin API (thanks, Cary) that adds
> LDPR_PREVAILING_DEF_IRONLY_EXP.
> The reoslution is like LDPR_PREVAILING_DEF_IRONLY but the symbol is exported
> out of DSO.  It is up to the compiler to optimize it out or keep it based on
> the knowledge whether the symbol can be optimized out at all (i.e. most 
> COMDATs
> can, other types can't).
> 
> This solve quite few problems with building C++ APPS, see the PR log.
> 
> I was originally wrong about gold implementation being buggy. The problem 
> turned
> out to be subtle lto-symtab bug that was mostly latent because of the COMDAT 
> hack
> we use. lto_symtab_resolve_symbols is supposed to honor plugin decision when 
> it is
> available but it doesn't when resolution of very first entry in the list is 
> UNKNOWN.
> This can happen because we add into symtab also declarations that are not in
> varpool (i.e. they are neither defined or used by the object file), but they 
> are
> used otherwise, i.e. referred from stuff used for debug info or TB 
> devirtualization.
> 
> To ensure backward compatibility I am keeping the COMDAT hack in place.  It 
> won't help
> letting compiler know the plugin API version, since we decide on that at a 
> time
> we output object files and thus we are not called from plugin.  I suppose we 
> could
> keep the hack in place for next release and remove it afterwards penalizing 
> builds
> with old binutils? Or perhaps even in GCC 4.7 if GNU LD gets updated in time.
> 
> Bootstrapped/regtested x86_64-linux, built Mozilla and lto-bootstrap in 
> progress.
> OK if it passes?

Ok.

Any idea when GNU ld will catch up?

Thanks,
Richard.

> Honza
> 
>   PR lto/47247
>   * lto-plugin.c (get_symbols_v2): New variable.
>   (write_resolution): Use V2 API when available.
>   (onload): Handle LDPT_GET_SYMBOLS_V2.
> 
>   * lto-symtab.c (lto_symtab_resolve_symbols): Do not resolve
>   when resolution is already availbale from plugin.
>   (lto_symtab_merge_decls_1): Handle LDPR_PREVAILING_DEF_IRONLY_EXP.
>   * cgraph.c (ld_plugin_symbol_resolution): Add prevailing_def_ironly_exp.
>   * lto-cgraph.c (LDPR_NUM_KNOWN): Update.
>   * ipa.c (varpool_externally_visible_p): IRONLY variables are never
>   externally visible.
>   * varasm.c (resolution_to_local_definition_p): Add
>   LDPR_PREVAILING_DEF_IRONLY_EXP.
>   (resolution_local_p): Likewise.
> 
>   * common.c (lto_resolution_str): Add new resolution.
>   * common.h (lto_resolution_str): Likewise.
> Index: lto-plugin/lto-plugin.c
> ===
> *** lto-plugin/lto-plugin.c   (revision 179274)
> --- lto-plugin/lto-plugin.c   (working copy)
> *** enum symbol_style
> *** 129,135 
>   static char *arguments_file_name;
>   static ld_plugin_register_claim_file register_claim_file;
>   static ld_plugin_register_all_symbols_read register_all_symbols_read;
> ! static ld_plugin_get_symbols get_symbols;
>   static ld_plugin_register_cleanup register_cleanup;
>   static ld_plugin_add_input_file add_input_file;
>   static ld_plugin_add_input_library add_input_library;
> --- 129,135 
>   static char *arguments_file_name;
>   static ld_plugin_register_claim_file register_claim_file;
>   static ld_plugin_register_all_symbols_read register_all_symbols_read;
> ! static ld_plugin_get_symbols get_symbols, get_symbols_v2;
>   static ld_plugin_register_cleanup register_cleanup;
>   static ld_plugin_add_input_file add_input_file;
>   static ld_plugin_add_input_library add_input_library;
> *** write_resolution (void)
> *** 441,447 
> struct plugin_symtab *symtab = &info->symtab;
> struct ld_plugin_symbol *syms = symtab->syms;
>   
> !   get_symbols (info->handle, symtab->nsyms, syms);
>   
> finish_conflict_resolution (symtab, &info->conflicts);
>   
> --- 441,452 
> struct plugin_symtab *symtab = &info->symtab;
> struct ld_plugin_symbol *syms = symtab->syms;
>   
> !   /* Version 2 of API supports IRONLY_EXP resolution that is
> !  accepted by GCC-4.7 and newer.  */
> !   if (get_symbols_v2)
> ! get_symbols_v2 (info->handle, symtab->nsyms, syms);
> !   else
> ! get_symbols (info->handle, symtab->nsyms, syms);
>   
> finish_conflict_resolution (symtab, &info->conflicts);
>   
> *** onload (struct ld_plugin_tv *tv)
> *** 986,991 
> --- 991,999 
>   case LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK:
> r

Support for V2 plugin API

2011-09-28 Thread Jan Hubicka
Hi,
this patch adds support for V2 plugin API (thanks, Cary) that adds
LDPR_PREVAILING_DEF_IRONLY_EXP.
The reoslution is like LDPR_PREVAILING_DEF_IRONLY but the symbol is exported
out of DSO.  It is up to the compiler to optimize it out or keep it based on
the knowledge whether the symbol can be optimized out at all (i.e. most COMDATs
can, other types can't).

This solve quite few problems with building C++ APPS, see the PR log.

I was originally wrong about gold implementation being buggy. The problem turned
out to be subtle lto-symtab bug that was mostly latent because of the COMDAT 
hack
we use. lto_symtab_resolve_symbols is supposed to honor plugin decision when it 
is
available but it doesn't when resolution of very first entry in the list is 
UNKNOWN.
This can happen because we add into symtab also declarations that are not in
varpool (i.e. they are neither defined or used by the object file), but they are
used otherwise, i.e. referred from stuff used for debug info or TB 
devirtualization.

To ensure backward compatibility I am keeping the COMDAT hack in place.  It 
won't help
letting compiler know the plugin API version, since we decide on that at a time
we output object files and thus we are not called from plugin.  I suppose we 
could
keep the hack in place for next release and remove it afterwards penalizing 
builds
with old binutils? Or perhaps even in GCC 4.7 if GNU LD gets updated in time.

Bootstrapped/regtested x86_64-linux, built Mozilla and lto-bootstrap in 
progress.
OK if it passes?

Honza

PR lto/47247
* lto-plugin.c (get_symbols_v2): New variable.
(write_resolution): Use V2 API when available.
(onload): Handle LDPT_GET_SYMBOLS_V2.

* lto-symtab.c (lto_symtab_resolve_symbols): Do not resolve
when resolution is already availbale from plugin.
(lto_symtab_merge_decls_1): Handle LDPR_PREVAILING_DEF_IRONLY_EXP.
* cgraph.c (ld_plugin_symbol_resolution): Add prevailing_def_ironly_exp.
* lto-cgraph.c (LDPR_NUM_KNOWN): Update.
* ipa.c (varpool_externally_visible_p): IRONLY variables are never
externally visible.
* varasm.c (resolution_to_local_definition_p): Add
LDPR_PREVAILING_DEF_IRONLY_EXP.
(resolution_local_p): Likewise.

* common.c (lto_resolution_str): Add new resolution.
* common.h (lto_resolution_str): Likewise.
Index: lto-plugin/lto-plugin.c
===
*** lto-plugin/lto-plugin.c (revision 179274)
--- lto-plugin/lto-plugin.c (working copy)
*** enum symbol_style
*** 129,135 
  static char *arguments_file_name;
  static ld_plugin_register_claim_file register_claim_file;
  static ld_plugin_register_all_symbols_read register_all_symbols_read;
! static ld_plugin_get_symbols get_symbols;
  static ld_plugin_register_cleanup register_cleanup;
  static ld_plugin_add_input_file add_input_file;
  static ld_plugin_add_input_library add_input_library;
--- 129,135 
  static char *arguments_file_name;
  static ld_plugin_register_claim_file register_claim_file;
  static ld_plugin_register_all_symbols_read register_all_symbols_read;
! static ld_plugin_get_symbols get_symbols, get_symbols_v2;
  static ld_plugin_register_cleanup register_cleanup;
  static ld_plugin_add_input_file add_input_file;
  static ld_plugin_add_input_library add_input_library;
*** write_resolution (void)
*** 441,447 
struct plugin_symtab *symtab = &info->symtab;
struct ld_plugin_symbol *syms = symtab->syms;
  
!   get_symbols (info->handle, symtab->nsyms, syms);
  
finish_conflict_resolution (symtab, &info->conflicts);
  
--- 441,452 
struct plugin_symtab *symtab = &info->symtab;
struct ld_plugin_symbol *syms = symtab->syms;
  
!   /* Version 2 of API supports IRONLY_EXP resolution that is
!  accepted by GCC-4.7 and newer.  */
!   if (get_symbols_v2)
! get_symbols_v2 (info->handle, symtab->nsyms, syms);
!   else
! get_symbols (info->handle, symtab->nsyms, syms);
  
finish_conflict_resolution (symtab, &info->conflicts);
  
*** onload (struct ld_plugin_tv *tv)
*** 986,991 
--- 991,999 
case LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK:
  register_all_symbols_read = p->tv_u.tv_register_all_symbols_read;
  break;
+   case LDPT_GET_SYMBOLS_V2:
+ get_symbols_v2 = p->tv_u.tv_get_symbols;
+ break;
case LDPT_GET_SYMBOLS:
  get_symbols = p->tv_u.tv_get_symbols;
  break;
Index: gcc/lto-symtab.c
===
*** gcc/lto-symtab.c(revision 179274)
--- gcc/lto-symtab.c(working copy)
*** lto_symtab_resolve_symbols (void **slot)
*** 441,452 
e->node = cgraph_get_node (e->decl);