SH interrupt handler sibcall patch

Tony Bryant brd@paradise.net.nz
Thu May 16 20:24:00 GMT 2002


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.



More information about the Gcc-patches mailing list