Bug 14151 - [new-ra] new-ra get frame size incorrect
Summary: [new-ra] new-ra get frame size incorrect
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.3.1
: P2 normal
Target Milestone: 4.0.0
Assignee: Michael Matz
URL:
Keywords: missed-optimization
Depends on:
Blocks: 16996 13246
  Show dependency treegraph
 
Reported: 2004-02-15 18:37 UTC by andy hutchinson
Modified: 2005-01-17 15:22 UTC (History)
3 users (show)

See Also:
Host:
Target: avr
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-02-15 18:45:32


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description andy hutchinson 2004-02-15 18:37:39 UTC
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 */



__________________________________________________________________
Comment 1 Andrew Pinski 2004-02-15 18:46:49 UTC
Suspending until either new-regalloc branch is merged to mainline, or bug is rechecked against 
new-regalloc branch.
Comment 2 Serge Belyshev 2004-04-08 21:03:00 UTC
new-regalloc branch fails to compile testcase:

$ ./xgcc -B. -S ~/tmp/14151.c 
/home/ssb/tmp/14151.c: In function `Timer0_Init':

/home/ssb/tmp/14151.c:11: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
$
Comment 3 andy hutchinson 2004-12-25 02:33:45 UTC
Problem still present on gcc (GCC) 4.0.0 20041205 (experimental) SNAPSHOT *sigh*
Comment 4 Steven Bosscher 2004-12-25 10:20:56 UTC
Andy, I think you should know this probably won't be fixed :-(  It is more
likely at this point that the whole new register allocator will be removed
as a failed experiment.  This is also why the bug status is SUSPENDED: It
will be closed as WONTFIX once it is decided for sure that new-ra is to be
removed from gcc.
Comment 5 Andrew Pinski 2005-01-17 15:22:51 UTC
Closing as wiill not fix as new-ra was removed from the mainline.