[Bug rtl-optimization/55757] Suboptimal interrupt prologue/epilogue for ARMv7-M (Cortex-M3)

freddie_chopin at op dot pl gcc-bugzilla@gcc.gnu.org
Thu Dec 20 17:08:00 GMT 2012


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

--- Comment #3 from Freddie Chopin <freddie_chopin at op dot pl> 2012-12-20 17:07:47 UTC ---
Indeed that's a trivial case, but other - useful - cases also show strange
behavior which I cannot clearly explain, so while we're at it I'd be grateful
for some explanation...

An interrupt handler function (void something(void)), but without attribute,
doing something inside (posts a FreeRTOS semaphore, calls vPortYieldFromISR()
if it's needed) actually saves a lot of registers on entry:
    23b4:    b507          push    {r0, r1, r2, lr}
>From what I know r0-r3 as scratch registers don't need to be saved on entry, as
it's the callers duty. There are also no parameters to be saved, as it's a void
function...

I observed the same behavior with some non-trivial functions from the lwIP
TCP/IP stack - they are also save scratch registers on entry, even when they
are void ...(void):

00005d00 <dns_init>:
void
dns_init()
{
    5d00:    b537          push    {r0, r1, r2, r4, r5, lr}

Is that a bug or maybe I don't understand the calling conventions? <;

BTW:
> The reason two registers are pushed, rather than one is that this is also needed to
> keep the stack aligned and pushing two registers uses less code than adjusting the stack in a separate insn.

But for optimization level 1, 2 and 3 only one reg is pushed...

Thx in advance!



More information about the Gcc-bugs mailing list