diff mbox

nds32: Backport PR70668 solution from mainline

Message ID 0c32ee11-c27f-9558-72f8-fbd1f25f705d@gmail.com
State New
Headers show

Commit Message

Chung-Ju Wu Jan. 10, 2017, 9:01 a.m. UTC
Hi, all,

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70668
https://gcc.gnu.org/ml/gcc-patches/2016-04/msg01862.html

Thanks Stefan Reinauer to create this PR and
thanks Segher Boessenkool to fix the issue.

Now I backport the solution to gcc-6 and gcc-5 branches.
Committed as revision r244257 and r244258.
https://gcc.gnu.org/r244257
https://gcc.gnu.org/r244258


Best regards,
jasonwucj

Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog	(revision 244256)
+++ gcc/ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2017-01-10  Chung-Ju Wu  <jasonwucj@gmail.com>
+
+	Backport from mainline
+	2016-04-28  Segher Boessenkool  <segher@kernel.crashing.org>
+
+	PR target/70668
+	* config/nds32/nds32.md (casesi): Don't access the operands array
+	out of bounds.
+
 2017-01-09  Andreas Tobler  <andreast@gcc.gnu.org>
 
 	Backport from mainline
Index: gcc/config/nds32/nds32.md
===================================================================
--- gcc/config/nds32/nds32.md	(revision 244256)
+++ gcc/config/nds32/nds32.md	(working copy)
@@ -2288,11 +2288,9 @@
   emit_jump_insn (gen_cbranchsi4 (test, operands[0], operands[2],
 				  operands[4]));
 
-  operands[5] = gen_reg_rtx (SImode);
-  /* Step C, D, E, and F, using another temporary register operands[5].  */
-  emit_jump_insn (gen_casesi_internal (operands[0],
-				       operands[3],
-				       operands[5]));
+  /* Step C, D, E, and F, using another temporary register.  */
+  rtx tmp = gen_reg_rtx (SImode);
+  emit_jump_insn (gen_casesi_internal (operands[0], operands[3], tmp));
   DONE;
 })
diff mbox

Patch

Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog	(revision 244256)
+++ gcc/ChangeLog	(working copy)
@@ -1,3 +1,12 @@ 
+2017-01-10  Chung-Ju Wu  <jasonwucj@gmail.com>
+
+	Backport from mainline
+	2016-04-28  Segher Boessenkool  <segher@kernel.crashing.org>
+
+	PR target/70668
+	* config/nds32/nds32.md (casesi): Don't access the operands array
+	out of bounds.
+
 2017-01-09  Andreas Tobler  <andreast@gcc.gnu.org>
 
 	Backport from mainline
Index: gcc/config/nds32/nds32.md
===================================================================
--- gcc/config/nds32/nds32.md	(revision 244256)
+++ gcc/config/nds32/nds32.md	(working copy)
@@ -2289,11 +2289,9 @@ 
   emit_jump_insn (gen_cbranchsi4 (test, operands[0], operands[2],
 				  operands[4]));
 
-  operands[5] = gen_reg_rtx (SImode);
-  /* Step C, D, E, and F, using another temporary register operands[5].  */
-  emit_jump_insn (gen_casesi_internal (operands[0],
-				       operands[3],
-				       operands[5]));
+  /* Step C, D, E, and F, using another temporary register.  */
+  rtx tmp = gen_reg_rtx (SImode);
+  emit_jump_insn (gen_casesi_internal (operands[0], operands[3], tmp));
   DONE;
 })