diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2017-06-30 15:36:41 +0000 |
---|---|---|
committer | Aldy Hernandez <aldyh@gcc.gnu.org> | 2017-06-30 15:36:41 +0000 |
commit | 059ab149148378662403798003b8f380c0a12588 (patch) | |
tree | c4ab86e7b702a90fb10bc8627320fa78adaac3be | |
parent | e59e8b5a1c86c6e901201e1d0fdcf53e2c453637 (diff) | |
download | gcc-059ab149148378662403798003b8f380c0a12588.zip gcc-059ab149148378662403798003b8f380c0a12588.tar.gz gcc-059ab149148378662403798003b8f380c0a12588.tar.bz2 |
tree-ssanames.c (set_range_info_raw): Abstract from ...
* tree-ssanames.c (set_range_info_raw): Abstract from ...
(set_range_info): ...here. Only call set_range_info_raw if domain
is useful.
(set_nonzero_bits): Call set_range_info_raw.
* tree-ssanames.h (set_range_info_raw): New.
testsuite/
* gcc.dg/Walloca-14.c: Adapt test to recognize new complaint of
unbounded use.
From-SVN: r249846
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Walloca-14.c | 1 | ||||
-rw-r--r-- | gcc/tree-ssanames.c | 47 | ||||
-rw-r--r-- | gcc/tree-ssanames.h | 3 |
5 files changed, 58 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index be0b4bc..2fbfc2b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-06-30 Aldy Hernandez <aldyh@redhat.com> + + * tree-ssanames.c (set_range_info_raw): Abstract from ... + (set_range_info): ...here. Only call set_range_info_raw if domain + is useful. + (set_nonzero_bits): Call set_range_info_raw. + * tree-ssanames.h (set_range_info_raw): New. + 2017-06-30 Jakub Jelinek <jakub@redhat.com> PR target/81225 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f0555b9..92d5f63 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-06-30 Aldy Hernandez <aldyh@redhat.com> + + * gcc.dg/Walloca-14.c: Adapt test to recognize new complaint of + unbounded use. + 2017-06-30 David Malcolm <dmalcolm@redhat.com> PR c++/80014 diff --git a/gcc/testsuite/gcc.dg/Walloca-14.c b/gcc/testsuite/gcc.dg/Walloca-14.c index 723dbe5..f3e3f57 100644 --- a/gcc/testsuite/gcc.dg/Walloca-14.c +++ b/gcc/testsuite/gcc.dg/Walloca-14.c @@ -9,5 +9,6 @@ g (int *p) extern void f (void *); void *q = __builtin_alloca (p); /* { dg-warning "passing argument 1" } */ + /* { dg-warning "unbounded use of 'alloca'" "unbounded" { target *-*-* } 11 } */ f (q); } diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c index e83dd46..676c806 100644 --- a/gcc/tree-ssanames.c +++ b/gcc/tree-ssanames.c @@ -320,11 +320,14 @@ make_ssa_name_fn (struct function *fn, tree var, gimple *stmt, return t; } -/* Store range information RANGE_TYPE, MIN, and MAX to tree ssa_name NAME. */ +/* Helper function for set_range_info. + + Store range information RANGE_TYPE, MIN, and MAX to tree ssa_name + NAME. */ void -set_range_info (tree name, enum value_range_type range_type, - const wide_int_ref &min, const wide_int_ref &max) +set_range_info_raw (tree name, enum value_range_type range_type, + const wide_int_ref &min, const wide_int_ref &max) { gcc_assert (!POINTER_TYPE_P (TREE_TYPE (name))); gcc_assert (range_type == VR_RANGE || range_type == VR_ANTI_RANGE); @@ -360,6 +363,34 @@ set_range_info (tree name, enum value_range_type range_type, } } +/* Store range information RANGE_TYPE, MIN, and MAX to tree ssa_name + NAME while making sure we don't store useless range info. */ + +void +set_range_info (tree name, enum value_range_type range_type, + const wide_int_ref &min, const wide_int_ref &max) +{ + gcc_assert (!POINTER_TYPE_P (TREE_TYPE (name))); + + /* A range of the entire domain is really no range at all. */ + tree type = TREE_TYPE (name); + if (min == wi::min_value (TYPE_PRECISION (type), TYPE_SIGN (type)) + && max == wi::max_value (TYPE_PRECISION (type), TYPE_SIGN (type))) + { + range_info_def *ri = SSA_NAME_RANGE_INFO (name); + if (ri == NULL) + return; + if (ri->get_nonzero_bits () == -1) + { + ggc_free (ri); + SSA_NAME_RANGE_INFO (name) = NULL; + return; + } + } + + set_range_info_raw (name, range_type, min, max); +} + /* Gets range information MIN, MAX and returns enum value_range_type corresponding to tree ssa_name NAME. enum value_range_type returned @@ -419,9 +450,13 @@ set_nonzero_bits (tree name, const wide_int_ref &mask) { gcc_assert (!POINTER_TYPE_P (TREE_TYPE (name))); if (SSA_NAME_RANGE_INFO (name) == NULL) - set_range_info (name, VR_RANGE, - TYPE_MIN_VALUE (TREE_TYPE (name)), - TYPE_MAX_VALUE (TREE_TYPE (name))); + { + if (mask == -1) + return; + set_range_info_raw (name, VR_RANGE, + TYPE_MIN_VALUE (TREE_TYPE (name)), + TYPE_MAX_VALUE (TREE_TYPE (name))); + } range_info_def *ri = SSA_NAME_RANGE_INFO (name); ri->set_nonzero_bits (mask); } diff --git a/gcc/tree-ssanames.h b/gcc/tree-ssanames.h index 9a18394..f7e032f 100644 --- a/gcc/tree-ssanames.h +++ b/gcc/tree-ssanames.h @@ -69,6 +69,9 @@ struct GTY ((variable_size)) range_info_def { /* Sets the value range to SSA. */ extern void set_range_info (tree, enum value_range_type, const wide_int_ref &, const wide_int_ref &); +extern void set_range_info_raw (tree, enum value_range_type, + const wide_int_ref &, + const wide_int_ref &); /* Gets the value range from SSA. */ extern enum value_range_type get_range_info (const_tree, wide_int *, wide_int *); |