Commit 84de9426 by Martin Sebor Committed by Jeff Law

gimple-fold.c (strlen_range_kind): Remove SRK_LENRANGE_2.

	* gimple-fold.c (strlen_range_kind): Remove SRK_LENRANGE_2.
	(get_range_strlen_tree): Update appropriately.
	(get_range_strlen)
	* gimple-fold.h (get_range_strlen): Drop unused last argument.

Co-Authored-By: Jeff Law <law@redhat.com>

From-SVN: r267537
parent fbf3e66f
2019-01-02 Martin Sebor <msebor@redhat.com> 2019-01-02 Martin Sebor <msebor@redhat.com>
Jeff Law <law@redhat.com> Jeff Law <law@redhat.com>
* gimple-fold.c (strlen_range_kind): Remove SRK_LENRANGE_2.
(get_range_strlen_tree): Update appropriately.
(get_range_strlen)
* gimple-fold.h (get_range_strlen): Drop unused last argument.
* gimple-fold.c (gimple_fold_builtin_strlen): Use set_strlen_range * gimple-fold.c (gimple_fold_builtin_strlen): Use set_strlen_range
rather than set_range_info. rather than set_range_info.
......
...@@ -77,8 +77,6 @@ enum strlen_range_kind { ...@@ -77,8 +77,6 @@ enum strlen_range_kind {
or element of. Also determine the size of the largest character or element of. Also determine the size of the largest character
array the string may refer to. */ array the string may refer to. */
SRK_LENRANGE, SRK_LENRANGE,
/* Temporary until the rest of Martin's strlen range work is integrated. */
SRK_LENRANGE_2,
/* Determine the integer value of the argument (not string length). */ /* Determine the integer value of the argument (not string length). */
SRK_INT_VALUE SRK_INT_VALUE
}; };
...@@ -1309,7 +1307,7 @@ get_range_strlen_tree (tree arg, bitmap *visited, strlen_range_kind rkind, ...@@ -1309,7 +1307,7 @@ get_range_strlen_tree (tree arg, bitmap *visited, strlen_range_kind rkind,
pdata, eltsize); pdata, eltsize);
} }
else if (TREE_CODE (TREE_OPERAND (op, 0)) == COMPONENT_REF else if (TREE_CODE (TREE_OPERAND (op, 0)) == COMPONENT_REF
&& (rkind == SRK_LENRANGE || rkind == SRK_LENRANGE_2)) && rkind == SRK_LENRANGE)
{ {
/* Fail if an array is the last member of a struct object /* Fail if an array is the last member of a struct object
since it could be treated as a (fake) flexible array since it could be treated as a (fake) flexible array
...@@ -1349,7 +1347,7 @@ get_range_strlen_tree (tree arg, bitmap *visited, strlen_range_kind rkind, ...@@ -1349,7 +1347,7 @@ get_range_strlen_tree (tree arg, bitmap *visited, strlen_range_kind rkind,
} }
} }
if (!val && (rkind == SRK_LENRANGE || rkind == SRK_LENRANGE_2)) if (!val && rkind == SRK_LENRANGE)
{ {
if (TREE_CODE (arg) == ADDR_EXPR) if (TREE_CODE (arg) == ADDR_EXPR)
return get_range_strlen (TREE_OPERAND (arg, 0), visited, rkind, return get_range_strlen (TREE_OPERAND (arg, 0), visited, rkind,
...@@ -1484,7 +1482,7 @@ get_range_strlen_tree (tree arg, bitmap *visited, strlen_range_kind rkind, ...@@ -1484,7 +1482,7 @@ get_range_strlen_tree (tree arg, bitmap *visited, strlen_range_kind rkind,
on the length of the string based on the referenced object's on the length of the string based on the referenced object's
or subobject's type. Determine the conservative upper bound or subobject's type. Determine the conservative upper bound
based on the enclosing object's size if possible. */ based on the enclosing object's size if possible. */
if (rkind == SRK_LENRANGE || rkind == SRK_LENRANGE_2) if (rkind == SRK_LENRANGE)
{ {
poly_int64 offset; poly_int64 offset;
tree base = get_addr_base_and_unit_offset (arg, &offset); tree base = get_addr_base_and_unit_offset (arg, &offset);
...@@ -1538,7 +1536,7 @@ get_range_strlen_tree (tree arg, bitmap *visited, strlen_range_kind rkind, ...@@ -1538,7 +1536,7 @@ get_range_strlen_tree (tree arg, bitmap *visited, strlen_range_kind rkind,
} }
pdata->maxlen = val; pdata->maxlen = val;
return rkind == SRK_LENRANGE || rkind == SRK_LENRANGE_2 || !integer_all_onesp (val); return rkind == SRK_LENRANGE || !integer_all_onesp (val);
} }
/* For an ARG referencing one or more strings, try to obtain the range /* For an ARG referencing one or more strings, try to obtain the range
...@@ -1600,7 +1598,7 @@ get_range_strlen (tree arg, bitmap *visited, ...@@ -1600,7 +1598,7 @@ get_range_strlen (tree arg, bitmap *visited,
for (unsigned int i = 0; i < 2; i++) for (unsigned int i = 0; i < 2; i++)
if (!get_range_strlen (ops[i], visited, rkind, pdata, eltsize)) if (!get_range_strlen (ops[i], visited, rkind, pdata, eltsize))
{ {
if (rkind != SRK_LENRANGE_2) if (rkind != SRK_LENRANGE)
return false; return false;
/* Set the upper bound to the maximum to prevent /* Set the upper bound to the maximum to prevent
it from being adjusted in the next iteration but it from being adjusted in the next iteration but
...@@ -1634,7 +1632,7 @@ get_range_strlen (tree arg, bitmap *visited, ...@@ -1634,7 +1632,7 @@ get_range_strlen (tree arg, bitmap *visited,
if (!get_range_strlen (arg, visited, rkind, pdata, eltsize)) if (!get_range_strlen (arg, visited, rkind, pdata, eltsize))
{ {
if (rkind != SRK_LENRANGE_2) if (rkind != SRK_LENRANGE)
return false; return false;
/* Set the upper bound to the maximum to prevent /* Set the upper bound to the maximum to prevent
it from being adjusted in the next iteration but it from being adjusted in the next iteration but
...@@ -1680,12 +1678,11 @@ get_range_strlen (tree arg, bitmap *visited, ...@@ -1680,12 +1678,11 @@ get_range_strlen (tree arg, bitmap *visited,
4 for wide characer strings. ELTSIZE is by default 1. */ 4 for wide characer strings. ELTSIZE is by default 1. */
bool bool
get_range_strlen (tree arg, c_strlen_data *pdata, unsigned eltsize, bool strict) get_range_strlen (tree arg, c_strlen_data *pdata, unsigned eltsize)
{ {
bitmap visited = NULL; bitmap visited = NULL;
if (!get_range_strlen (arg, &visited, strict ? SRK_LENRANGE : SRK_LENRANGE_2, if (!get_range_strlen (arg, &visited, SRK_LENRANGE, pdata, eltsize))
pdata, eltsize))
{ {
/* On failure extend the length range to an impossible maximum /* On failure extend the length range to an impossible maximum
(a valid MAXLEN must be less than PTRDIFF_MAX - 1). Other (a valid MAXLEN must be less than PTRDIFF_MAX - 1). Other
......
...@@ -26,7 +26,7 @@ extern tree create_tmp_reg_or_ssa_name (tree, gimple *stmt = NULL); ...@@ -26,7 +26,7 @@ extern tree create_tmp_reg_or_ssa_name (tree, gimple *stmt = NULL);
extern tree canonicalize_constructor_val (tree, tree); extern tree canonicalize_constructor_val (tree, tree);
extern tree get_symbol_constant_value (tree); extern tree get_symbol_constant_value (tree);
struct c_strlen_data; struct c_strlen_data;
extern bool get_range_strlen (tree, c_strlen_data *, unsigned eltsize, bool = false); extern bool get_range_strlen (tree, c_strlen_data *, unsigned eltsize);
extern void gimplify_and_update_call_from_tree (gimple_stmt_iterator *, tree); extern void gimplify_and_update_call_from_tree (gimple_stmt_iterator *, tree);
extern bool fold_stmt (gimple_stmt_iterator *); extern bool fold_stmt (gimple_stmt_iterator *);
extern bool fold_stmt (gimple_stmt_iterator *, tree (*) (tree)); extern bool fold_stmt (gimple_stmt_iterator *, tree (*) (tree));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment