[new-ra] new register allocator get frame size wrong?

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

 




I have been trying new-ra for improved register allocation on avr target (8 bit registers, small memory etc)

The improvements are very good - 10% or more on code size. In particular it gets rid of redundant reg-reg moves between back to back library/function calls.

However, the 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.

Is this a bug? or am I missing somthing?


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

OPT = s

CC = avr-gcc
CFLAGS = -W -Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums  -O$(OPT)

.c.s:
    $(CC) $(CFLAGS) -c  -da -S $<

all:    testcase.s
clean:
    rm -f *.o
---------------------



    .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 */



__________________________________________________________________
New! Unlimited Netscape Internet Service.
Only $9.95 a month -- Sign up today at http://isp.netscape.com/register
Act now to get a personalized email address!

Netscape. Just the Net You Need.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux