diff options
author | Jan Hubicka <jh@suse.cz> | 2020-10-26 11:24:33 +0100 |
---|---|---|
committer | Jan Hubicka <jh@suse.cz> | 2020-10-26 11:24:33 +0100 |
commit | 40e67ab8e59cf1c558f2818625c7e06dbf7a8e50 (patch) | |
tree | a949d436af2b24b4dcf1d15dd96045e6ec8f7f9b /gcc/ipa-sra.c | |
parent | dc7824734e6589bac2ba0f8363d24d50da8cfeae (diff) | |
download | gcc-40e67ab8e59cf1c558f2818625c7e06dbf7a8e50.zip gcc-40e67ab8e59cf1c558f2818625c7e06dbf7a8e50.tar.gz gcc-40e67ab8e59cf1c558f2818625c7e06dbf7a8e50.tar.bz2 |
Make default duplicate and insert methods of summaries abort; fix fallout
the default duplicate and insert methods of sumaries produce empty
summary that is not useful for anything and makes it easy to introduce
bugs.
This patch makes the default hooks to abort and summaries that do not
need dupicaito/insertion disable the corresponding hooks. I also
implemented missing insertion hook for ipa-sra which forced me to move
analysis out of anonymous namespace.
2020-10-23 Jan Hubicka <hubicka@ucw.cz>
* cgraph.h (struct cgraph_node): Make ipa_transforms_to_apply vl_ptr.
* ipa-inline-analysis.c (initialize_growth_caches): Disable insertion
and duplication hooks.
* ipa-inline-transform.c (clone_inlined_nodes): Clear
ipa_transforms_to_apply.
(save_inline_function_body): Disable insertion hoook for
ipa_saved_clone_sources.
* ipa-prop.c (ipcp_transformation_initialize): Disable insertion hook.
* ipa-prop.h (ipa_node_params_t): Disable insertion hook.
* ipa-reference.c (propagate): Disable insertion hoook.
* ipa-sra.c (ipa_sra_summarize_function): Move out of anonymous
namespace.
(ipa_sra_function_summaries::insert): New virtual function.
* passes.c (execute_one_pass): Do not add transforms to inline clones.
* symbol-summary.h (function_summary_base): Make insert and duplicate
hooks fail instead of silently producing empty summaries; add way to
disable duplication hooks
(call_summary_base): Likewise.
* tree-nested.c (nested_function_info::get_create): Disable insertion
hooks
(maybe_record_nested_function): Likewise.
Diffstat (limited to 'gcc/ipa-sra.c')
-rw-r--r-- | gcc/ipa-sra.c | 164 |
1 files changed, 91 insertions, 73 deletions
diff --git a/gcc/ipa-sra.c b/gcc/ipa-sra.c index 8d4f580..07227c0 100644 --- a/gcc/ipa-sra.c +++ b/gcc/ipa-sra.c @@ -85,6 +85,8 @@ along with GCC; see the file COPYING3. If not see #include "tree-streamer.h" #include "internal-fn.h" +static void ipa_sra_summarize_function (cgraph_node *); + /* Bits used to track size of an aggregate in bytes interprocedurally. */ #define ISRA_ARG_SIZE_LIMIT_BITS 16 #define ISRA_ARG_SIZE_LIMIT (1 << ISRA_ARG_SIZE_LIMIT_BITS) @@ -373,6 +375,7 @@ public: virtual void duplicate (cgraph_node *, cgraph_node *, isra_func_summary *old_sum, isra_func_summary *new_sum); + virtual void insert (cgraph_node *, isra_func_summary *); }; /* Hook that is called by summary when a node is duplicated. */ @@ -426,6 +429,21 @@ ipa_sra_function_summaries::duplicate (cgraph_node *, cgraph_node *, static GTY(()) ipa_sra_function_summaries *func_sums; +/* Hook that is called by summary when new node appears. */ + +void +ipa_sra_function_summaries::insert (cgraph_node *node, isra_func_summary *) +{ + if (opt_for_fn (node->decl, flag_ipa_sra)) + { + push_cfun (DECL_STRUCT_FUNCTION (node->decl)); + ipa_sra_summarize_function (node); + pop_cfun (); + } + else + func_sums->remove (node); +} + /* Class to manage call summaries. */ class ipa_sra_call_summaries: public call_summary <isra_call_summary *> @@ -2478,79 +2496,6 @@ verify_splitting_accesses (cgraph_node *node, bool certain_must_exist) } } -/* Intraprocedural part of IPA-SRA analysis. Scan function body of NODE and - create a summary structure describing IPA-SRA opportunities and constraints - in it. */ - -static void -ipa_sra_summarize_function (cgraph_node *node) -{ - if (dump_file) - fprintf (dump_file, "Creating summary for %s/%i:\n", node->name (), - node->order); - if (!ipa_sra_preliminary_function_checks (node)) - return; - gcc_obstack_init (&gensum_obstack); - isra_func_summary *ifs = func_sums->get_create (node); - ifs->m_candidate = true; - tree ret = TREE_TYPE (TREE_TYPE (node->decl)); - ifs->m_returns_value = (TREE_CODE (ret) != VOID_TYPE); - - decl2desc = new hash_map<tree, gensum_param_desc *>; - unsigned count = 0; - for (tree parm = DECL_ARGUMENTS (node->decl); parm; parm = DECL_CHAIN (parm)) - count++; - - if (count > 0) - { - auto_vec<gensum_param_desc, 16> param_descriptions (count); - param_descriptions.reserve_exact (count); - param_descriptions.quick_grow_cleared (count); - - bool cfun_pushed = false; - struct function *fun = DECL_STRUCT_FUNCTION (node->decl); - if (create_parameter_descriptors (node, ¶m_descriptions)) - { - push_cfun (fun); - cfun_pushed = true; - final_bbs = BITMAP_ALLOC (NULL); - bb_dereferences = XCNEWVEC (HOST_WIDE_INT, - by_ref_count - * last_basic_block_for_fn (fun)); - aa_walking_limit = opt_for_fn (node->decl, param_ipa_max_aa_steps); - scan_function (node, fun); - - if (dump_file) - { - dump_gensum_param_descriptors (dump_file, node->decl, - ¶m_descriptions); - fprintf (dump_file, "----------------------------------------\n"); - } - } - process_scan_results (node, fun, ifs, ¶m_descriptions); - - if (cfun_pushed) - pop_cfun (); - if (bb_dereferences) - { - free (bb_dereferences); - bb_dereferences = NULL; - BITMAP_FREE (final_bbs); - final_bbs = NULL; - } - } - isra_analyze_all_outgoing_calls (node); - - delete decl2desc; - decl2desc = NULL; - obstack_free (&gensum_obstack, NULL); - if (dump_file) - fprintf (dump_file, "\n\n"); - if (flag_checking) - verify_splitting_accesses (node, false); - return; -} - /* Intraprocedural part of IPA-SRA analysis. Scan bodies of all functions in this compilation unit and create summary structures describing IPA-SRA opportunities and constraints in them. */ @@ -4102,6 +4047,79 @@ public: } // anon namespace +/* Intraprocedural part of IPA-SRA analysis. Scan function body of NODE and + create a summary structure describing IPA-SRA opportunities and constraints + in it. */ + +static void +ipa_sra_summarize_function (cgraph_node *node) +{ + if (dump_file) + fprintf (dump_file, "Creating summary for %s/%i:\n", node->name (), + node->order); + if (!ipa_sra_preliminary_function_checks (node)) + return; + gcc_obstack_init (&gensum_obstack); + isra_func_summary *ifs = func_sums->get_create (node); + ifs->m_candidate = true; + tree ret = TREE_TYPE (TREE_TYPE (node->decl)); + ifs->m_returns_value = (TREE_CODE (ret) != VOID_TYPE); + + decl2desc = new hash_map<tree, gensum_param_desc *>; + unsigned count = 0; + for (tree parm = DECL_ARGUMENTS (node->decl); parm; parm = DECL_CHAIN (parm)) + count++; + + if (count > 0) + { + auto_vec<gensum_param_desc, 16> param_descriptions (count); + param_descriptions.reserve_exact (count); + param_descriptions.quick_grow_cleared (count); + + bool cfun_pushed = false; + struct function *fun = DECL_STRUCT_FUNCTION (node->decl); + if (create_parameter_descriptors (node, ¶m_descriptions)) + { + push_cfun (fun); + cfun_pushed = true; + final_bbs = BITMAP_ALLOC (NULL); + bb_dereferences = XCNEWVEC (HOST_WIDE_INT, + by_ref_count + * last_basic_block_for_fn (fun)); + aa_walking_limit = opt_for_fn (node->decl, param_ipa_max_aa_steps); + scan_function (node, fun); + + if (dump_file) + { + dump_gensum_param_descriptors (dump_file, node->decl, + ¶m_descriptions); + fprintf (dump_file, "----------------------------------------\n"); + } + } + process_scan_results (node, fun, ifs, ¶m_descriptions); + + if (cfun_pushed) + pop_cfun (); + if (bb_dereferences) + { + free (bb_dereferences); + bb_dereferences = NULL; + BITMAP_FREE (final_bbs); + final_bbs = NULL; + } + } + isra_analyze_all_outgoing_calls (node); + + delete decl2desc; + decl2desc = NULL; + obstack_free (&gensum_obstack, NULL); + if (dump_file) + fprintf (dump_file, "\n\n"); + if (flag_checking) + verify_splitting_accesses (node, false); + return; +} + ipa_opt_pass_d * make_pass_ipa_sra (gcc::context *ctxt) { |