aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2015-06-08 14:53:19 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2015-06-08 14:53:19 +0000
commitad3e2ba07405b81ed2c4729f63040ce2463c8108 (patch)
tree0a205221c4836a72e8edc9ffb5d1099bd9126a61
parente50869f7a638328f609afc0cbfa77ccaa2cbe01a (diff)
downloadgcc-ad3e2ba07405b81ed2c4729f63040ce2463c8108.zip
gcc-ad3e2ba07405b81ed2c4729f63040ce2463c8108.tar.gz
gcc-ad3e2ba07405b81ed2c4729f63040ce2463c8108.tar.bz2
re PR tree-optimization/66422 (-Warray-bounds false positive with -O3)
2015-06-08 Richard Biener <rguenther@suse.de> PR tree-optimization/66422 * tree-ssa-loop-ivcanon.c (remove_exits_and_undefined_stmts): Split block after inserted gcc_unreachable. * gcc.dg/Warray-bounds-16.c: New testcase. From-SVN: r224235
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/Warray-bounds-16.c40
-rw-r--r--gcc/tree-ssa-loop-ivcanon.c2
4 files changed, 52 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9908efd..55b5a83 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-06-08 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/66422
+ * tree-ssa-loop-ivcanon.c (remove_exits_and_undefined_stmts): Split
+ block after inserted gcc_unreachable.
+
2015-06-08 Nick Clifton <nickc@redhat.com>
* config/rx/rx.c (rx_function_value): Do not promote vector types.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 46e207bb..5537a46 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2015-06-08 Richard Biener <rguenther@suse.de>
+ PR tree-optimization/66422
+ * gcc.dg/Warray-bounds-16.c: New testcase.
+
+2015-06-08 Richard Biener <rguenther@suse.de>
+
* gcc.dg/vect/slp-perm-10.c: New testcase.
* gcc.dg/vect/slp-23.c: Adjust.
* gcc.dg/torture/pr53366-2.c: Also verify cross-iteration
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-16.c b/gcc/testsuite/gcc.dg/Warray-bounds-16.c
new file mode 100644
index 0000000..20008f6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-16.c
@@ -0,0 +1,40 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -Warray-bounds" } */
+
+typedef struct foo {
+ unsigned char foo_size;
+ int buf[4];
+ const char* bar;
+} foo;
+
+const foo *get_foo(int index);
+
+static int foo_loop(const foo *myfoo) {
+ int i;
+ if (myfoo->foo_size < 3)
+ return 0;
+ for (i = 0; i < myfoo->foo_size; i++) {
+ if (myfoo->buf[i] != 1) /* { dg-bogus "above array bounds" } */
+ return 0;
+ }
+
+ return 1;
+}
+
+static int run_foo(void) {
+ int i;
+ for (i = 0; i < 1; i++) {
+ const foo *myfoo = get_foo(i);
+ if (foo_loop(myfoo))
+ return 0;
+ }
+ return -1;
+}
+
+typedef struct hack {
+ int (*func)(void);
+} hack;
+
+hack myhack = {
+ .func = run_foo,
+};
diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c
index c561811..c1945d0 100644
--- a/gcc/tree-ssa-loop-ivcanon.c
+++ b/gcc/tree-ssa-loop-ivcanon.c
@@ -520,9 +520,9 @@ remove_exits_and_undefined_stmts (struct loop *loop, unsigned int npeeled)
gimple_stmt_iterator gsi = gsi_for_stmt (elt->stmt);
gcall *stmt = gimple_build_call
(builtin_decl_implicit (BUILT_IN_UNREACHABLE), 0);
-
gimple_set_location (stmt, gimple_location (elt->stmt));
gsi_insert_before (&gsi, stmt, GSI_NEW_STMT);
+ split_block (gimple_bb (stmt), stmt);
changed = true;
if (dump_file && (dump_flags & TDF_DETAILS))
{