avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] -O3 problem


From: Denis Chertykov
Subject: Re: [avr-gcc-list] -O3 problem
Date: 18 May 2001 22:03:06 +0400

Dean Ferreyra <address@hidden> writes:

> Hi,
> 
> I am running into this problem:  I'm using a couple of layers of inline
> functions.  When I compile with -O3 the generated assembly code changes the
> value of r29 which is busy in this function as the frame pointer.  When the
> function wants to return, this value gets copied back as the stack pointer
> killing the stack.  I've included a distilled sample below that trigger the
> problem and I've included the assembly output.  The problematic assignment
> to r29 can be seen on the third line after the prolog.
> 
> I'm using CVS updates from May 16, 2001 for binutils and gcc.  My host is
> cygwin.
> 
> My current workaround is to compile with -O2 or where possible change the
> function so that avr-gcc does not use an explicit stack frame pointer.

Thanks for bug report.
Thanks for good test case.
It was a generic GCC bug.

Patch:

Index: regrename.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/regrename.c,v
retrieving revision 1.21
diff -c -3 -p -r1.21 regrename.c
*** regrename.c 2001/05/14 07:56:57     1.21
--- regrename.c 2001/05/18 17:54:21
***************
*** 1,5 ****
  /* Register renaming for the GNU compiler.
!    Copyright (C) 2000 Free Software Foundation, Inc.
  
     This file is part of GNU CC.
  
--- 1,5 ----
  /* Register renaming for the GNU compiler.
!    Copyright (C) 2000, 2001 Free Software Foundation, Inc.
  
     This file is part of GNU CC.
  
*************** regrename_optimize ()
*** 219,227 ****
        /* Don't clobber traceback for noreturn functions.  */
        if (frame_pointer_needed)
        {
!         SET_HARD_REG_BIT (unavailable, FRAME_POINTER_REGNUM);
  #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
!         SET_HARD_REG_BIT (unavailable, HARD_FRAME_POINTER_REGNUM);
  #endif
        }
  
--- 219,232 ----
        /* Don't clobber traceback for noreturn functions.  */
        if (frame_pointer_needed)
        {
!         int i;
!         
!         for (i = HARD_REGNO_NREGS (FRAME_POINTER_REGNUM, Pmode); i--;)
!           SET_HARD_REG_BIT (unavailable, FRAME_POINTER_REGNUM + i);
!         
  #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
!         for (i = HARD_REGNO_NREGS (HARD_FRAME_POINTER_REGNUM, Pmode); i--;)
!           SET_HARD_REG_BIT (unavailable, HARD_FRAME_POINTER_REGNUM + i);
  #endif
        }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]