[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] ATmega2560 and r30/31 save in function prologue
From: |
Anatoly Sokolov |
Subject: |
Re: [avr-gcc-list] ATmega2560 and r30/31 save in function prologue |
Date: |
Sat, 3 May 2008 13:05:02 +0400 |
Hi.
> Anatoly, Andy, can you look at this?
Testcase:
#include <avr/interrupt.h>
void foo (void)
{
char tmp = PORTA;
}
ISR(INT0_vect)
{
foo();
}
int
main (void)
{
return 0;
}
Code compiled with -O0:
void foo (void)
{
ce: df 93 push r29
d0: cf 93 push r28
d2: 0f 92 push r0
d4: cd b7 in r28, 0x3d ; 61
d6: de b7 in r29, 0x3e ; 62
char tmp = PORTA;
d8: eb e3 ldi r30, 0x3B ; 59
da: f0 e0 ldi r31, 0x00 ; 0
dc: 80 81 ld r24, Z
de: 89 83 std Y+1, r24 ; 0x01
}
e0: 0f 90 pop r0
e2: cf 91 pop r28
e4: df 91 pop r29
e6: 08 95 ret
000000e8 <__vector_1>:
ISR(INT0_vect)
{
e8: 1f 92 push r1
ea: 0f 92 push r0
ec: 0f b6 in r0, 0x3f ; 63
ee: 0f 92 push r0
f0: 11 24 eor r1, r1
f2: df 93 push r29
f4: cf 93 push r28
f6: cd b7 in r28, 0x3d ; 61
f8: de b7 in r29, 0x3e ; 62
foo();
fa: 0e 94 67 00 call 0xce ; 0xce <foo>
}
fe: cf 91 pop r28
100: df 91 pop r29
102: 0f 90 pop r0
104: 0f be out 0x3f, r0 ; 63
106: 0f 90 pop r0
108: 1f 90 pop r1
10a: 18 95 reti
Interrupt handler call function and should to save all call used regs, but
don't save.
Problem possible is in avr_regs_to_save()/leaf_function_p() functions.
static int
avr_regs_to_save (HARD_REG_SET *set)
{
......
int leaf_func_p = leaf_function_p ();
warning (0, "leaf - %i", leaf_func_p);
Output:
main.c: In function 'foo':
main.c:5: warning: unused variable 'tmp'
main.c:6: warning: leaf - 1
main.c:6: warning: leaf - 1
main.c:6: warning: leaf - 1
main.c:6: warning: leaf - 1
main.c:6: warning: leaf - 1
main.c:6: warning: Prologue end
main.c:6: warning: leaf - 1
main.c: In function '__vector_1':
main.c:12: warning: leaf - 0
main.c:12: warning: leaf - 0
main.c:12: warning: leaf - 0
main.c:12: warning: leaf - 0
main.c:12: warning: leaf - 1
main.c:12: warning: Prologue end
main.c:12: warning: leaf - 1
...
foo() is don't call other functions and leaf_function_p () all return 1. ISR
is call foo() but leaf_function_p () surprising change return value acros
calls.
Anatoly.