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]
Other format: [Raw text]

[Bug c/14151] New: new-ra get frame size incorrect


new-ra gives substantial code size and speed improvments on avr target.
However, gain is lost because the frame size is wrong. Or more precisely the
frame size reflects the inclusion of stack slots that have been optimised away.

Code below show a simple case where frame size is 2 - presumably reflecting the
"i" local variable that is in a register.

Without -fnew-ra, the epilog/prolog is empty (ie frame pointer can be eliminated)

I have managed to determine that the AVR target is being told that the frame
size is 2.

int CallbackFunc[10];
void Timer0_Init(void)
{
    //mt char i;
	char i;

    // Initialize array of callback functions
    for (i=0; i<10; i++)
        CallbackFunc[i] = 0;

}





compiler options (GCC 3.3.1 target AVR). Host win2k and XP

-Os -W -Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums  


WITHOUT -new-ra we get no frame (since it get optimized away)

    .file   "testcase.c"
    .arch avr2
__SREG__ = 0x3f
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__tmp_reg__ = 0
__zero_reg__ = 1
    .global __do_copy_data
    .global __do_clear_bss
    .text
.global Timer0_Init
    .type   Timer0_Init, @function
Timer0_Init:
/* prologue: frame size=0 */
/* prologue end (size=0) */
    ldi r24,lo8(0)
    ldi r30,lo8(CallbackFunc)
    ldi r31,hi8(CallbackFunc)
.L6:
    st Z+,__zero_reg__
    st Z+,__zero_reg__
    subi r24,lo8(-(1))
    cpi r24,lo8(10)
    brlo .L6
/* epilogue: frame size=0 */
    ret
/* epilogue end (size=1) */
/* function Timer0_Init size 9 (8) */
    .size   Timer0_Init, .-Timer0_Init
    .comm CallbackFunc,20,1
/* File "testcase.c": code    9 = 0x0009 (   8), prologues   0, epilogues   1 */


NOW WITH -new-ra we get:
========================

    .file   "testcase.c"
    .arch avr2
__SREG__ = 0x3f
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__tmp_reg__ = 0
__zero_reg__ = 1
    .global __do_copy_data
    .global __do_clear_bss
    .text
.global Timer0_Init
    .type   Timer0_Init, @function
Timer0_Init:
/* prologue: frame size=2 */<============================
    push r28<========================================
    push r29<========================================
    in r28,__SP_L__
    in r29,__SP_H__
    sbiw r28,2
    in __tmp_reg__,__SREG__
    cli
    out __SP_H__,r29
    out __SREG__,__tmp_reg__
    out __SP_L__,r28
/* prologue end (size=10) */
    ldi r24,lo8(0)
    ldi r30,lo8(CallbackFunc)
    ldi r31,hi8(CallbackFunc)
.L6:
    st Z+,__zero_reg__
    st Z+,__zero_reg__
    subi r24,lo8(-(1))
    cpi r24,lo8(10)
    brlo .L6
/* epilogue: frame size=2 */
    adiw r28,2
    in __tmp_reg__,__SREG__
    cli
    out __SP_H__,r29
    out __SREG__,__tmp_reg__
    out __SP_L__,r28
    pop r29
    pop r28
    ret
/* epilogue end (size=9) */
/* function Timer0_Init size 27 (8) */
    .size   Timer0_Init, .-Timer0_Init
    .comm CallbackFunc,20,1
/* File "testcase.c": code   27 = 0x001b (   8), prologues  10, epilogues   9 */



__________________________________________________________________

-- 
           Summary: new-ra get frame size incorrect
           Product: gcc
           Version: new-ra
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andrewhutchinson at cox dot net
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: 3.3.1
GCC target triplet: avr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14151


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