static inline ipa_reference_vars_info_t
get_reference_vars_info_from_cgraph (struct cgraph_node * node)
{
- return get_var_ann (node->decl)->reference_vars_info;
+ return get_function_ann (node->decl)->reference_vars_info;
}
/* Get a bitmap that contains all of the locally referenced static
static ipa_reference_local_vars_info_t
get_local_reference_vars_info (tree fn)
{
- ipa_reference_vars_info_t info = get_var_ann (fn)->reference_vars_info;
+ ipa_reference_vars_info_t info = get_function_ann (fn)->reference_vars_info;
if (info)
return info->local;
static ipa_reference_global_vars_info_t
get_global_reference_vars_info (tree fn)
{
- ipa_reference_vars_info_t info = get_var_ann (fn)->reference_vars_info;
+ ipa_reference_vars_info_t info = get_function_ann (fn)->reference_vars_info;
if (info)
return info->global;
{
if (!t) return;
- if ((TREE_CODE (t) == VAR_DECL)
+ if ((TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == FUNCTION_DECL)
&& (has_proper_scope_for_analysis (t)))
{
if (checking_write)
if (TREE_CODE (t) == ADDR_EXPR)
{
tree x = get_base_var (t);
- if (TREE_CODE (x) == VAR_DECL)
+ if (TREE_CODE (x) == VAR_DECL || TREE_CODE (x) == FUNCTION_DECL)
if (has_proper_scope_for_analysis (x))
bitmap_set_bit (module_statics_escape, DECL_UID (x));
}
static void
ipa_init (void)
{
+ struct cgraph_node *node;
memory_identifier_string = build_string(7, "memory");
reference_vars_to_consider =
module_statics_written = BITMAP_ALLOC (&ipa_obstack);
all_module_statics = BITMAP_ALLOC (&ipa_obstack);
+ /* This will add NODE->DECL to the splay trees. */
+ for (node = cgraph_nodes; node; node = node->next)
+ has_proper_scope_for_analysis (node->decl);
+
/* There are some shared nodes, in particular the initializers on
static declarations. We do not need to scan them more than once
since all we would be interested in are the addressof
tree decl = fn->decl;
/* Add the info to the tree's annotation. */
- get_var_ann (fn->decl)->reference_vars_info = info;
+ get_function_ann (fn->decl)->reference_vars_info = info;
info->local = l;
l->statics_read = BITMAP_ALLOC (&ipa_obstack);
}
- free (get_var_ann (fn->decl)->reference_vars_info);
- get_var_ann (fn->decl)->reference_vars_info = NULL;
+ free (get_function_ann (fn->decl)->reference_vars_info);
+ get_function_ann (fn->decl)->reference_vars_info = NULL;
}
\f
on the local information that was produced by ipa_analyze_function
and ipa_analyze_variable. */
-static void
+static unsigned int
static_execute (void)
{
struct cgraph_node *node;
EXECUTE_IF_SET_IN_BITMAP (module_statics_readonly, 0, index, bi)
{
tree var = get_static_decl (index);
- TREE_READONLY (var) = 1;
- if (dump_file)
- fprintf (dump_file, "read-only var %s\n",
- get_static_name (index));
+
+ /* Readonly on a function decl is very different from the
+ variable. */
+ if (TREE_CODE (var) == FUNCTION_DECL)
+ continue;
+
+ /* Ignore variables in named sections - changing TREE_READONLY
+ changes the section flags, potentially causing conflicts with
+ other variables in the same named section. */
+ if (DECL_SECTION_NAME (var) == NULL_TREE)
+ {
+ TREE_READONLY (var) = 1;
+ if (dump_file)
+ fprintf (dump_file, "read-only var %s\n",
+ get_static_name (index));
+ }
if (DECL_INITIAL (var)
&& is_gimple_min_invariant (DECL_INITIAL (var)))
{
&& (cgraph_function_body_availability (node) == AVAIL_OVERWRITABLE))
clean_function (node);
}
+ return 0;
}