This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

target/4819: H8-300 port corrupts r3 on interrupt prologue & epilogue



>Number:         4819
>Category:       target
>Synopsis:       H8-300 port corrupts r3 on interrupt prologue & epilogue
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 07 06:06:03 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Richard Hodson
>Release:        gcc version 3.0.2
>Organization:
>Environment:
i386 Redhat 7.2 with gcc-3.0.2 host compiler
>Description:
On entry to an interrupt routine that requires local
stack space, the first thing that happens is the amount
of stack space is loaded into r3 and a sub r3,r7 executed.
This happens before r3 is saved, so on exit from the
interrupt routine r3 is corrupt.

eg...

_irq_handler:
	mov.w   #6,r3
        sub.w   r3,sp
	push    r0
        push    r2


The attached patch generates ugly code that simply issues
enough "subs #2,r7" instructions to allocate the required
memory.
>How-To-Repeat:
#pragma interrupt
irq_handler()
{
	int	lots_storage[3];

	lots_storage[0] = 1;
}
>Fix:
--- gcc-3.0.2/gcc/config/h8300/h8300.c  Thu Aug 30 19:06:05 2001
+++ gcc-3.0.2.patched/gcc/config/h8300/h8300.c  Tue Nov  6 15:45:24 2001
@@ -167,6 +167,7 @@
      subs since this shouldn't happen often.  */
   if ((TARGET_H8300 && size <= 4)
       || ((TARGET_H8300H || TARGET_H8300S) && size <= 8)
+      || (TARGET_H8300 && interrupt_handler )
       || (TARGET_H8300 && current_function_needs_context
          && ! strcmp (op, "sub")))
     {
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]