From bdb69beee91adebad0d3b6b0d3dd0f3810dbe7a2 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Fri, 4 Jan 2008 15:56:41 +0000 Subject: [PATCH] re PR tree-optimization/34029 (internal compiler error: verify_stmts failed) 2008-01-04 Richard Guenther PR middle-end/34029 * tree-cfg.c (verify_expr): Do not look inside ADDR_EXPRs for verifying purposes if they are is_gimple_min_invariant. * gcc.c-torture/compile/pr34029-1.c: New testcase. * gcc.c-torture/compile/pr34029-2.c: Likewise. From-SVN: r131325 --- gcc/ChangeLog | 6 +++++ gcc/testsuite/ChangeLog | 6 +++++ .../gcc.c-torture/compile/pr34029-1.c | 22 +++++++++++++++++++ .../gcc.c-torture/compile/pr34029-2.c | 12 ++++++++++ gcc/tree-cfg.c | 5 +++++ 5 files changed, 51 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr34029-1.c create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr34029-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d0468013ed5..d16ff847e92 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-01-04 Richard Guenther + + PR middle-end/34029 + * tree-cfg.c (verify_expr): Do not look inside ADDR_EXPRs + for verifying purposes if they are is_gimple_min_invariant. + 2008-01-04 Aldy Hernandez PR tree-optimization/34448 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 239fbebd9bc..a8cdbf7731f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-01-04 Richard Guenther + + PR middle-end/34029 + * gcc.c-torture/compile/pr34029-1.c: New testcase. + * gcc.c-torture/compile/pr34029-2.c: Likewise. + 2008-01-04 Jakub Jelinek PR gcov-profile/34609 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr34029-1.c b/gcc/testsuite/gcc.c-torture/compile/pr34029-1.c new file mode 100644 index 00000000000..526112974b2 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr34029-1.c @@ -0,0 +1,22 @@ +static const char s[] = "ab.cd.efghijk"; + +int +foo (const char *x) +{ + const char *a; + int b = 0; + + a = __builtin_strchr (s, '.'); + if (a == 0) + b = 1; + else if ((a = __builtin_strchr (a + 1, '.')) == 0) + b = 1; + else if (__builtin_strncmp (s, x, a - s)) + b = 1; + else if (__builtin_strncmp (a + 1, x + (a - s + 1), 4) < 0) + b = 1; + + if (b) + return 4; + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/compile/pr34029-2.c b/gcc/testsuite/gcc.c-torture/compile/pr34029-2.c new file mode 100644 index 00000000000..9ec49ec97fa --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr34029-2.c @@ -0,0 +1,12 @@ +static const char s[] = "ab.cd.efghijk"; +static const char t[] = "abcde"; + +long +foo (const char *x) +{ + const char *a; + long b = 0; + + a = __builtin_strchr (s, '.'); + return ((long) a) + (1 - (long) t); +} diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 1606497ec6d..a8cb6276fc9 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -3218,6 +3218,11 @@ verify_expr (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) error ("address taken, but ADDRESSABLE bit not set"); return x; } + + /* Stop recursing and verifying invariant ADDR_EXPRs, they tend + to become arbitrary complicated. */ + if (is_gimple_min_invariant (t)) + *walk_subtrees = 0; break; }