On Thu, May 17, 2012 at 9:42 AM, Jan Hubicka <hubi...@ucw.cz> wrote:
> Hi,
> C++ virtual tables keyed to other compilation units are represented as 
> DECL_EXTERNAL
> variables with constructor known. Knowhing the constructor helps constant 
> folding to do
> devirtualization.
>
> At the moment these costructors are not seen by varpool and thus they are not
> represented by ipa-ref and thus WHOPR partitioning is not seeing them and we
> later in can_refer_decl_in_current_unit_p try to work out if the partitioning
> was done in lucky or unlucky way.
>
> This patch makes external variables to be handled similarly to external 
> functions.
> That is the variables gets finalized and analyzed by varpool. They go in 
> similar
> way to partitioning as comdat functions.
>
> Code removing unreachable nodes treats them as normal variables until after
> inlining when vars/funcions referred only by those are considred unreachable.
> This also allows us to remove the constructors from memory when we know they
> are no longer needed saving couple hundred KB on compiling Mozilla with LTO.
>
> The patch also enables aboud 3000 extra foldings on Mozilla LTO build.
> Mostly those are devirtualized calls to libstdc++.
>
> Bootstrapped/regtested x86_64-linux, comitted.
> Index: ChangeLog
> ===================================================================
> *** ChangeLog   (revision 187630)
> --- ChangeLog   (working copy)
> ***************
> *** 1,3 ****
> --- 1,26 ----
> + 2012-05-17  Jan Hubicka  <j...@suse.cz>
> +
> +       * lto-symtab.c (lto_symtab_resolve_symbols): Preffer decl with 
> constructor
> +       over decl without.
> +       * cgraph.c (cgraph_remove_node): Clear also body of unanalyzed nodes.
> +       * cgraph.h (varpool_can_remove_if_no_refs): Handle external correctly.
> +       * cgraphunit.c (process_function_and_variable_attributes): Finalize
> +       extrnal decls.
> +       (mark_functions_to_output): Also accept bodies for functions with 
> clones.
> +       (output_in_order): Skip external vars.
> +       * lto-cgraph.c (lto_output_node): External functions are never in 
> other
> +       partition.
> +       (lto_output_varpool_node): Likewise.
> +       * lto-streamer-out.c (lto_write_tree): Always use error_mark_nodes for
> +       forgotten initializers.
> +       * ipa.c (process_references): Handle external vars.
> +       (symtab_remove_unreachable_nodes): Update to handle external vars.
> +       (varpool_externally_visible_p): External vars are externally visible.
> +       * gimple-fold.c (can_refer_decl_in_current_unit_p): Update.
> +       * varpool.c (varpool_remove_node): Remove constructor.
> +       (decide_is_variable_needed): Handle externals.
> +       (varpool_remove_unreferenced_decls): Likewise.
> +

This caused:

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


-- 
H.J.

Reply via email to