From 938f9248db10f40bd95f09a53742e9063d4814ae Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Tue, 21 Nov 2017 14:39:14 +0100 Subject: [PATCH] Fix UBSAN errors in dse.c (PR rtl-optimization/82044). 2017-11-21 Martin Liska PR rtl-optimization/82044 PR tree-optimization/82042 * dse.c (check_mem_read_rtx): Check for overflow. From-SVN: r255001 --- gcc/ChangeLog | 6 ++++++ gcc/dse.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2f13296d330..eb2bdd64588 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-11-21 Martin Liska + + PR rtl-optimization/82044 + PR tree-optimization/82042 + * dse.c (check_mem_read_rtx): Check for overflow. + 2017-11-21 Aldy Hernandez * tree-ssa-threadbackward.c (find_jump_threads_backwards): Fix 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; -- 2.30.2