[PATCH 2/2] [ARC] Fix millicode wrong blink restore.

Claudiu Zissulescu claziss@gmail.com
Tue Dec 11 10:23:00 GMT 2018


The blink is restored wrongly when using millicode and regular load
instructions.

gcc/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

	* config/arc/arc.c (arc_restore_callee_milli) Don't clobber off
	variable.

testsuite/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

	* gcc.target/arc/milli-1.c: New test.
---
 gcc/config/arc/arc.c                   |  4 +---
 gcc/testsuite/gcc.target/arc/milli-1.c | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/arc/milli-1.c

diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index 55175215bfe..5af3ee6c9e0 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -3597,9 +3597,7 @@ arc_restore_callee_milli (unsigned int gmask,
     insn = frame_insn (insn);
 
   /* Add DWARF info.  */
-  for (regno = start_reg, off = 0;
-       regno <= end_reg;
-       regno++, off += UNITS_PER_WORD)
+  for (regno = start_reg; regno <= end_reg; regno++)
     {
       reg = gen_rtx_REG (SImode, regno);
       add_reg_note (insn, REG_CFA_RESTORE, reg);
diff --git a/gcc/testsuite/gcc.target/arc/milli-1.c b/gcc/testsuite/gcc.target/arc/milli-1.c
new file mode 100644
index 00000000000..b501b39eb81
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/milli-1.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+/* Test if we restore correctly blink when using millicode.  */
+extern void bar (void);
+
+void foo (void)
+{
+  __asm__ volatile ( "" : : : "r13","r14","r15","r16","r17","r18","r20","r21");
+  bar();
+}
+
+void foo2 (void)
+{
+  bar();
+  __asm__ volatile ( "" : : : "r13","r14","r15","r16","r17","r18","r20","r21");
+}
+
+/* { dg-final { scan-assembler-not "st.*r13,\\\[sp" } } */
+/* { dg-final { scan-assembler-not "st.*r14,\\\[sp" } } */
+/* { dg-final { scan-assembler-not "st.*r15,\\\[sp" } } */
+/* { dg-final { scan-assembler "ld.*blink,\\\[sp,32" } } */
+/* { dg-final { scan-assembler "mov_s.*r12,32" } } */
-- 
2.19.1



More information about the Gcc-patches mailing list