[Top][All Lists]

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

Re: [avr-gcc-list] Weird optimization issue with avr-gcc 4.5.3, re "nake

From: Georg-Johann Lay
Subject: Re: [avr-gcc-list] Weird optimization issue with avr-gcc 4.5.3, re "naked."
Date: Thu, 26 Jan 2012 23:10:43 +0100
User-agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)

William "Chops" Westfield schrieb:

A week or so ago I mentioned that avr-gcc 4.5.3 caused the optiboot
bootloader (used by Arduino and etc) to grow 22 bytes (from 500 bytes
to 522 bytes, pushing it over the size that it needs to be.)

Any thoughts as to what might be going on here?

Thanks WestfW

I tested the code with avr-gcc 4.5 and command line options -Os -mmcu=atmega8

With the attributes, the object size is 54 bytes.
Without the attributes the object size is 64 bytes.

If you get > 500 bytes you should turn on optimization.

The difference between 54 and 64 is because main's prologue is not void if it's not naked.

Herer is a diff between the respective assembler files:

 __SP_L__ = 0x3d
 __tmp_reg__ = 0
 __zero_reg__ = 1
-       .section        .init9,"ax",@progbits
+       .text
 .global        main
        .type   main, @function
-/* prologue: naked */
+       push r29
+       push r28
+       push __tmp_reg__
+       in r28,__SP_L__
+       in r29,__SP_H__
+/* prologue: function */
 /* frame size = 1 */
-/* stack size = 0 */
-.L__stack_usage = 0
+/* stack size = 3 */
+.L__stack_usage = 3
        rcall getch
        cpi r24,lo8(24)

So you see it's all about prologue and naked, the code is the same.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]