Bug 36424 - avr-gcc use don't saved registers in ISR with -O3 ('-frename-registers' ) optimization
avr-gcc use don't saved registers in ISR with -O3 ('-frename-registers' ) opt...
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: target
4.4.0
: P3 normal
: 4.3.2
Assigned To: aesok
:
: 36423 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-06-02 17:55 UTC by aesok
Modified: 2008-06-15 21:36 UTC (History)
3 users (show)

See Also:
Host:
Target: avr-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
The patch for 36424 (1.96 KB, patch)
2008-06-02 18:06 UTC, aesok
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description aesok 2008-06-02 17:55:59 UTC
Testcase:
#include <avr/io.h>
#include <avr/interrupt.h>

volatile unsigned char   UART_RxChar;
volatile unsigned char   UART_ReceivedChar;

SIGNAL(SIG_USART_RECV)      
{
    /* Indicate that the UART has received a character */
    UART_ReceivedChar = 1;
    /* Store received character */
    UART_RxChar = UDR;
}

Request: use -frename-registers optimization, enabled on -O3.

Result code:
.global __vector_13
 .type __vector_13, @function
__vector_13:
.LFB2:
.LM1:
 push __zero_reg__
 push r0
 in r0,__SREG__
 push r0
 clr __zero_reg__
 push r24
/* prologue: Signal */
/* frame size = 0 */
.LM2:
 ldi r26,lo8(1)
 sts UART_ReceivedChar,r26
.LM3:
 lds r24,198
 sts UART_RxChar,r24
/* epilogue start */
.LM4:
 pop r24
 pop r0
 out __SREG__,r0
 pop r0
 pop __zero_reg__
 reti

R26 register used in ISR but don't saved/restored.

To fix bug, need define HARD_REGNO_RENAME_OK macro in config/avr.h

Anatoly.
Comment 1 aesok 2008-06-02 18:06:09 UTC
Created attachment 15713 [details]
The patch for 36424
Comment 2 Eric Weddington 2008-06-04 22:55:22 UTC
*** Bug 36423 has been marked as a duplicate of this bug. ***
Comment 3 aesok 2008-06-08 16:08:53 UTC
Subject: Bug 36424

Author: aesok
Date: Sun Jun  8 16:08:08 2008
New Revision: 136562

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=136562
Log:
	PR target/36424
	* config/avr/avr.h (HARD_REGNO_RENAME_OK): Define.
	* config/avr/avr.c (avr_hard_regno_rename_ok): New function. 
	* config/avr/avr-protos.h (avr_hard_regno_rename_ok): New prototype. 

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/avr/avr-protos.h
    trunk/gcc/config/avr/avr.c
    trunk/gcc/config/avr/avr.h

Comment 4 Eric Weddington 2008-06-08 17:32:29 UTC
Fixed for 4.4.0.
Comment 5 aesok 2008-06-15 21:33:12 UTC
Subject: Bug 36424

Author: aesok
Date: Sun Jun 15 21:32:29 2008
New Revision: 136826

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=136826
Log:
	PR target/36424
	* config/avr/avr.h (HARD_REGNO_RENAME_OK): Define.
	* config/avr/avr.c (avr_hard_regno_rename_ok): New function. 
	* config/avr/avr-protos.h (avr_hard_regno_rename_ok): New prototype. 

Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/config/avr/avr-protos.h
    branches/gcc-4_3-branch/gcc/config/avr/avr.c
    branches/gcc-4_3-branch/gcc/config/avr/avr.h

Comment 6 aesok 2008-06-15 21:36:38 UTC
Fixed for 4.3.2.