On 7/18/19 6:33 AM, Jozef Lawrynowicz wrote:
> The attached patch fixes an issue for msp430 where the logic to decide which
> registers need to be saved in an interrupt function was unnecessarily
> choosing to save all callee-saved registers regardless of whether they were
> used or not. This came at a code size and performance penalty for the 430 ISA,
> and a performance penalty for the 430X ISA.
> 
> Interrupt functions require special conventions for saving registers which
> would normally be caller-saved. Since the interrupt happens without warning,
> registers that would normally have been preserved by the caller of a function
> cannot be preserved when an interrupt is triggered. This means interrupts must
> save and restore the used caller-saved registers, in addition to the used
> callee-saved registers that a regular function would save.
> 
> If an interrupt is not a leaf function, all caller-saved registers must be
> saved/restored in the prologue/epilogue of the interrupt function, since it
> is unknown which of these will be modified in later functions.
> 
> We can rely on the function called by an interrupt to save and restore
> callee-saved registers, so it is unnecessary to save all callee-saved regs
> in the ISR. This is what this patch changes.
> 
> Successfully regtested for msp430-elf on trunk for C/C++.
> 
> Ok for trunk?
> 
> Thanks,
> Jozef
> 
> 
> 0001-MSP430-Fix-unnecessary-saving-of-all-callee-saved-re.patch
> 
> From 1e151dac2be34ae50bea8b4b37bd2d78c5f7ddd6 Mon Sep 17 00:00:00 2001
> From: Jozef Lawrynowicz <joze...@mittosystems.com>
> Date: Thu, 18 Jul 2019 09:25:52 +0100
> Subject: [PATCH] MSP430: Fix unnecessary saving of all callee-saved regs in an
>  ISR which calls another function
> 
> gcc/ChangeLog:
> 
> 2019-07-18  Jozef Lawrynowicz  <joze...@mittosystems.com>
> 
>       * config/msp430/msp430.c (msp430_preserve_reg_p): Don't save
>       callee-saved regs R4->R10 in an interrupt function that calls another
>       function.
> 
> gcc/testsuite/ChangeLog:
> 
> 2019-07-18  Jozef Lawrynowicz  <joze...@mittosystems.com>
> 
>       * gcc.target/msp430/isr-push-pop-main.c: New test.
>       * gcc.target/msp430/isr-push-pop-isr-430.c: Likewise.
>       * gcc.target/msp430/isr-push-pop-isr-430x.c: Likewise.
>       * gcc.target/msp430/isr-push-pop-leaf-isr-430.c: Likewise.
>       * gcc.target/msp430/isr-push-pop-leaf-isr-430x.c: Likewise.
OK
jeff

Reply via email to