#include "tree-ssa-structalias.h"
#include "cgraph.h"
#include "alias.h"
+#include "pointer-set.h"
/* The idea behind this analyzer is to generate set constraints from the
program, then solve the resulting constraints in order to generate the
DEF_VEC_ALLOC_P(varinfo_t, heap);
-/* Table of variable info structures for constraint variables. Indexed directly
- by variable info id. */
+/* Table of variable info structures for constraint variables.
+ Indexed directly by variable info id. */
static VEC(varinfo_t,heap) *varmap;
/* Return the varmap element N */
decl. */
if (TREE_CODE (t) == SSA_NAME
&& TREE_CODE (SSA_NAME_VAR (t)) == PARM_DECL
- && gimple_default_def (cfun, SSA_NAME_VAR (t)) == t)
+ && SSA_NAME_IS_DEFAULT_DEF (t))
return get_constraint_exp_from_ssa_var (SSA_NAME_VAR (t));
cexpr.type = SCALAR;
use_operand_p use_p;
ssa_op_iter iter;
enum escape_type stmt_escape_type = is_escape_site (stmt);
- tree op;
if (stmt_escape_type == ESCAPE_TO_CALL
|| stmt_escape_type == ESCAPE_TO_PURE_CONST)
var = SSA_NAME_VAR (op);
v_ann = var_ann (var);
- /* The base variable of an ssa name must be a GIMPLE register, and thus
+ /* The base variable of an SSA name must be a GIMPLE register, and thus
it cannot be aliased. */
gcc_assert (!may_be_aliased (var));
So, if the original code had no other dereferences of PTR,
the aliaser will not create memory tags for it, and when
&PTR->FLD gets propagated to INDIRECT_REF expressions, the
- memory operations will receive no V_MAY_DEF/VUSE operands.
+ memory operations will receive no VDEF/VUSE operands.
One solution would be to have count_uses_and_derefs consider
&PTR->FLD a dereference of PTR. But that is wrong, since it
all the variables OP points to. */
pi->is_dereferenced = 1;
- /* Keep track of how many time we've dereferenced each
- pointer. */
- NUM_REFERENCES_INC (v_ann);
-
/* If this is a store operation, mark OP as being
dereferenced to store, otherwise mark it as being
dereferenced to load. */
if (is_store)
- bitmap_set_bit (ai->dereferenced_ptrs_store, DECL_UID (var));
+ pointer_set_insert (ai->dereferenced_ptrs_store, var);
else
- bitmap_set_bit (ai->dereferenced_ptrs_load, DECL_UID (var));
+ pointer_set_insert (ai->dereferenced_ptrs_load, var);
}
if (stmt_escape_type != NO_ESCAPE && num_derefs < num_uses)
if (get_call_expr_in (stmt)
|| stmt_escape_type == ESCAPE_STORED_IN_GLOBAL)
{
- bitmap_set_bit (ai->dereferenced_ptrs_store, DECL_UID (var));
+ pointer_set_insert (ai->dereferenced_ptrs_store, var);
pi->is_dereferenced = 1;
}
}
if (TREE_CODE (stmt) == PHI_NODE)
return;
- /* Update reference counter for definitions to any
- potentially aliased variable. This is used in the alias
- grouping heuristics. */
- FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_DEF)
- {
- tree var = SSA_NAME_VAR (op);
- var_ann_t ann = var_ann (var);
- bitmap_set_bit (ai->written_vars, DECL_UID (var));
- if (may_be_aliased (var))
- NUM_REFERENCES_INC (ann);
-
- }
-
- /* Mark variables in V_MAY_DEF operands as being written to. */
- FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_VIRTUAL_DEFS)
+ /* Mark stored variables in STMT as being written to and update the
+ reference counter for potentially aliased symbols in STMT. */
+ if (stmt_references_memory_p (stmt) && STORED_SYMS (stmt))
{
- tree var = DECL_P (op) ? op : SSA_NAME_VAR (op);
- bitmap_set_bit (ai->written_vars, DECL_UID (var));
+ unsigned i;
+ bitmap_iterator bi;
+ EXECUTE_IF_SET_IN_BITMAP (STORED_SYMS (stmt), 0, i, bi)
+ pointer_set_insert (ai->written_vars, referenced_var (i));
}
}
{
rhsoffset = TREE_INT_CST_LOW (op1) * BITS_PER_UNIT;
}
+ else
+ return false;
for (i = 0; VEC_iterate (ce_s, lhsc, i, c); i++)
{
tree var = vi->decl;
tree smt;
- bitmap_iterator bi;
- unsigned int j;
var_ann_t va;
struct ptr_info_def *pi = NULL;
decl. */
if (TREE_CODE (p) == SSA_NAME
&& TREE_CODE (SSA_NAME_VAR (p)) == PARM_DECL
- && gimple_default_def (cfun, SSA_NAME_VAR (p)) == p)
+ && SSA_NAME_IS_DEFAULT_DEF (p))
lookup_p = SSA_NAME_VAR (p);
if (lookup_id_for_tree (lookup_p, &id))
tree stmt = bsi_stmt (bsi);
find_func_aliases (stmt);
+
/* Update various related attributes like escaped
addresses, pointer dereferences for loads and stores.
This is used when creating name tags and alias