Commit d9cc481a by Adam Nemet

re PR middle-end/37669 (ice for legal code with -O2)

	PR middle-end/37669
	* tree-ssa-ccp.c (ccp_fold_builtin): Only allow one argument to be
	processed by get_maxval_strlen.

testsuite/
	PR middle-end/37669
	* gcc.c-torture/compile/pr37669-2.c: New test.

From-SVN: r141270
parent 3b8031bb
2008-10-21 Adam Nemet <anemet@caviumnetworks.com>
PR middle-end/37669
* tree-ssa-ccp.c (ccp_fold_builtin): Only allow one argument to be
processed by get_maxval_strlen.
2008-10-21 David Edelsohn <edelsohn@gnu.org> 2008-10-21 David Edelsohn <edelsohn@gnu.org>
PR target/35485 PR target/35485
......
2008-10-21 Jakub Jelinek <jakub@redhat.com>
PR middle-end/37669
* gcc.c-torture/compile/pr37669-2.c: New test.
2008-10-21 Richard Guenther <rguenther@suse.de> 2008-10-21 Richard Guenther <rguenther@suse.de>
* gcc.dg/tree-ssa/alias-19.c: New testcase. * gcc.dg/tree-ssa/alias-19.c: New testcase.
......
/* PR middle-end/37669 */
#define FMT10 "%d%d%d%d%d%d%d%d%d%d"
#define FMT100 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10 FMT10
#define FMT1000 FMT100 FMT100 FMT100 FMT100 FMT100 \
FMT100 FMT100 FMT100 FMT100 FMT100
#define ARG10 , i, i, i, i, i, i, i, i, i, i
#define ARG100 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10 ARG10
#define ARG1000 ARG100 ARG100 ARG100 ARG100 ARG100 \
ARG100 ARG100 ARG100 ARG100 ARG100
void foo (char *s, int i, int j)
{
__builtin___snprintf_chk (s, i, 1, j, FMT1000 ARG1000);
}
...@@ -2430,7 +2430,7 @@ ccp_fold_builtin (gimple stmt) ...@@ -2430,7 +2430,7 @@ ccp_fold_builtin (gimple stmt)
{ {
tree result, val[3]; tree result, val[3];
tree callee, a; tree callee, a;
int arg_mask, i, type; int arg_idx, type;
bitmap visited; bitmap visited;
bool ignore; bool ignore;
int nargs; int nargs;
...@@ -2466,12 +2466,12 @@ ccp_fold_builtin (gimple stmt) ...@@ -2466,12 +2466,12 @@ ccp_fold_builtin (gimple stmt)
case BUILT_IN_STRLEN: case BUILT_IN_STRLEN:
case BUILT_IN_FPUTS: case BUILT_IN_FPUTS:
case BUILT_IN_FPUTS_UNLOCKED: case BUILT_IN_FPUTS_UNLOCKED:
arg_mask = 1; arg_idx = 0;
type = 0; type = 0;
break; break;
case BUILT_IN_STRCPY: case BUILT_IN_STRCPY:
case BUILT_IN_STRNCPY: case BUILT_IN_STRNCPY:
arg_mask = 2; arg_idx = 1;
type = 0; type = 0;
break; break;
case BUILT_IN_MEMCPY_CHK: case BUILT_IN_MEMCPY_CHK:
...@@ -2479,17 +2479,17 @@ ccp_fold_builtin (gimple stmt) ...@@ -2479,17 +2479,17 @@ ccp_fold_builtin (gimple stmt)
case BUILT_IN_MEMMOVE_CHK: case BUILT_IN_MEMMOVE_CHK:
case BUILT_IN_MEMSET_CHK: case BUILT_IN_MEMSET_CHK:
case BUILT_IN_STRNCPY_CHK: case BUILT_IN_STRNCPY_CHK:
arg_mask = 4; arg_idx = 2;
type = 2; type = 2;
break; break;
case BUILT_IN_STRCPY_CHK: case BUILT_IN_STRCPY_CHK:
case BUILT_IN_STPCPY_CHK: case BUILT_IN_STPCPY_CHK:
arg_mask = 2; arg_idx = 1;
type = 1; type = 1;
break; break;
case BUILT_IN_SNPRINTF_CHK: case BUILT_IN_SNPRINTF_CHK:
case BUILT_IN_VSNPRINTF_CHK: case BUILT_IN_VSNPRINTF_CHK:
arg_mask = 2; arg_idx = 1;
type = 2; type = 2;
break; break;
default: default:
...@@ -2498,18 +2498,12 @@ ccp_fold_builtin (gimple stmt) ...@@ -2498,18 +2498,12 @@ ccp_fold_builtin (gimple stmt)
/* Try to use the dataflow information gathered by the CCP process. */ /* Try to use the dataflow information gathered by the CCP process. */
visited = BITMAP_ALLOC (NULL); visited = BITMAP_ALLOC (NULL);
bitmap_clear (visited);
memset (val, 0, sizeof (val)); memset (val, 0, sizeof (val));
for (i = 0; i < nargs; i++) a = gimple_call_arg (stmt, arg_idx);
{ if (!get_maxval_strlen (a, &val[arg_idx], visited, type))
if ((arg_mask >> i) & 1) val[arg_idx] = NULL_TREE;
{
a = gimple_call_arg (stmt, i);
bitmap_clear (visited);
if (!get_maxval_strlen (a, &val[i], visited, type))
val[i] = NULL_TREE;
}
}
BITMAP_FREE (visited); BITMAP_FREE (visited);
......
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