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: pretty-ipa merge part 19: Clonning infrastructure


On Mon, May 4, 2009 at 3:31 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
> Hi,
> this patch merge clone infrastructure from pretty-ipa. ?I've
> bootstrapped/regtested it on x86_64-linux and i686-linux and intend to commit
> it in few days if there are no objections. ?Diego, we probably ought to
> synchronize on LTO merge, my experience from pretty-ipa merge is that bringing
> in type checking and SSA expansion is quite distrubing. ?So I would suggest for
> you to merge in first and I will commit afterwardes so we can handle this patch
> independently.
>
> The patch is solving following problem:
>
> For WHOPR we need IPA passes to work on callgraph when function bodies are not
> available: all IPA passes create summaries about every function during
> compilation stage and in linker stage (via their analyze methods). At linktime
> they use summaries to decide on transformations they want to do (in execute
> methods). ?Result of execute methods is optimization summary that is later
> shipped to local optimization.
>
> To make this work, it is neccesary for passes like inliner, IPA-CP, IPA-SRA,
> IPA-PTA, unreachable function removal or clonning to be able to use summaries
> before all of the passes was executed, work on callgraph after some of passes
> being executed (depending on pass order) and applying the result after all the
> passes was executed. ?It is also important for the LTO driver to understand
> what needs to be shipped to compilation nodes to make it possible to apply the
> transformations.
>
> Clones provide common abstraction for these passes: when inliner decides to
> inline function or clonning pass decides to produce clone,
> cgraph_create_virtual_clone is used. ?This produce new node in cgraph that
> looks like other functions but whose body is not there, instead clone_info
> structure provide info how to build it based on function it is being clone of.
> I added support for simple subtitutions and function call changes into the
> infrastructure itself, other changes can be done by pass own transform
> function. ?I expect that commonizing implementation of the most common changes
> to function bodies to make it easier for passes to update their own function
> summary for newly born clones and thus solve many of pass interaction issues we
> are ncesarily going to hit once WHOPR does more than just inlining.
>
> At the beggining of local optimization, cgraph_matherialize_clones is called
> that is responsible for producing all the neccesary clonned bodies and we follow
> the optimization queue same way as always.
>
> The patch is relatively large since it include:
> ?- Reorganization of cgraph clones from flat clones list into tree: When clonning
> ? ?pass produce clone, inliner can inline it thus creating clone of clone. ?This
> ? ?can't be represented properly by flat list.
> ?- Support for substitution and function call change during clonning. ?It was already
> ? ?here for ipa-cp, now it is part of cgraph infrastructure. ?I plan to update it
> ? ?for Martin's parm notes structure to accomondate needs of full IPA SRA pass, but
> ? ?I don't want to have dependency here, so now it include bitmap of arguments
> ? ?to skip and vector (I turned into from varray) of structures.
> ?- Inliner is now able to fully update callgraph after inlining, embedded folding
> ? ?and dead blocks removal. ?This is neccesary to allow updating SSA in clones after
> ? ?materializing them.
> ? ?This will help some other stuff too, like make it possible to handle
> ? ?devirtualization and indirect inlining in early inliner via iteration that
> ? ?looks like better (easier and overall less expensive) implementation than
> ? ?teaching early inliner about indirect call analysis.
> ?- Update existing IPA passes (inliner, IPA-CP) for new clone API.
>
> It is not really possible to break these things into incremental changes and
> have bootstrappable compiler in meantime. ?In order to reduce the patch I
> didn't include local profile updating that needs bit more work and is quite
> non-critical.
>
> Honza
>
> ? ? ? ?* cgraphbuild.c (compute_call_stmt_bb_frequency): Accept function argument;
> ? ? ? ?handle correctly when profile is absent.
> ? ? ? ?(build_cgraph_edges): Update.
> ? ? ? ?(rebuild_cgraph_edges): Update.
> ? ? ? ?* cgraph.c: Do not include varrau.h
> ? ? ? ?(cgraph_set_call_stmt_including_clones, cgraph_create_edge_including_clones):
> ? ? ? ?New function
> ? ? ? ?(cgraph_update_edges_for_call_stmt_node): New stati cfunction.
> ? ? ? ?(cgraph_update_edges_for_call_stmt): Handle clones.
> ? ? ? ?(cgraph_remove_node): Handle clone tree.
> ? ? ? ?(cgraph_remove_node_and_inline_clones): New function.
> ? ? ? ?(dump_cgraph_node): Dump clone tree.
> ? ? ? ?(cgraph_clone_node): Handle clone tree.
> ? ? ? ?(clone_function_name): Bring here from tree-inline.c
> ? ? ? ?(cgraph_create_virtual_clone): New function.
> ? ? ? ?* cgraph.h (ipa_replace_map): Move ehre from ipa.h
> ? ? ? ?(cgraph_clone_info): New function
> ? ? ? ?(strut cgraph_node): Add clone_info and new clone tree pointers.
> ? ? ? ?(cgraph_remove_node_and_inline_clones, cgraph_set_call_stmt_including_clones,
> ? ? ? ?cgraph_create_edge_including_clones, cgraph_create_virtual_clone): Declare.
> ? ? ? ?(cgraph_function_versioning): Use VEC argument.
> ? ? ? ?(compute_call_stmt_bb_frequency): Update prototype.
> ? ? ? ?(cgraph_materialize_all_clones): New function.
> ? ? ? ?* ipa-cp.c (ipcp_update_cloned_node): Remove.
> ? ? ? ?(ipcp_create_replace_map): Update to VECtors.
> ? ? ? ?(ipcp_update_callgraph): Use virtual clones.
> ? ? ? ?(ipcp_update_bb_counts, ipcp_update_edges_counts): Remove.
> ? ? ? ?(ipcp_update_profiling): Do not update local profiling.
> ? ? ? ?(ipcp_insert_stage): Use VECtors and virtual clones.
> ? ? ? ?* cgraphunit.c (verify_cgraph_node): Verify clone tree.
> ? ? ? ?(clone_of_p): New function.
> ? ? ? ?(cgraph_preserve_function_body_p): Use clone tree.
> ? ? ? ?(cgraph_optimize): Materialize clones.
> ? ? ? ?(cgraph_function_versioning): Update for VECtors.
> ? ? ? ?(save_inline_function_body): Use clone tree.
> ? ? ? ?(cgraph_materialize_clone, cgraph_materialize_all_clones): New functions.
> ? ? ? ?* ipa-inline.c (cgraph_default_inline_p): Use analyzed flags.
> ? ? ? ?* ipa.c: Include gimple.h.
> ? ? ? ?(cgraph_remove_unreachable_nodes): Use clone tree.
> ? ? ? ?* ipa-prop.c (ipa_note_param_call): Update call of compute_call_stmt_bb_frequency.
> ? ? ? ?* ipa-prop.h (ipa_replace_map): Move to cgraph.h.
> ? ? ? ?* tree-inline.c: Do not include varray.h; do not include gt-tree-inline.h
> ? ? ? ?(copy_bb): Handle updating of clone tree; add new edge when new call
> ? ? ? ?appears.
> ? ? ? ?(expand_call_inline): Be strict about every call having edge.
> ? ? ? ?(clone_fn_id_num, clone_function_name): Move to cgraph.c.
> ? ? ? ?(delete_unreachable_blocks_update_callgraph): New function.
> ? ? ? ?(tree_function_versioning): Use VECtors; always remove unreachable blocks
> ? ? ? ?and fold conditionals.
> ? ? ? ?* tree-inline.h: Do not include varray.h
> ? ? ? ?(tree_function_versioning): Remove.
> ? ? ? ?* Makefile.in (GTFILES): Remove tree-inline.c
> ? ? ? ?* passes.c (do_per_function): Do only functions having body.
> ? ? ? ?* ipa-struct-reorg.c (do_reorg_1, collect_data_accesses): Handle cone tree.

This caused:

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


-- 
H.J.


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