]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
arc: Fix interrupt's epilogue.
authorClaudiu Zissulescu <claziss@gmail.com>
Mon, 18 Jul 2022 11:32:41 +0000 (14:32 +0300)
committerClaudiu Zissulescu <claziss@gmail.com>
Mon, 18 Jul 2022 11:36:58 +0000 (14:36 +0300)
The stack pointer adjustment in interrupt epilogue is happening after
restoring the ZOL registers which is wrong. Fixing this.

gcc/
* config/arc/arc.cc (arc_expand_epilogue): Adjust the frame
pointer first when in interrupts.

gcc/testsuite/
* gcc.target/arc/interrupt-13.c: New file.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
gcc/config/arc/arc.cc
gcc/testsuite/gcc.target/arc/interrupt-13.c [new file with mode: 0644]

index fbc17e684a027f35a83879fa0d920f7968ba499f..77730c88e55ae0ec4541a5c1385378513a1eb52e 100644 (file)
@@ -3965,7 +3965,7 @@ arc_expand_epilogue (int sibcall_p)
   if (size)
     emit_insn (gen_blockage ());
 
-  if (ARC_INTERRUPT_P (fn_type) && restore_fp)
+  if (ARC_INTERRUPT_P (fn_type))
     {
       /* We need to restore FP before any SP operation in an
         interrupt.  */
diff --git a/gcc/testsuite/gcc.target/arc/interrupt-13.c b/gcc/testsuite/gcc.target/arc/interrupt-13.c
new file mode 100644 (file)
index 0000000..0ed8451
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-options "-O2" } */
+
+extern int foo (int *);
+
+void __attribute__((interrupt("ilink")))
+irq (void)
+{
+  struct {
+    int x0;
+    int x1;
+  } a = {1 ,2};
+  foo ((int *)&a);
+}
+
+/* { dg-final { scan-assembler "add_s\\s+sp,sp,8.*pop_s\\s+r0" } } */