unsigned int *stack, *tos;
};
-static const unsigned HOST_WIDE_INT unknown[4] = {
- HOST_WIDE_INT_M1U,
- HOST_WIDE_INT_M1U,
- 0,
- 0
-};
-
static tree compute_object_offset (const_tree, const_tree);
static bool addr_object_size (struct object_size_info *,
const_tree, int, unsigned HOST_WIDE_INT *);
/* Maximum value of offset we consider to be addition. */
static unsigned HOST_WIDE_INT offset_limit;
+static inline unsigned HOST_WIDE_INT
+unknown (int object_size_type)
+{
+ return ((unsigned HOST_WIDE_INT) -((object_size_type >> 1) ^ 1));
+}
/* Initialize OFFSET_LIMIT variable. */
static void
/* Compute __builtin_object_size for PTR, which is a ADDR_EXPR.
OBJECT_SIZE_TYPE is the second argument from __builtin_object_size.
- If unknown, return unknown[object_size_type]. */
+ If unknown, return unknown (object_size_type). */
static bool
addr_object_size (struct object_size_info *osi, const_tree ptr,
/* Set to unknown and overwrite just before returning if the size
could be determined. */
- *psize = unknown[object_size_type];
+ *psize = unknown (object_size_type);
pt_var = TREE_OPERAND (ptr, 0);
while (handled_component_p (pt_var))
SSA_NAME_VERSION (var)))
sz = object_sizes[object_size_type][SSA_NAME_VERSION (var)];
else
- sz = unknown[object_size_type];
+ sz = unknown (object_size_type);
}
- if (sz != unknown[object_size_type])
+ if (sz != unknown (object_size_type))
{
offset_int mem_offset;
if (mem_ref_offset (pt_var).is_constant (&mem_offset))
else if (wi::fits_uhwi_p (dsz))
sz = dsz.to_uhwi ();
else
- sz = unknown[object_size_type];
+ sz = unknown (object_size_type);
}
else
- sz = unknown[object_size_type];
+ sz = unknown (object_size_type);
}
- if (sz != unknown[object_size_type] && sz < offset_limit)
+ if (sz != unknown (object_size_type) && sz < offset_limit)
pt_var_size = size_int (sz);
}
else if (DECL_P (pt_var))
/* Compute __builtin_object_size for CALL, which is a GIMPLE_CALL.
Handles calls to functions declared with attribute alloc_size.
OBJECT_SIZE_TYPE is the second argument from __builtin_object_size.
- If unknown, return unknown[object_size_type]. */
+ If unknown, return unknown (object_size_type). */
static unsigned HOST_WIDE_INT
alloc_object_size (const gcall *call, int object_size_type)
calltype = gimple_call_fntype (call);
if (!calltype)
- return unknown[object_size_type];
+ return unknown (object_size_type);
/* Set to positions of alloc_size arguments. */
int arg1 = -1, arg2 = -1;
|| (arg2 >= 0
&& (arg2 >= (int)gimple_call_num_args (call)
|| TREE_CODE (gimple_call_arg (call, arg2)) != INTEGER_CST)))
- return unknown[object_size_type];
+ return unknown (object_size_type);
tree bytes = NULL_TREE;
if (arg2 >= 0)
if (bytes && tree_fits_uhwi_p (bytes))
return tree_to_uhwi (bytes);
- return unknown[object_size_type];
+ return unknown (object_size_type);
}
/* Set to unknown and overwrite just before returning if the size
could be determined. */
- *psize = unknown[object_size_type];
+ *psize = unknown (object_size_type);
if (! offset_limit)
init_offset_limit ();
{
EXECUTE_IF_SET_IN_BITMAP (osi.visited, 0, i, bi)
if (object_sizes[object_size_type][i]
- != unknown[object_size_type])
+ != unknown (object_size_type))
{
print_generic_expr (dump_file, ssa_name (i),
dump_flags);
}
*psize = object_sizes[object_size_type][SSA_NAME_VERSION (ptr)];
- return *psize != unknown[object_size_type];
+ return *psize != unknown (object_size_type);
}
/* Compute object_sizes for PTR, defined to VALUE, which is not an SSA_NAME. */
unsigned HOST_WIDE_INT bytes;
gcc_assert (object_sizes[object_size_type][varno]
- != unknown[object_size_type]);
+ != unknown (object_size_type));
gcc_assert (osi->pass == 0);
if (TREE_CODE (value) == WITH_SIZE_EXPR)
if (TREE_CODE (value) == ADDR_EXPR)
addr_object_size (osi, value, object_size_type, &bytes);
else
- bytes = unknown[object_size_type];
+ bytes = unknown (object_size_type);
if ((object_size_type & 2) == 0)
{
gcc_assert (is_gimple_call (call));
gcc_assert (object_sizes[object_size_type][varno]
- != unknown[object_size_type]);
+ != unknown (object_size_type));
gcc_assert (osi->pass == 0);
bytes = alloc_object_size (call, object_size_type);
{
int object_size_type = osi->object_size_type;
unsigned int varno = SSA_NAME_VERSION (ptr);
- unsigned HOST_WIDE_INT bytes;
+ unsigned HOST_WIDE_INT bytes = unknown (object_size_type);
- gcc_assert (object_sizes[object_size_type][varno]
- != unknown[object_size_type]);
- gcc_assert (osi->pass == 0);
+ gcc_checking_assert (object_sizes[object_size_type][varno] != bytes);
+ gcc_checking_assert (osi->pass == 0);
- bytes = unknown[object_size_type];
-
- if ((object_size_type & 2) == 0)
- {
- if (object_sizes[object_size_type][varno] < bytes)
- object_sizes[object_size_type][varno] = bytes;
- }
- else
- {
- if (object_sizes[object_size_type][varno] > bytes)
- object_sizes[object_size_type][varno] = bytes;
- }
+ object_sizes[object_size_type][varno] = bytes;
}
unsigned int varno = SSA_NAME_VERSION (dest);
unsigned HOST_WIDE_INT orig_bytes;
- if (object_sizes[object_size_type][varno] == unknown[object_size_type])
+ if (object_sizes[object_size_type][varno] == unknown (object_size_type))
return false;
if (offset >= offset_limit)
{
- object_sizes[object_size_type][varno] = unknown[object_size_type];
+ object_sizes[object_size_type][varno] = unknown (object_size_type);
return false;
}
collect_object_sizes_for (osi, orig);
orig_bytes = object_sizes[object_size_type][SSA_NAME_VERSION (orig)];
- if (orig_bytes != unknown[object_size_type])
+ if (orig_bytes != unknown (object_size_type))
orig_bytes = (offset > orig_bytes)
? HOST_WIDE_INT_0U : orig_bytes - offset;
else
gcc_unreachable ();
- if (object_sizes[object_size_type][varno] == unknown[object_size_type])
+ if (object_sizes[object_size_type][varno] == unknown (object_size_type))
return false;
/* Handle PTR + OFFSET here. */
|| TREE_CODE (op0) == ADDR_EXPR))
{
if (! tree_fits_uhwi_p (op1))
- bytes = unknown[object_size_type];
+ bytes = unknown (object_size_type);
else if (TREE_CODE (op0) == SSA_NAME)
return merge_object_sizes (osi, var, op0, tree_to_uhwi (op1));
else
/* op0 will be ADDR_EXPR here. */
addr_object_size (osi, op0, object_size_type, &bytes);
- if (bytes == unknown[object_size_type])
+ if (bytes == unknown (object_size_type))
;
else if (off > offset_limit)
- bytes = unknown[object_size_type];
+ bytes = unknown (object_size_type);
else if (off > bytes)
bytes = 0;
else
}
}
else
- bytes = unknown[object_size_type];
+ bytes = unknown (object_size_type);
if ((object_size_type & 2) == 0)
{
gcc_assert (gimple_assign_rhs_code (stmt) == COND_EXPR);
- if (object_sizes[object_size_type][varno] == unknown[object_size_type])
+ if (object_sizes[object_size_type][varno] == unknown (object_size_type))
return false;
then_ = gimple_assign_rhs2 (stmt);
else
expr_object_size (osi, var, then_);
- if (object_sizes[object_size_type][varno] == unknown[object_size_type])
+ if (object_sizes[object_size_type][varno] == unknown (object_size_type))
return reexamine;
if (TREE_CODE (else_) == SSA_NAME)
object size is object size of the first operand minus the constant.
If the constant is bigger than the number of remaining bytes until the
end of the object, object size is 0, but if it is instead a pointer
- subtraction, object size is unknown[object_size_type].
+ subtraction, object size is unknown (object_size_type).
To differentiate addition from subtraction, ADDR_EXPR returns
- unknown[object_size_type] for all objects bigger than half of the address
+ unknown (object_size_type) for all objects bigger than half of the address
space, and constants less than half of the address space are considered
addition, while bigger constants subtraction.
For a memcpy like GIMPLE_CALL that always returns one of its arguments, the
expr_object_size (osi, var, rhs);
}
else
- unknown_object_size (osi, var);
+ unknown_object_size (osi, var);
break;
}
case GIMPLE_ASM:
/* Pointers defined by __asm__ statements can point anywhere. */
- object_sizes[object_size_type][varno] = unknown[object_size_type];
+ object_sizes[object_size_type][varno] = unknown (object_size_type);
break;
case GIMPLE_NOP:
expr_object_size (osi, var, SSA_NAME_VAR (var));
else
/* Uninitialized SSA names point nowhere. */
- object_sizes[object_size_type][varno] = unknown[object_size_type];
+ object_sizes[object_size_type][varno] = unknown (object_size_type);
break;
case GIMPLE_PHI:
tree rhs = gimple_phi_arg (stmt, i)->def;
if (object_sizes[object_size_type][varno]
- == unknown[object_size_type])
+ == unknown (object_size_type))
break;
if (TREE_CODE (rhs) == SSA_NAME)
}
if (! reexamine
- || object_sizes[object_size_type][varno] == unknown[object_size_type])
+ || object_sizes[object_size_type][varno] == unknown (object_size_type))
{
bitmap_set_bit (computed[object_size_type], varno);
bitmap_clear_bit (osi->reexamine, varno);