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



             Bug #: 55757

           Summary: Suboptimal interrupt prologue/epilogue for ARMv7-M

                    (Cortex-M3)

    Classification: Unclassified

           Product: gcc

           Version: 4.6.2

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: rtl-optimization

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: freddie_cho...@op.pl





With a Cortex-M3 microcontroller (ARMv7-M) and an empty interrupt handler

function:



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

void DMA_IRQHandler(void)

{



}



Results in suboptimal prologue/epilogue:



000023b4 <DMA_IRQHandler>:

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

void DMA_IRQHandler(void)

{

    23b4:    4668          mov    r0, sp

    23b6:    f020 0107     bic.w    r1, r0, #7

    23ba:    468d          mov    sp, r1

    23bc:    b501          push    {r0, lr}

}

    23be:    e8bd 4001     ldmia.w    sp!, {r0, lr}

    23c2:    4685          mov    sp, r0

    23c4:    4770          bx    lr

    ...



Without the __attribute__ the function is fine, just a single "bx lr".



This behavior is incorrect not only because r0 and lr are unused, but also

because on ARMv7-M these registers (r0-r3, lr, ip, sp, pc, psr) are saved by

hardware, so there's no point in saving them again.

Reply via email to