This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
SH interrupt handler sibcall patch
- From: Tony Bryant <brd at paradise dot net dot nz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 17 May 2002 14:31:46 +1200
- Subject: SH interrupt handler sibcall patch
- Organization: Bryant Research & Development
This patch stops Hitachi SH interrupt handlers erroneously tail calling other
procedures, which almost certainly don't have the right stack pop/rte ending
sequence.
some text for the changelog: Stop interrupt handlers from tail calling
? shsibcall.patch
Index: sh.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.h,v
retrieving revision 1.142
diff -u -r1.142 sh.h
--- sh.h 15 May 2002 05:29:59 -0000 1.142
+++ sh.h 17 May 2002 02:26:57 -0000
@@ -1608,8 +1608,18 @@
receives arguments ``by reference'' will have them stored in its
own stack frame, so it must not pass pointers or references to
these arguments to other functions by means of sibling calls. */
-#define FUNCTION_OK_FOR_SIBCALL(DECL) \
- (! TARGET_SHCOMPACT || current_function_args_info.stack_regs == 0)
+
+/* Stop interrupt routines from being candidates for tail calls (as the
+ caller) since the callee won't be restoring all the registers required by
+ an interrupt handler */
+
+#define FUNCTION_OK_FOR_SIBCALL(DECL) \
+ ((lookup_attribute \
+ ("interrupt_handler", \
+ DECL_ATTRIBUTES (current_function_decl))\
+ == NULL_TREE) \
+ && \
+ ( ! TARGET_SHCOMPACT || current_function_args_info.stack_regs == 0))
/* Update the data in CUM to advance over an argument
of mode MODE and data type TYPE.