aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernd Edlinger <bernd.edlinger@hotmail.de>2018-08-22 23:43:44 +0000
committerJeff Law <law@gcc.gnu.org>2018-08-22 17:43:44 -0600
commit36d2d101fa9d21189195cce1e90b955096a79779 (patch)
tree5e2dacb95dffb68975016fb56187863415ed909c
parentf73a5316b6f76fa62979c29f4ec3620bf821dca0 (diff)
downloadgcc-36d2d101fa9d21189195cce1e90b955096a79779.zip
gcc-36d2d101fa9d21189195cce1e90b955096a79779.tar.gz
gcc-36d2d101fa9d21189195cce1e90b955096a79779.tar.bz2
tree-ssa-dse.c (compute_trims): Avoid folding away undefined behaviour.
* tree-ssa-dse.c (compute_trims): Avoid folding away undefined behaviour. From-SVN: r263793
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/tree-ssa-dse.c7
2 files changed, 12 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 606fb5f..f362c369 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2018-08-22 Bernd Edlinger <bernd.edlinger@hotmail.de>
+
+ * tree-ssa-dse.c (compute_trims): Avoid folding away undefined
+ behaviour.
+
2018-08-22 Martin Sebor <msebor@redhat.com>
PR middle-end/87052
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
index 4cb8c0f8..016aa6c 100644
--- a/gcc/tree-ssa-dse.c
+++ b/gcc/tree-ssa-dse.c
@@ -248,6 +248,13 @@ compute_trims (ao_ref *ref, sbitmap live, int *trim_head, int *trim_tail,
residual handling in mem* and str* functions is usually
reasonably efficient. */
*trim_tail = last_orig - last_live;
+
+ /* But don't trim away out of bounds accesses, as this defeats
+ proper warnings. */
+ if (*trim_tail
+ && compare_tree_int (TYPE_SIZE_UNIT (TREE_TYPE (ref->base)),
+ last_orig) <= 0)
+ *trim_tail = 0;
}
else
*trim_tail = 0;