aboutsummaryrefslogtreecommitdiff
path: root/gcc/ubsan.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2016-05-02 09:39:09 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2016-05-02 09:39:09 +0000
commit032c80e999eac4288ff1b0f752e15c8e7c5cdf51 (patch)
tree246e0c0732538d6aaa57d527e1ad81e531ce8ace /gcc/ubsan.c
parentcd1e4d417a91f4e802e745c8ff6cc6d88a2e96c1 (diff)
downloadgcc-032c80e999eac4288ff1b0f752e15c8e7c5cdf51.zip
gcc-032c80e999eac4288ff1b0f752e15c8e7c5cdf51.tar.gz
gcc-032c80e999eac4288ff1b0f752e15c8e7c5cdf51.tar.bz2
Support <, <=, > and >= for offset_int and widest_int
offset_int and widest_int are supposed to be at least one bit wider than all the values they need to represent, with the extra bits being signs. Thus offset_int is effectively int128_t and widest_int is effectively intNNN_t, for target-dependent NNN. Because the types are signed, there's not really any need to specify a sign for operations like comparison. I think things would be clearer if we supported <, <=, > and >= for them (but not for wide_int, which doesn't have a sign). Tested on x86_64-linux-gnu and aarch64-linux-gnu. gcc/ * wide-int.h: Update offset_int and widest_int documentation. (WI_SIGNED_BINARY_PREDICATE_RESULT): New macro. (wi::binary_traits): Allow ordered comparisons between offset_int and offset_int, between widest_int and widest_int, and between either of these types and basic C types. (operator <, <=, >, >=): Define for the same combinations. * tree.h (tree_int_cst_lt): Use comparison operators instead of wi:: comparisons. (tree_int_cst_le): Likewise. * gimple-fold.c (fold_array_ctor_reference): Likewise. (fold_nonarray_ctor_reference): Likewise. * gimple-ssa-strength-reduction.c (record_increment): Likewise. * tree-affine.c (aff_comb_cannot_overlap_p): Likewise. * tree-parloops.c (try_transform_to_exit_first_loop_alt): Likewise. * tree-sra.c (completely_scalarize): Likewise. * tree-ssa-alias.c (stmt_kills_ref_p): Likewise. * tree-ssa-reassoc.c (extract_bit_test_mask): Likewise. * tree-vrp.c (extract_range_from_binary_expr_1): Likewise. (check_for_binary_op_overflow): Likewise. (search_for_addr_array): Likewise. * ubsan.c (ubsan_expand_objsize_ifn): Likewise. From-SVN: r235719
Diffstat (limited to 'gcc/ubsan.c')
-rw-r--r--gcc/ubsan.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/gcc/ubsan.c b/gcc/ubsan.c
index d3fbfd1..802341e 100644
--- a/gcc/ubsan.c
+++ b/gcc/ubsan.c
@@ -911,8 +911,8 @@ ubsan_expand_objsize_ifn (gimple_stmt_iterator *gsi)
/* Yes, __builtin_object_size couldn't determine the
object size. */;
else if (TREE_CODE (offset) == INTEGER_CST
- && wi::ges_p (wi::to_widest (offset), -OBJSZ_MAX_OFFSET)
- && wi::les_p (wi::to_widest (offset), -1))
+ && wi::to_widest (offset) >= -OBJSZ_MAX_OFFSET
+ && wi::to_widest (offset) <= -1)
/* The offset is in range [-16K, -1]. */;
else
{
@@ -928,8 +928,8 @@ ubsan_expand_objsize_ifn (gimple_stmt_iterator *gsi)
/* If the offset is small enough, we don't need the second
run-time check. */
if (TREE_CODE (offset) == INTEGER_CST
- && wi::ges_p (wi::to_widest (offset), 0)
- && wi::les_p (wi::to_widest (offset), OBJSZ_MAX_OFFSET))
+ && wi::to_widest (offset) >= 0
+ && wi::to_widest (offset) <= OBJSZ_MAX_OFFSET)
*gsi = gsi_after_labels (then_bb);
else
{