STRIP_NOPS (ptr1);
STRIP_NOPS (ptr2);
- /* Anything we do not explicilty handle aliases. */
- if ((TREE_CODE (ptr1) != SSA_NAME
- && TREE_CODE (ptr1) != ADDR_EXPR
- && TREE_CODE (ptr1) != POINTER_PLUS_EXPR)
- || (TREE_CODE (ptr2) != SSA_NAME
- && TREE_CODE (ptr2) != ADDR_EXPR
- && TREE_CODE (ptr2) != POINTER_PLUS_EXPR)
- || !POINTER_TYPE_P (TREE_TYPE (ptr1))
- || !POINTER_TYPE_P (TREE_TYPE (ptr2)))
- return true;
-
/* Disregard pointer offsetting. */
if (TREE_CODE (ptr1) == POINTER_PLUS_EXPR)
{
if (base
&& (TREE_CODE (base) == MEM_REF
|| TREE_CODE (base) == TARGET_MEM_REF))
- ptr1 = TREE_OPERAND (base, 0);
+ return ptr_derefs_may_alias_p (TREE_OPERAND (base, 0), ptr2);
else if (base
&& DECL_P (base))
return ptr_deref_may_alias_decl_p (ptr2, base);
if (base
&& (TREE_CODE (base) == MEM_REF
|| TREE_CODE (base) == TARGET_MEM_REF))
- ptr2 = TREE_OPERAND (base, 0);
+ return ptr_derefs_may_alias_p (ptr1, TREE_OPERAND (base, 0));
else if (base
&& DECL_P (base))
return ptr_deref_may_alias_decl_p (ptr1, base);
return true;
}
+ /* From here we require SSA name pointers. Anything else aliases. */
+ if (TREE_CODE (ptr1) != SSA_NAME
+ || TREE_CODE (ptr2) != SSA_NAME
+ || !POINTER_TYPE_P (TREE_TYPE (ptr1))
+ || !POINTER_TYPE_P (TREE_TYPE (ptr2)))
+ return true;
+
/* We may end up with two empty points-to solutions for two same pointers.
In this case we still want to say both pointers alias, so shortcut
that here. */
r->max_size = -1;
r->ref_alias_set = -1;
r->base_alias_set = -1;
+ r->volatile_p = ref ? TREE_THIS_VOLATILE (ref) : false;
}
/* Returns the base object of the memory reference *REF. */
ref->max_size = ref->size = -1;
ref->ref_alias_set = 0;
ref->base_alias_set = 0;
+ ref->volatile_p = false;
}
/* Return 1 if TYPE1 and TYPE2 are to be considered equivalent for the
/* If either reference is view-converted, give up now. */
if (same_type_for_tbaa (TREE_TYPE (base1), TREE_TYPE (ptrtype1)) != 1
- || same_type_for_tbaa (TREE_TYPE (dbase2),
- TREE_TYPE (reference_alias_ptr_type (dbase2))) != 1)
+ || same_type_for_tbaa (TREE_TYPE (dbase2), TREE_TYPE (base2)) != 1)
return true;
/* If both references are through the same type, they do not alias
|| TREE_CODE (base2) == LABEL_DECL)
return true;
+ /* Two volatile accesses always conflict. */
+ if (ref1->volatile_p
+ && ref2->volatile_p)
+ return true;
+
/* Defer to simple offset based disambiguation if we have
references based on two decls. Do this before defering to
TBAA to handle must-alias cases in conformance with the
if (!base)
return true;
+ /* A call that is not without side-effects might involve volatile
+ accesses and thus conflicts with all other volatile accesses. */
+ if (ref->volatile_p)
+ return true;
+
/* If the reference is based on a decl that is not aliased the call
cannot possibly use it. */
if (DECL_P (base)
case BUILT_IN_MEMMOVE_CHK:
case BUILT_IN_MEMPCPY_CHK:
case BUILT_IN_STPCPY_CHK:
+ case BUILT_IN_STPNCPY_CHK:
{
ao_ref dref;
tree size = NULL_TREE;
|| CONSTANT_CLASS_P (base))
return false;
+ /* A call that is not without side-effects might involve volatile
+ accesses and thus conflicts with all other volatile accesses. */
+ if (ref->volatile_p)
+ return true;
+
/* If the reference is based on a decl that is not aliased the call
cannot possibly clobber it. */
if (DECL_P (base)
case BUILT_IN_MEMMOVE_CHK:
case BUILT_IN_MEMPCPY_CHK:
case BUILT_IN_STPCPY_CHK:
+ case BUILT_IN_STPNCPY_CHK:
case BUILT_IN_STRCAT_CHK:
case BUILT_IN_STRNCAT_CHK:
case BUILT_IN_MEMSET_CHK:
static bool
maybe_skip_until (gimple phi, tree target, ao_ref *ref,
- tree vuse, bitmap *visited)
+ tree vuse, bitmap *visited, bool abort_on_visited)
{
basic_block bb = gimple_bb (phi);
{
/* An already visited PHI node ends the walk successfully. */
if (bitmap_bit_p (*visited, SSA_NAME_VERSION (PHI_RESULT (def_stmt))))
- return true;
- vuse = get_continuation_for_phi (def_stmt, ref, visited);
+ return !abort_on_visited;
+ vuse = get_continuation_for_phi (def_stmt, ref,
+ visited, abort_on_visited);
if (!vuse)
return false;
continue;
if (gimple_bb (def_stmt) != bb)
{
if (!bitmap_set_bit (*visited, SSA_NAME_VERSION (vuse)))
- return true;
+ return !abort_on_visited;
bb = gimple_bb (def_stmt);
}
vuse = gimple_vuse (def_stmt);
static tree
get_continuation_for_phi_1 (gimple phi, tree arg0, tree arg1,
- ao_ref *ref, bitmap *visited)
+ ao_ref *ref, bitmap *visited,
+ bool abort_on_visited)
{
gimple def0 = SSA_NAME_DEF_STMT (arg0);
gimple def1 = SSA_NAME_DEF_STMT (arg1);
&& dominated_by_p (CDI_DOMINATORS,
gimple_bb (def1), gimple_bb (def0))))
{
- if (maybe_skip_until (phi, arg0, ref, arg1, visited))
+ if (maybe_skip_until (phi, arg0, ref, arg1, visited, abort_on_visited))
return arg0;
}
else if (gimple_nop_p (def1)
|| dominated_by_p (CDI_DOMINATORS,
gimple_bb (def0), gimple_bb (def1)))
{
- if (maybe_skip_until (phi, arg1, ref, arg0, visited))
+ if (maybe_skip_until (phi, arg1, ref, arg0, visited, abort_on_visited))
return arg1;
}
/* Special case of a diamond:
be found. */
tree
-get_continuation_for_phi (gimple phi, ao_ref *ref, bitmap *visited)
+get_continuation_for_phi (gimple phi, ao_ref *ref, bitmap *visited,
+ bool abort_on_visited)
{
unsigned nargs = gimple_phi_num_args (phi);
for (i = 0; i < nargs; ++i)
{
arg1 = PHI_ARG_DEF (phi, i);
- arg0 = get_continuation_for_phi_1 (phi, arg0, arg1, ref, visited);
+ arg0 = get_continuation_for_phi_1 (phi, arg0, arg1, ref, visited,
+ abort_on_visited);
if (!arg0)
return NULL_TREE;
}
{
bitmap visited = NULL;
void *res;
+ bool translated = false;
timevar_push (TV_ALIAS_STMT_WALK);
if (gimple_nop_p (def_stmt))
break;
else if (gimple_code (def_stmt) == GIMPLE_PHI)
- vuse = get_continuation_for_phi (def_stmt, ref, &visited);
+ vuse = get_continuation_for_phi (def_stmt, ref, &visited, translated);
else
{
if (stmt_may_clobber_ref_p_1 (def_stmt, ref))
else if (res != NULL)
break;
/* Translation succeeded, continue walking. */
+ translated = true;
}
vuse = gimple_vuse (def_stmt);
}