diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-01-18 17:42:11 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-01-18 17:42:11 +0000 |
commit | bfedbed14d7bfcd59070c25f70ea7d0859beb92e (patch) | |
tree | 8adefaf359f0ba900559f677e0e56f23f125b6f0 /gcc/ipa-reference.c | |
parent | 2c9d5cb8354d561bbfa418895cb6158c1c855e75 (diff) | |
download | gcc-bfedbed14d7bfcd59070c25f70ea7d0859beb92e.tar.gz |
* gcc.dg/ipa/ipa-icf-32.c: Update template.
* c-c++-common/asan/instrument-with-calls-3.c: Likewise.
* c-c++-common/asan/instrument-with-calls-2.c: Likewise.
* c-c++-common/asan/instrument-with-calls-1.c: Likewise.
* c-c++-common/asan/kasan-recover-1.c: Likewise.
* c-c++-common/asan/kasan-recover-2.c: Likewise.
* ipa-reference.c (set_reference_optimization_summary,
ipa_reference_get_not_written_global): Do nothing if ipa-reference is disabled.
(ignore_module_statics): New static var.
(propagate_bits): If ipa-reference is disabled, do not look into local properties.
(analyze_function): Disable analysis when ipa_reference is disabled.
(generate_summary): Do not dump when reference is disabled;
collect vars accessed from functions with ipa-reference disabled.
(get_read_write_all_from_node): When ipa-reference is disabled, use the
node flags.
(gate): Enable for LTO.
(ignore_edge_p): New function.
(propagate): Skip functions w/o ipa-reference analysis.
* optc-save-gen.awk: Handle optimize_debug correctly.
* opth-gen.awk: Likewise.
* common.opt (fauto-inc-dec, fdelete-dead-exceptions, ffunction-cse,
fgraphite, fstrict-volatile-bitfields, fira-algorithm, fira-region,
fira-share-save-slots, fira-share-spill-slots,
fmodulo-sched-allow-regmoves, fpartial-inlining,
sched-stalled-insns, fsched-stalled-insns-dep, fstrict-overflow,
ftracer, ftree-parallelize-loops, fassociative-math,
freciprocal-math, fvect-cost-model, fsimd-cost-model): Mark as
Optimization
(fauto-profile, fcommon, fdata-sections, fipa-icf-variables,
ftoplevel-reorder, funit-at-a-time, fwhole-program): Do not mark as
Optimization.
* ipa-icf.c (gate, sem_item_optimizer::filter_removed_items):
Fix for IPA.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219823 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ipa-reference.c')
-rw-r--r-- | gcc/ipa-reference.c | 68 |
1 files changed, 57 insertions, 11 deletions
diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c index 784c1df8d18..6a677ca502c 100644 --- a/gcc/ipa-reference.c +++ b/gcc/ipa-reference.c @@ -132,6 +132,9 @@ static splay_tree reference_vars_to_consider; static we are considering. This is added to the local info when asm code is found that clobbers all memory. */ static bitmap all_module_statics; +/* Set of all statics that should be ignored becuase they are touched by + -fno-ipa-reference code. */ +static bitmap ignore_module_statics; /* Obstack holding bitmaps of local analysis (live from analysis to propagation) */ @@ -198,6 +201,9 @@ set_reference_optimization_summary (struct cgraph_node *node, bitmap ipa_reference_get_not_read_global (struct cgraph_node *fn) { + if (!opt_for_fn (fn->decl, flag_ipa_reference) + || !opt_for_fn (current_function_decl, flag_ipa_reference)) + return NULL; ipa_reference_optimization_summary_t info = get_reference_optimization_summary (fn->function_symbol (NULL)); if (info) @@ -216,6 +222,9 @@ ipa_reference_get_not_read_global (struct cgraph_node *fn) bitmap ipa_reference_get_not_written_global (struct cgraph_node *fn) { + if (!opt_for_fn (fn->decl, flag_ipa_reference) + || !opt_for_fn (current_function_decl, flag_ipa_reference)) + return NULL; ipa_reference_optimization_summary_t info = get_reference_optimization_summary (fn); if (info) @@ -273,6 +282,8 @@ is_proper_for_analysis (tree t) return false; /* TODO: Check aliases. */ + if (bitmap_bit_p (ignore_module_statics, DECL_UID (t))) + return false; /* This is a variable we care about. Check if we have seen it before, and if not add it the set of variables we care about. */ @@ -381,8 +392,9 @@ propagate_bits (ipa_reference_global_vars_info_t x_global, struct cgraph_node *x /* Only look into nodes we can propagate something. */ int flags = flags_from_decl_or_type (y->decl); - if (avail > AVAIL_INTERPOSABLE - || (avail == AVAIL_INTERPOSABLE && (flags & ECF_LEAF))) + if (opt_for_fn (y->decl, flag_ipa_reference) + && (avail > AVAIL_INTERPOSABLE + || (avail == AVAIL_INTERPOSABLE && (flags & ECF_LEAF)))) { if (get_reference_vars_info (y)) { @@ -437,6 +449,7 @@ ipa_init (void) bitmap_obstack_initialize (&local_info_obstack); bitmap_obstack_initialize (&optimization_summary_obstack); all_module_statics = BITMAP_ALLOC (&optimization_summary_obstack); + ignore_module_statics = BITMAP_ALLOC (&optimization_summary_obstack); node_removal_hook_holder = symtab->add_cgraph_removal_hook (&remove_node_data, NULL); @@ -474,6 +487,8 @@ analyze_function (struct cgraph_node *fn) int i; tree var; + if (!opt_for_fn (fn->decl, flag_ipa_reference)) + return; local = init_function_info (fn); for (i = 0; fn->iterate_reference (i, ref); i++) { @@ -559,6 +574,22 @@ generate_summary (void) /* Process all of the functions next. */ FOR_EACH_DEFINED_FUNCTION (node) + if (!node->alias && !opt_for_fn (node->decl, flag_ipa_reference)) + { + struct ipa_ref *ref = NULL; + int i; + tree var; + for (i = 0; node->iterate_reference (i, ref); i++) + { + if (!is_a <varpool_node *> (ref->referred)) + continue; + var = ref->referred->decl; + if (!is_proper_for_analysis (var)) + continue; + bitmap_set_bit (ignore_module_statics, DECL_UID (var)); + } + } + FOR_EACH_DEFINED_FUNCTION (node) analyze_function (node); if (dump_file) @@ -570,7 +601,8 @@ generate_summary (void) if (dump_file) FOR_EACH_DEFINED_FUNCTION (node) - if (node->get_availability () >= AVAIL_INTERPOSABLE) + if (node->get_availability () >= AVAIL_INTERPOSABLE + && opt_for_fn (node->decl, flag_ipa_reference)) { ipa_reference_local_vars_info_t l; unsigned int index; @@ -607,7 +639,7 @@ read_write_all_from_decl (struct cgraph_node *node, tree decl = node->decl; int flags = flags_from_decl_or_type (decl); if ((flags & ECF_LEAF) - && node->get_availability () <= AVAIL_INTERPOSABLE) + && node->get_availability () < AVAIL_INTERPOSABLE) ; else if (flags & ECF_CONST) ; @@ -640,7 +672,8 @@ get_read_write_all_from_node (struct cgraph_node *node, struct cgraph_edge *e, *ie; /* When function is overwritable, we can not assume anything. */ - if (node->get_availability () <= AVAIL_INTERPOSABLE) + if (node->get_availability () <= AVAIL_INTERPOSABLE + || (node->analyzed && !opt_for_fn (node->decl, flag_ipa_reference))) read_write_all_from_decl (node, read_all, write_all); for (e = node->callees; @@ -650,7 +683,8 @@ get_read_write_all_from_node (struct cgraph_node *node, enum availability avail; struct cgraph_node *callee = e->callee->function_symbol (&avail); gcc_checking_assert (callee); - if (avail <= AVAIL_INTERPOSABLE) + if (avail <= AVAIL_INTERPOSABLE + || (callee->analyzed && !opt_for_fn (callee->decl, flag_ipa_reference))) read_write_all_from_decl (callee, read_all, write_all); } @@ -672,6 +706,18 @@ get_read_write_all_from_node (struct cgraph_node *node, } } +/* Skip edges from and to nodes without ipa_reference enables. This leave + them out of strongy connected coponents and makes them easyto skip in the + propagation loop bellow. */ + +static bool +ignore_edge_p (cgraph_edge *e) +{ + return (!opt_for_fn (e->caller->decl, flag_ipa_reference) + || !opt_for_fn (e->callee->function_symbol ()->decl, + flag_ipa_reference)); +} + /* Produce the global information by preforming a transitive closure on the local information that was produced by ipa_analyze_function. */ @@ -695,7 +741,7 @@ propagate (void) the global information. All the nodes within a cycle will have the same info so we collapse cycles first. Then we can do the propagation in one pass from the leaves to the roots. */ - order_pos = ipa_reduced_postorder (order, true, true, NULL); + order_pos = ipa_reduced_postorder (order, true, true, ignore_edge_p); if (dump_file) ipa_print_order (dump_file, "reduced", order, order_pos); @@ -710,7 +756,7 @@ propagate (void) bool write_all = false; node = order[i]; - if (node->alias) + if (node->alias || !opt_for_fn (node->decl, flag_ipa_reference)) continue; node_info = get_reference_vars_info (node); @@ -788,7 +834,7 @@ propagate (void) struct cgraph_node *w; node = order[i]; - if (node->alias) + if (node->alias || !opt_for_fn (node->decl, flag_ipa_reference)) continue; fprintf (dump_file, @@ -829,7 +875,7 @@ propagate (void) ipa_reference_optimization_summary_t opt; node_info = get_reference_vars_info (node); - if (!node->alias + if (!node->alias && opt_for_fn (node->decl, flag_ipa_reference) && (node->get_availability () > AVAIL_INTERPOSABLE || (flags_from_decl_or_type (node->decl) & ECF_LEAF))) { @@ -1178,7 +1224,7 @@ public: /* opt_pass methods: */ virtual bool gate (function *) { - return (flag_ipa_reference + return ((in_lto_p || flag_ipa_reference) /* Don't bother doing anything if the program has errors. */ && !seen_error ()); } |