Fix UBSAN in regrename.c (PR rtl-optimization/84635).
authorMartin Liska <mliska@suse.cz>
Sun, 18 Mar 2018 20:17:10 +0000 (21:17 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Sun, 18 Mar 2018 20:17:10 +0000 (20:17 +0000)
2018-03-18  Martin Liska  <mliska@suse.cz>

PR rtl-optimization/84635
* regrename.c (build_def_use): Use matches_mode only when
matches >= 0.

From-SVN: r258634

gcc/ChangeLog
gcc/regrename.c

index 2a77e3b..9aab6e6 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-18  Martin Liska  <mliska@suse.cz>
+
+       PR rtl-optimization/84635
+       * regrename.c (build_def_use): Use matches_mode only when
+       matches >= 0.
+
 2018-03-18  Richard Sandiford  <richard.sandiford@linaro.org>
 
        PR tree-optimization/84913
index dcec77a..4575481 100644 (file)
@@ -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