/* Callgraph based analysis of static variables.
- Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
Contributed by Kenneth Zadeck <zadeck@naturalbridge.com>
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
+Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
for more details.
You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING. If not, write to the Free
-Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301, USA.
-*/
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
/* This file gathers information about how variables whose scope is
confined to the compilation unit are used.
if (DECL_EXTERNAL (t) || TREE_PUBLIC (t))
return false;
+ /* We cannot touch decls where the type needs constructing. */
+ if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (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. */
if (!bitmap_bit_p (all_module_statics, DECL_UID (t)))
check_call (ipa_reference_local_vars_info_t local, tree call_expr)
{
int flags = call_expr_flags (call_expr);
- tree operand_list = TREE_OPERAND (call_expr, 1);
tree operand;
tree callee_t = get_callee_fndecl (call_expr);
enum availability avail = AVAIL_NOT_AVAILABLE;
+ call_expr_arg_iterator iter;
- for (operand = operand_list;
- operand != NULL_TREE;
- operand = TREE_CHAIN (operand))
- {
- tree argument = TREE_VALUE (operand);
- check_rhs_var (local, argument);
- }
+ FOR_EACH_CALL_EXPR_ARG (operand, iter, call_expr)
+ check_rhs_var (local, operand);
if (callee_t)
{
int *walk_subtrees,
void *data)
{
- struct cgraph_node *fn = data;
+ struct cgraph_node *fn = (struct cgraph_node *) data;
tree t = *tp;
ipa_reference_local_vars_info_t local = NULL;
if (fn)
case ADDR_EXPR:
check_rhs_var (local, rhs);
break;
- case CALL_EXPR:
+ default:
+ break;
+ }
+ break;
+ case tcc_vl_exp:
+ switch (TREE_CODE (rhs))
+ {
+ case CALL_EXPR:
check_call (local, rhs);
break;
default:
get_reference_vars_info_from_cgraph (target)->local;
/* Make the world safe for tail recursion. */
- struct ipa_dfs_info *node_info = x->aux;
+ struct ipa_dfs_info *node_info = (struct ipa_dfs_info *) x->aux;
if (node_info->aux)
return;
analyze_function (struct cgraph_node *fn)
{
ipa_reference_vars_info_t info
- = xcalloc (1, sizeof (struct ipa_reference_vars_info_d));
+ = XCNEW (struct ipa_reference_vars_info_d);
ipa_reference_local_vars_info_t l
- = xcalloc (1, sizeof (struct ipa_reference_local_vars_info_d));
+ = XCNEW (struct ipa_reference_local_vars_info_d);
tree decl = fn->decl;
/* Add the info to the tree's annotation. */
FOR_EACH_BB_FN (this_block, this_cfun)
{
block_stmt_iterator bsi;
+ tree phi, op;
+ use_operand_p use;
+ ssa_op_iter iter;
+
+ /* Find the addresses taken in phi node arguments. */
+ for (phi = phi_nodes (this_block); phi; phi = PHI_CHAIN (phi))
+ {
+ FOR_EACH_PHI_ARG (use, phi, iter, SSA_OP_USE)
+ {
+ op = USE_FROM_PTR (use);
+ if (TREE_CODE (op) == ADDR_EXPR)
+ check_rhs_var (l, op);
+ }
+ }
+
for (bsi = bsi_start (this_block); !bsi_end_p (bsi); bsi_next (&bsi))
walk_tree (bsi_stmt_ptr (bsi), scan_for_static_refs,
fn, visited_nodes);
struct varpool_node *vnode;
struct cgraph_node *w;
struct cgraph_node **order =
- xcalloc (cgraph_n_nodes, sizeof (struct cgraph_node *));
- int order_pos = order_pos = ipa_utils_reduced_inorder (order, false, true);
+ XCNEWVEC (struct cgraph_node *, cgraph_n_nodes);
+ int order_pos = ipa_utils_reduced_inorder (order, false, true);
int i;
ipa_init ();
{
ipa_reference_vars_info_t node_info;
ipa_reference_global_vars_info_t node_g =
- xcalloc (1, sizeof (struct ipa_reference_global_vars_info_d));
+ XCNEW (struct ipa_reference_global_vars_info_d);
ipa_reference_local_vars_info_t node_l;
bool read_all;
/* If any node in a cycle is calls_read_all or calls_write_all
they all are. */
- w_info = node->aux;
+ w_info = (struct ipa_dfs_info *) node->aux;
w = w_info->next_cycle;
while (w)
{
read_all |= w_l->calls_read_all;
write_all |= w_l->calls_write_all;
- w_info = w->aux;
+ w_info = (struct ipa_dfs_info *) w->aux;
w = w_info->next_cycle;
}
node_l->statics_written);
}
- w_info = node->aux;
+ w_info = (struct ipa_dfs_info *) node->aux;
w = w_info->next_cycle;
while (w)
{
if (!write_all)
bitmap_ior_into (node_g->statics_written,
w_l->statics_written);
- w_info = w->aux;
+ w_info = (struct ipa_dfs_info *) w->aux;
w = w_info->next_cycle;
}
while (w)
{
propagate_bits (w);
- w_info = w->aux;
+ w_info = (struct ipa_dfs_info *) w->aux;
w = w_info->next_cycle;
}
}
node = order[i];
merge_callee_local_info (node, node);
- w_info = node->aux;
+ w_info = (struct ipa_dfs_info *) node->aux;
w = w_info->next_cycle;
while (w)
{
merge_callee_local_info (w, w);
- w_info = w->aux;
+ w_info = (struct ipa_dfs_info *) w->aux;
w = w_info->next_cycle;
}
}
get_static_name (index));
}
- w_info = node->aux;
+ w_info = (struct ipa_dfs_info *) node->aux;
w = w_info->next_cycle;
while (w)
{
}
- w_info = w->aux;
+ w_info = (struct ipa_dfs_info *) w->aux;
w = w_info->next_cycle;
}
fprintf (dump_file, "\n globals read: ");