From: Martin Liska Date: Sun, 18 Mar 2018 20:17:10 +0000 (+0100) Subject: Fix UBSAN in regrename.c (PR rtl-optimization/84635). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f7dbf8e56459916a66af9fc62608109f65babd51;p=gcc.git Fix UBSAN in regrename.c (PR rtl-optimization/84635). 2018-03-18 Martin Liska PR rtl-optimization/84635 * regrename.c (build_def_use): Use matches_mode only when matches >= 0. From-SVN: r258634 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2a77e3b9245..9aab6e606d4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-03-18 Martin Liska + + PR rtl-optimization/84635 + * regrename.c (build_def_use): Use matches_mode only when + matches >= 0. + 2018-03-18 Richard Sandiford PR tree-optimization/84913 diff --git a/gcc/regrename.c b/gcc/regrename.c index dcec77adf75..45754812f6c 100644 --- a/gcc/regrename.c +++ b/gcc/regrename.c @@ -1703,14 +1703,18 @@ build_def_use (basic_block bb) and we must instead make sure to make the operand visible to the machinery that tracks hard registers. */ machine_mode i_mode = recog_data.operand_mode[i]; - machine_mode matches_mode = recog_data.operand_mode[matches]; - if (matches >= 0 - && maybe_ne (GET_MODE_SIZE (i_mode), - GET_MODE_SIZE (matches_mode)) - && !verify_reg_in_set (op, &live_in_chains)) + if (matches >= 0) { - untracked_operands |= 1 << i; - untracked_operands |= 1 << matches; + machine_mode matches_mode + = recog_data.operand_mode[matches]; + + if (maybe_ne (GET_MODE_SIZE (i_mode), + GET_MODE_SIZE (matches_mode)) + && !verify_reg_in_set (op, &live_in_chains)) + { + untracked_operands |= 1 << i; + untracked_operands |= 1 << matches; + } } } #ifdef STACK_REGS