Commit 78125561 by Jeff Law

gimple-fold.c (get_range_strlen): Only set *nonstr when an unterminated string is discovered.

	* gimple-fold.c (get_range_strlen): Only set *nonstr when
	an unterminated string is discovered.  Bubble up range
	even for unterminated strings.
	(gimple_fold_builtin_strlen): Do not fold if get_range_strlen
	indicates the string was not terminated via NONSTR.

From-SVN: r264816
parent 2e103ae2
2018-10-3 Aldy Hernandez <aldyh@redhat.com> 2018-10-02 Jeff Law <law@redhat.com>
* gimple-fold.c (get_range_strlen): Only set *nonstr when
an unterminated string is discovered. Bubble up range
even for unterminated strings.
(gimple_fold_builtin_strlen): Do not fold if get_range_strlen
indicates the string was not terminated via NONSTR.
2018-10-03 Aldy Hernandez <aldyh@redhat.com>
* tree-vrp.c (extract_range_from_unary_expr): Special case all * tree-vrp.c (extract_range_from_unary_expr): Special case all
pointer conversions. pointer conversions.
...@@ -1344,8 +1344,13 @@ get_range_strlen (tree arg, tree length[2], bitmap *visited, int type, ...@@ -1344,8 +1344,13 @@ get_range_strlen (tree arg, tree length[2], bitmap *visited, int type,
/* If we potentially had a non-terminated string, then /* If we potentially had a non-terminated string, then
bubble that information up to the caller. */ bubble that information up to the caller. */
if (!val) if (!val && data.decl)
*nonstr = data.decl; {
*nonstr = data.decl;
*minlen = data.len;
*maxlen = data.len;
return type == 0 ? false : true;
}
} }
if (!val && fuzzy) if (!val && fuzzy)
...@@ -3596,6 +3601,7 @@ gimple_fold_builtin_strlen (gimple_stmt_iterator *gsi) ...@@ -3596,6 +3601,7 @@ gimple_fold_builtin_strlen (gimple_stmt_iterator *gsi)
tree nonstr; tree nonstr;
tree lenrange[2]; tree lenrange[2];
if (!get_range_strlen (arg, lenrange, 1, true, &nonstr) if (!get_range_strlen (arg, lenrange, 1, true, &nonstr)
&& !nonstr
&& lenrange[0] && TREE_CODE (lenrange[0]) == INTEGER_CST && lenrange[0] && TREE_CODE (lenrange[0]) == INTEGER_CST
&& lenrange[1] && TREE_CODE (lenrange[1]) == INTEGER_CST) && lenrange[1] && TREE_CODE (lenrange[1]) == INTEGER_CST)
{ {
......
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