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



--- Comment #1 from Freddie Chopin <freddie_chopin at op dot pl> 2012-12-20 
15:23:25 UTC ---

BTW - it seems that optimization settings don't make any difference here - the

code below was compiled with -Os, on all other levels (1,2,3) the assembly

looks like this:



00002e90 <DMA_IRQHandler>:

void DMA_IRQHandler(void) __attribute((interrupt));

void DMA_IRQHandler(void)

{

    2e90:    4668          mov    r0, sp

    2e92:    f020 0107     bic.w    r1, r0, #7

    2e96:    468d          mov    sp, r1

    2e98:    b401          push    {r0}

}

    2e9a:    bc01          pop    {r0}

    2e9c:    4685          mov    sp, r0

    2e9e:    4770          bx    lr





So it just saves r0 only, without saving lr. It's actually 2 bytes smaller than

the assembly done for size optimizations (;



Without optimization (-O0) I get:



0000473c <DMA_IRQHandler>:

void DMA_IRQHandler(void) __attribute((interrupt));

void DMA_IRQHandler(void)

{

    473c:    4668          mov    r0, sp

    473e:    f020 0107     bic.w    r1, r0, #7

    4742:    468d          mov    sp, r1

    4744:    b481          push    {r0, r7}

    4746:    af00          add    r7, sp, #0

}

    4748:    46bd          mov    sp, r7

    474a:    bc81          pop    {r0, r7}

    474c:    4685          mov    sp, r0

    474e:    4770          bx    lr



The commandline options used to compile:



arm-none-eabi-gcc -c -mcpu=cortex-m3 -mthumb -O0 -ffunction-sections

-fdata-sections -Wall -Wstrict-prototypes -Wextra -std=gnu99 -g -ggdb3

-fverbose-asm -Wa,-ahlms=out/uart.lst   -MD -MP -MF out/uart.d <some include

dirs> <input file> <output file>

Reply via email to