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
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. */
else
return NULL;
}
-
\f
-/* 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;
/* 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;
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)
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 ++;
}
}
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));
}
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));
}
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));
}
&& TREE_STATIC (base))
{
struct cgraph_node *node = cgraph_node::get (callee);
- bitmap not_read;
/* FIXME: Callee can be an OMP builtin that does not have a call graph
node yet. We should enforce that there are nodes for all decls in the
IL and remove this check instead. */
- if (node
- && (not_read = ipa_reference_get_not_read_global (node))
- && bitmap_bit_p (not_read, DECL_UID (base)))
- goto process_args;
+ if (node)
+ {
+ enum availability avail;
+ bitmap not_read;
+
+ node = node->ultimate_alias_target (&avail);
+ if (avail >= AVAIL_AVAILABLE
+ && (not_read = ipa_reference_get_not_read_global (node))
+ && bitmap_bit_p (not_read, ipa_reference_var_uid (base)))
+ goto process_args;
+ }
}
/* Check if the base variable is call-used. */
&& TREE_STATIC (base))
{
struct cgraph_node *node = cgraph_node::get (callee);
- bitmap not_written;
- if (node
- && (not_written = ipa_reference_get_not_written_global (node))
- && bitmap_bit_p (not_written, DECL_UID (base)))
- return false;
+ if (node)
+ {
+ bitmap not_written;
+ enum availability avail;
+
+ node = node->ultimate_alias_target (&avail);
+ if (avail >= AVAIL_AVAILABLE
+ && (not_written = ipa_reference_get_not_written_global (node))
+ && bitmap_bit_p (not_written, ipa_reference_var_uid (base)))
+ return false;
+ }
}
/* Check if the base variable is call-clobbered. */