diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2015-12-09 08:34:16 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2015-12-09 07:34:16 +0000 |
commit | 37074a02aee862ae15867e40aa5a12db616657b6 (patch) | |
tree | a589b3f752ddc9ef0c99801a8a2355889655a259 /gcc/ipa-reference.c | |
parent | 04d2fbcc5fa0a0464e847d1bf3faeb83d67711c2 (diff) | |
download | gcc-37074a02aee862ae15867e40aa5a12db616657b6.zip gcc-37074a02aee862ae15867e40aa5a12db616657b6.tar.gz gcc-37074a02aee862ae15867e40aa5a12db616657b6.tar.bz2 |
re PR lto/61886 (LTO breaks fread with _FORTIFY_SOURCE=2)
PR ipa/61886
PR middle-end/25140
* ipa-reference.c (is_improper): Break out from ...
(is_proper_for_analysis): ... here; fix WRT aliases.
(analyze_function, generate_summary,
ipa_reference_write_optimization_summary,
ipa_reference_read_optimization_summary): Use ipa_reference_var_uid.
* ipa-refrence.h (ipa_reference_var_uid): New inline.
* tree-ssa-alias.c (ref_maybe_used_by_call_p_1,
call_may_clobber_ref_p_1): Use ipa_reference_var_uid.
* gcc.c-torture/execute/alias-3.c: New testcase.
From-SVN: r231442
Diffstat (limited to 'gcc/ipa-reference.c')
-rw-r--r-- | gcc/ipa-reference.c | 73 |
1 files changed, 45 insertions, 28 deletions
diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c index 88c4997..be98cdc 100644 --- a/gcc/ipa-reference.c +++ b/gcc/ipa-reference.c @@ -167,8 +167,8 @@ set_reference_optimization_summary (struct cgraph_node *node, ipa_reference_opt_sum_vector[node->uid] = info; } -/* Return a bitmap indexed by DECL_UID for the static variables that - are *not* read during the execution of the function FN. Returns +/* Return a bitmap indexed by ipa_reference_var_uid for the static variables + that are *not* read during the execution of the function FN. Returns NULL if no data is available. */ bitmap @@ -187,8 +187,8 @@ ipa_reference_get_not_read_global (struct cgraph_node *fn) return NULL; } -/* Return a bitmap indexed by DECL_UID for the static variables that - are *not* written during the execution of the function FN. Note +/* Return a bitmap indexed by ipa_reference_var_uid for the static variables + that are *not* written during the execution of the function FN. Note that variables written may or may not be read during the function call. Returns NULL if no data is available. */ @@ -207,40 +207,51 @@ ipa_reference_get_not_written_global (struct cgraph_node *fn) else return NULL; } - -/* Return true if the variable T is the right kind of static variable to - perform compilation unit scope escape analysis. */ -static inline bool -is_proper_for_analysis (tree t) +/* Hepler for is_proper_for_analysis. */ +static bool +is_improper (symtab_node *n, void *v ATTRIBUTE_UNUSED) { + tree t = n->decl; /* If the variable has the "used" attribute, treat it as if it had a been touched by the devil. */ if (DECL_PRESERVE_P (t)) - return false; + return true; /* Do not want to do anything with volatile except mark any function that uses one to be not const or pure. */ if (TREE_THIS_VOLATILE (t)) - return false; + return true; /* We do not need to analyze readonly vars, we already know they do not alias. */ if (TREE_READONLY (t)) - return false; + return true; /* We can not track variables with address taken. */ if (TREE_ADDRESSABLE (t)) - return false; + return true; - /* TODO: We could track public variables that are not addressable, but currently - frontends don't give us those. */ + /* TODO: We could track public variables that are not addressable, but + currently frontends don't give us those. */ if (TREE_PUBLIC (t)) + return true; + + return false; +} + +/* Return true if the variable T is the right kind of static variable to + perform compilation unit scope escape analysis. */ + +static inline bool +is_proper_for_analysis (tree t) +{ + if (bitmap_bit_p (ignore_module_statics, ipa_reference_var_uid (t))) return false; - /* TODO: Check aliases. */ - if (bitmap_bit_p (ignore_module_statics, DECL_UID (t))) + if (symtab_node::get (t) + ->call_for_symbol_and_aliases (is_improper, NULL, true)) return false; return true; @@ -452,21 +463,22 @@ analyze_function (struct cgraph_node *fn) /* 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. */ if (all_module_statics - && bitmap_set_bit (all_module_statics, DECL_UID (var))) + && bitmap_set_bit (all_module_statics, ipa_reference_var_uid (var))) { if (dump_file) splay_tree_insert (reference_vars_to_consider, - DECL_UID (var), (splay_tree_value)var); + ipa_reference_var_uid (var), + (splay_tree_value)var); } switch (ref->use) { case IPA_REF_LOAD: - bitmap_set_bit (local->statics_read, DECL_UID (var)); + bitmap_set_bit (local->statics_read, ipa_reference_var_uid (var)); break; case IPA_REF_STORE: if (ref->cannot_lead_to_return ()) break; - bitmap_set_bit (local->statics_written, DECL_UID (var)); + bitmap_set_bit (local->statics_written, ipa_reference_var_uid (var)); break; case IPA_REF_ADDR: break; @@ -547,7 +559,7 @@ generate_summary (void) var = ref->referred->decl; if (!is_proper_for_analysis (var)) continue; - bitmap_set_bit (ignore_module_statics, DECL_UID (var)); + bitmap_set_bit (ignore_module_statics, ipa_reference_var_uid (var)); } } FOR_EACH_DEFINED_FUNCTION (node) @@ -975,13 +987,15 @@ ipa_reference_write_optimization_summary (void) symtab_node *snode = lto_symtab_encoder_deref (encoder, i); varpool_node *vnode = dyn_cast <varpool_node *> (snode); if (vnode - && bitmap_bit_p (all_module_statics, DECL_UID (vnode->decl)) + && bitmap_bit_p (all_module_statics, + ipa_reference_var_uid (vnode->decl)) && referenced_from_this_partition_p (vnode, encoder)) { tree decl = vnode->decl; - bitmap_set_bit (ltrans_statics, DECL_UID (decl)); + bitmap_set_bit (ltrans_statics, ipa_reference_var_uid (decl)); splay_tree_insert (reference_vars_to_consider, - DECL_UID (decl), (splay_tree_value)decl); + ipa_reference_var_uid (decl), + (splay_tree_value)decl); ltrans_statics_bitcount ++; } } @@ -1067,7 +1081,8 @@ ipa_reference_read_optimization_summary (void) unsigned int var_index = streamer_read_uhwi (ib); tree v_decl = lto_file_decl_data_get_var_decl (file_data, var_index); - bitmap_set_bit (all_module_statics, DECL_UID (v_decl)); + bitmap_set_bit (all_module_statics, + ipa_reference_var_uid (v_decl)); if (dump_file) fprintf (dump_file, " %s", fndecl_name (v_decl)); } @@ -1107,7 +1122,8 @@ ipa_reference_read_optimization_summary (void) unsigned int var_index = streamer_read_uhwi (ib); tree v_decl = lto_file_decl_data_get_var_decl (file_data, var_index); - bitmap_set_bit (info->statics_not_read, DECL_UID (v_decl)); + bitmap_set_bit (info->statics_not_read, + ipa_reference_var_uid (v_decl)); if (dump_file) fprintf (dump_file, " %s", fndecl_name (v_decl)); } @@ -1129,7 +1145,8 @@ ipa_reference_read_optimization_summary (void) unsigned int var_index = streamer_read_uhwi (ib); tree v_decl = lto_file_decl_data_get_var_decl (file_data, var_index); - bitmap_set_bit (info->statics_not_written, DECL_UID (v_decl)); + bitmap_set_bit (info->statics_not_written, + ipa_reference_var_uid (v_decl)); if (dump_file) fprintf (dump_file, " %s", fndecl_name (v_decl)); } |