From 617695cdc2b3d950f1e4deb5ea85d5cc302943f4 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Sat, 31 Oct 2020 08:56:40 +0100 Subject: Handle fnspec in local ipa-modref * ipa-modref.c (modref_summary::dump): Dump writes_errno. (parm_map_for_arg): Break out from ... (merge_call_side_effects): ... here. (get_access_for_fnspec): New function. (process_fnspec): New function. (analyze_call): Use it. (analyze_stmt): Update. (analyze_function): Initialize writes_errno. (modref_summaries::duplicate): Duplicate writes_errno. * ipa-modref.h (struct modref_summary): Add writes_errno. * tree-ssa-alias.c (call_may_clobber_ref_p_1): Check errno. --- gcc/ipa-modref.h | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/ipa-modref.h') diff --git a/gcc/ipa-modref.h b/gcc/ipa-modref.h index 8828104..31ceffa 100644 --- a/gcc/ipa-modref.h +++ b/gcc/ipa-modref.h @@ -34,6 +34,7 @@ struct GTY(()) modref_summary ~modref_summary (); void dump (FILE *); bool useful_p (int ecf_flags); + bool writes_errno; }; modref_summary *get_modref_function_summary (cgraph_node *func); -- cgit v1.1 From 520d5ad337eaa15860a5a964daf7ca46cf31c029 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Sat, 14 Nov 2020 13:52:36 +0100 Subject: Detect EAF flags in ipa-modref A minimal patch for the EAF flags discovery. It works only in local ipa-modref and gives up on cyclic SSA graphs. It improves pt_solution_includes disambiguations twice. gcc/Changelog: * gimple.c: Include ipa-modref-tree.h and ipa-modref.h. (gimple_call_arg_flags): Use modref to determine flags. * ipa-modref.c: Include gimple-ssa.h, tree-phinodes.h, tree-ssa-operands.h, stringpool.h and tree-ssanames.h. (analyze_ssa_name_flags): Declare. (modref_summary::useful_p): Summary is also useful if arg flags are known. (dump_eaf_flags): New function. (modref_summary::dump): Use it. (get_modref_function_summary): Be read for current_function_decl being NULL. (memory_access_to): New function. (deref_flags): New function. (call_lhs_flags): New function. (analyze_parms): New function. (analyze_function): Use it. * ipa-modref.h (struct modref_summary): Add arg_flags. * doc/invoke.texi (ipa-modref-max-depth): Document. * params.opt (ipa-modref-max-depth): New param. --- gcc/ipa-modref.h | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/ipa-modref.h') diff --git a/gcc/ipa-modref.h b/gcc/ipa-modref.h index 31ceffa..5987230 100644 --- a/gcc/ipa-modref.h +++ b/gcc/ipa-modref.h @@ -29,6 +29,7 @@ struct GTY(()) modref_summary /* Load and stores in function (transitively closed to all callees) */ modref_records *loads; modref_records *stores; + auto_vec GTY((skip)) arg_flags; modref_summary (); ~modref_summary (); -- cgit v1.1 From 85ebbabd85e03bdc3afc190aeb29250606d18322 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Mon, 16 Nov 2020 19:30:45 +0100 Subject: IPA tracking of EAF flags in ipa-modref. this patch implements the IPA propagation part of EAF flags handling in ipa-modref. It extends the local analysis to collect lattice consisting of flags and escape points. SSA name escapes if it is passed directly or indirectly to a function call. If useful flags are found for parameter its escape list is stored into escape summaries. This time each call site is annotated with info on which function parameters escape to what argument of function call. At IPA time we then perform iterative dataflow and produce final flags. ipa-modref is still cheaper than pure-const when running on cc1plus (about 2-3% that is what accounts every non-trivial passs) and the dataflow converges in 1 or 2 iterations. Local analysis does some work to avoid streaming escape points when they are not useful to determine final flags (that is, local escape analysis determined good enough flags). For cc1plus there are 225k calls with useful escape summary. * ipa-modref.c (escape_point): New type. (modref_lattice): New type. (escape_entry): New type. (escape_summary): New type. (escape_summaries_t): New type. (escape_summaries): New static variable. (eaf_flags_useful_p): New function. (modref_summary::useful_p): Add new check_flags attribute; check eaf_flags for usefulness. (modref_summary_lto): Add arg_flags. (modref_summary_lto::useful_p): Add new check_flags attribute; check eaf_flags for usefulness. (dump_modref_edge_summaries): New function. (remove_modref_edge_summaries): New function. (ignore_retval_p): New predicate. (ignore_stores_p): Also ignore for const. (remove_summary): Call remove_modref_edge_summaries. (modref_lattice::init): New member function. (modref_lattice::release): New member unction. (modref_lattice::dump): New member function. (modref_lattice::add_escape_point): New member function. (modref_lattice::merge): Two new member functions. (modref_lattice::merge_deref): New member functions. (modref_lattice::merge_direct_load): New member function. (modref_lattice::merge_direct_store): New member function. (call_lhs_flags): Rename to ... (merge_call_lhs_flags): ... this one; reimplement using modreflattice. (analyze_ssa_name_flags): Replace KNOWN_FLAGS param by LATTICE; add IPA parametr; use modref_lattice. (analyze_parms): New parameter IPA and SUMMARY_LTO; update for modref_lattice; initialize escape_summary. (analyze_function): Allocate escape_summaries; update uses of useful_p. (modref_write_escape_summary): New function. (modref_read_escape_summary): New function. (modref_write): Write escape summary. (read_section): Read escape summary. (modref_read): Initialie escape_summaries. (remap_arg_flags): New function. (update_signature): Use it. (escape_map): New structure. (update_escape_summary_1, update_escape_summary): New functions. (ipa_merge_modref_summary_after_inlining): Merge escape summaries. (propagate_unknown_call): Do not remove useless summaries. (remove_useless_summaries): Remove them here. (modref_propagate_in_scc): Update; do not dump scc. (modref_propagate_dump_scc): New function. (modref_merge_call_site_flags): New function. (modref_propagate_flags_in_scc): New function. (pass_ipa_modref::execute): Use modref_propagate_flags_in_scc and modref_propagate_dump_scc; delete escape_summaries. (ipa_modref_c_finalize): Remove escape_summaries. * ipa-modref.h (modref_summary): Update prototype of useful_p. * params.opt (param=modref-max-escape-points): New param. * doc/invoke.texi (modref-max-escape-points): Document. --- gcc/ipa-modref.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/ipa-modref.h') diff --git a/gcc/ipa-modref.h b/gcc/ipa-modref.h index 5987230..7decabd 100644 --- a/gcc/ipa-modref.h +++ b/gcc/ipa-modref.h @@ -30,12 +30,12 @@ struct GTY(()) modref_summary modref_records *loads; modref_records *stores; auto_vec GTY((skip)) arg_flags; + bool writes_errno; modref_summary (); ~modref_summary (); void dump (FILE *); - bool useful_p (int ecf_flags); - bool writes_errno; + bool useful_p (int ecf_flags, bool check_flags = true); }; modref_summary *get_modref_function_summary (cgraph_node *func); -- cgit v1.1