Fix UBSAN errors in dse.c (PR rtl-optimization/82044).
authorMartin Liska <mliska@suse.cz>
Tue, 21 Nov 2017 13:39:14 +0000 (14:39 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Tue, 21 Nov 2017 13:39:14 +0000 (13:39 +0000)
2017-11-21  Martin Liska  <mliska@suse.cz>

PR rtl-optimization/82044
PR tree-optimization/82042
* dse.c (check_mem_read_rtx): Check for overflow.

From-SVN: r255001

gcc/ChangeLog
gcc/dse.c

index 2f13296d330082a34d7a1a17e3f6a566ab9453a9..eb2bdd64588d597ac9000d9bb2826f0be08254a7 100644 (file)
@@ -1,3 +1,9 @@
+2017-11-21  Martin Liska  <mliska@suse.cz>
+
+       PR rtl-optimization/82044
+       PR tree-optimization/82042
+       * dse.c (check_mem_read_rtx): Check for overflow.
+
 2017-11-21  Aldy Hernandez  <aldyh@redhat.com>
 
        * tree-ssa-threadbackward.c (find_jump_threads_backwards): Fix
index 563ca9f56f3f2448d76d013f02762bf4fba21cde..f6d5e6e6fe26d7bace5f393c982ac0dfb0e7491b 100644 (file)
--- a/gcc/dse.c
+++ b/gcc/dse.c
@@ -1981,6 +1981,12 @@ check_mem_read_rtx (rtx *loc, bb_info_t bb_info)
   else
     width = GET_MODE_SIZE (GET_MODE (mem));
 
+  if (offset > HOST_WIDE_INT_MAX - width)
+    {
+      clear_rhs_from_active_local_stores ();
+      return;
+    }
+
   read_info = read_info_type_pool.allocate ();
   read_info->group_id = group_id;
   read_info->mem = mem;