mirror of git://gcc.gnu.org/git/gcc.git
[1/2] Add get_next_strinfo helper function
This patch just adds a helper function for getting the next strinfo in a chain, since part 2 adds another place where we do that. 2017-05-16 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * tree-ssa-strlen.c (get_next_strinfo): New function. (get_stridx_plus_constant): Use it. (zero_length_string): Likewise. (adjust_related_strinfos): Likewise. (adjust_last_stmt): Likewise. From-SVN: r248732
This commit is contained in:
parent
89c88990a8
commit
bde63fdea4
|
|
@ -1,3 +1,11 @@
|
||||||
|
2017-05-31 Richard Sandiford <richard.sandiford@linaro.org>
|
||||||
|
|
||||||
|
* tree-ssa-strlen.c (get_next_strinfo): New function.
|
||||||
|
(get_stridx_plus_constant): Use it.
|
||||||
|
(zero_length_string): Likewise.
|
||||||
|
(adjust_related_strinfos): Likewise.
|
||||||
|
(adjust_last_stmt): Likewise.
|
||||||
|
|
||||||
2017-05-31 Richard Biener <rguenther@suse.de>
|
2017-05-31 Richard Biener <rguenther@suse.de>
|
||||||
|
|
||||||
PR target/80880
|
PR target/80880
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,19 @@ get_strinfo (int idx)
|
||||||
return (*stridx_to_strinfo)[idx];
|
return (*stridx_to_strinfo)[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get the next strinfo in the chain after SI, or null if none. */
|
||||||
|
|
||||||
|
static inline strinfo *
|
||||||
|
get_next_strinfo (strinfo *si)
|
||||||
|
{
|
||||||
|
if (si->next == 0)
|
||||||
|
return NULL;
|
||||||
|
strinfo *nextsi = get_strinfo (si->next);
|
||||||
|
if (nextsi == NULL || nextsi->first != si->first || nextsi->prev != si->idx)
|
||||||
|
return NULL;
|
||||||
|
return nextsi;
|
||||||
|
}
|
||||||
|
|
||||||
/* Helper function for get_stridx. */
|
/* Helper function for get_stridx. */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
@ -665,10 +678,8 @@ get_stridx_plus_constant (strinfo *basesi, HOST_WIDE_INT off, tree ptr)
|
||||||
gcc_checking_assert (compare_tree_int (si->length, off) != -1);
|
gcc_checking_assert (compare_tree_int (si->length, off) != -1);
|
||||||
for (chainsi = si; chainsi->next; chainsi = si)
|
for (chainsi = si; chainsi->next; chainsi = si)
|
||||||
{
|
{
|
||||||
si = get_strinfo (chainsi->next);
|
si = get_next_strinfo (chainsi);
|
||||||
if (si == NULL
|
if (si == NULL
|
||||||
|| si->first != chainsi->first
|
|
||||||
|| si->prev != chainsi->idx
|
|
||||||
|| si->length == NULL_TREE
|
|| si->length == NULL_TREE
|
||||||
|| TREE_CODE (si->length) != INTEGER_CST)
|
|| TREE_CODE (si->length) != INTEGER_CST)
|
||||||
break;
|
break;
|
||||||
|
|
@ -736,26 +747,18 @@ zero_length_string (tree ptr, strinfo *chainsi)
|
||||||
si = verify_related_strinfos (chainsi);
|
si = verify_related_strinfos (chainsi);
|
||||||
if (si)
|
if (si)
|
||||||
{
|
{
|
||||||
chainsi = si;
|
do
|
||||||
for (; chainsi->next; chainsi = si)
|
|
||||||
{
|
{
|
||||||
if (chainsi->endptr == NULL_TREE)
|
gcc_assert (si->length || si->stmt);
|
||||||
|
if (si->endptr == NULL_TREE)
|
||||||
{
|
{
|
||||||
chainsi = unshare_strinfo (chainsi);
|
si = unshare_strinfo (si);
|
||||||
chainsi->endptr = ptr;
|
si->endptr = ptr;
|
||||||
}
|
}
|
||||||
si = get_strinfo (chainsi->next);
|
chainsi = si;
|
||||||
if (si == NULL
|
si = get_next_strinfo (si);
|
||||||
|| si->first != chainsi->first
|
|
||||||
|| si->prev != chainsi->idx)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
gcc_assert (chainsi->length || chainsi->stmt);
|
|
||||||
if (chainsi->endptr == NULL_TREE)
|
|
||||||
{
|
|
||||||
chainsi = unshare_strinfo (chainsi);
|
|
||||||
chainsi->endptr = ptr;
|
|
||||||
}
|
}
|
||||||
|
while (si != NULL);
|
||||||
if (chainsi->length && integer_zerop (chainsi->length))
|
if (chainsi->length && integer_zerop (chainsi->length))
|
||||||
{
|
{
|
||||||
if (chainsi->next)
|
if (chainsi->next)
|
||||||
|
|
@ -833,12 +836,8 @@ adjust_related_strinfos (location_t loc, strinfo *origsi, tree adj)
|
||||||
si->endptr = NULL_TREE;
|
si->endptr = NULL_TREE;
|
||||||
si->dont_invalidate = true;
|
si->dont_invalidate = true;
|
||||||
}
|
}
|
||||||
if (si->next == 0)
|
nsi = get_next_strinfo (si);
|
||||||
return;
|
if (nsi == NULL)
|
||||||
nsi = get_strinfo (si->next);
|
|
||||||
if (nsi == NULL
|
|
||||||
|| nsi->first != si->first
|
|
||||||
|| nsi->prev != si->idx)
|
|
||||||
return;
|
return;
|
||||||
si = nsi;
|
si = nsi;
|
||||||
}
|
}
|
||||||
|
|
@ -995,15 +994,9 @@ adjust_last_stmt (strinfo *si, gimple *stmt, bool is_strcat)
|
||||||
return;
|
return;
|
||||||
while (firstsi != lastsi)
|
while (firstsi != lastsi)
|
||||||
{
|
{
|
||||||
strinfo *nextsi;
|
firstsi = get_next_strinfo (firstsi);
|
||||||
if (firstsi->next == 0)
|
if (firstsi == NULL)
|
||||||
return;
|
return;
|
||||||
nextsi = get_strinfo (firstsi->next);
|
|
||||||
if (nextsi == NULL
|
|
||||||
|| nextsi->prev != firstsi->idx
|
|
||||||
|| nextsi->first != si->first)
|
|
||||||
return;
|
|
||||||
firstsi = nextsi;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue