summaryrefslogtreecommitdiff
path: root/gcc/dse.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2017-11-21 14:39:14 +0100
committerMartin Liska <marxin@gcc.gnu.org>2017-11-21 13:39:14 +0000
commit938f9248db10f40bd95f09a53742e9063d4814ae (patch)
tree91c9d0c44fc7b5f85ce97e48bc0232423cb36f0b /gcc/dse.c
parentddc1759a351bcf186aeafa34613ccc89cdba4913 (diff)
Fix UBSAN errors in dse.c (PR rtl-optimization/82044).
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
Diffstat (limited to 'gcc/dse.c')
-rw-r--r--gcc/dse.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/dse.c b/gcc/dse.c
index 563ca9f56f3..f6d5e6e6fe2 100644
--- 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;