re PR target/49437 (interrupt return pop sometimes corrupts sp)

PR target/49437
       * config/arm/arm.c (arm_output_epilogue): Properly handle epilogue
       when stack was realigned in interrupt handler prologue.

testsuite:

       PR target/49437
       * gcc.target/arm/handler-align.c: New test.
       * lib/target-supports.exp (check_effective_target_arm_cortex_m):
         New Function.

From-SVN: r177891
This commit is contained in:
Joey Ye 2011-08-19 08:28:08 +00:00
parent 96332fd82c
commit a3f9487098
5 changed files with 69 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2011-08-19 Matthew Gretton-Dann <matthew.gretton-dann@arm.com>
PR target/49437
* config/arm/arm.c (arm_output_epilogue): Properly handle epilogue
when stack was realigned in interrupt handler prologue.
2011-08-18 Joseph Myers <joseph@codesourcery.com>
* c-decl.c (shadow_tag_warned): Check for _Noreturn.

View File

@ -15230,6 +15230,7 @@ arm_output_epilogue (rtx sibling)
&& !crtl->calls_eh_return
&& bit_count(saved_regs_mask) * 4 == count
&& !IS_INTERRUPT (func_type)
&& !IS_STACKALIGN (func_type)
&& !crtl->tail_call_emit)
{
unsigned long mask;

View File

@ -1,3 +1,10 @@
2011-08-19 Joey Ye <joey.ye@arm.com>
PR target/49437
* gcc.target/arm/handler-align.c: New test.
* lib/target-supports.exp (check_effective_target_arm_cortex_m):
New Function.
2011-08-19 Joey Ye <joey.ye@arm.com>
* gcc.c-torture/execute/20101011-1.c (DO_TEST): Skip on ARM.

View File

@ -0,0 +1,42 @@
/* Test epilogue of a realigned interrupt handler. */
/* { dg-do run } */
/* { dg-options "-mthumb -Os" } */
/* { dg-skip-if "" { ! { arm_thumb1_ok || arm_thumb2_ok } } } */
/* { dg-require-effective-target arm_cortex_m } */
/* { dg-require-effective-target arm_eabi } */
extern __attribute__((noreturn)) void abort(void);
extern int snprintf(char *, int, const char *, ...);
#define BUFF_LEN 256
char buff[BUFF_LEN];
char *get_buffer(void)
{
return buff;
}
void __attribute__((interrupt)) foo(void)
{
char *msg = get_buffer();
snprintf(msg, BUFF_LEN, "%d %p", 1, buff+BUFF_LEN);
}
volatile void * save_sp;
int main()
{
register volatile void * sp asm("sp");
/* Check stack pointer before/after calling the interrupt
* handler. Not equal means that handler doesn't restore
* stack correctly. */
save_sp = sp;
foo();
/* Abort here instead of return non-zero. Due to wrong sp, lr value,
* returning from main may not work. */
if (save_sp != sp)
{
sp = save_sp;
abort();
}
return 0;
}

View File

@ -2116,6 +2116,19 @@ proc check_effective_target_arm_thumb2 { } {
} ""]
}
# Return 1 if this is an ARM cortex-M profile cpu
proc check_effective_target_arm_cortex_m { } {
return [check_no_compiler_messages arm_cortex_m assembly {
#if !defined(__ARM_ARCH_7M__) \
&& !defined (__ARM_ARCH_7EM__) \
&& !defined (__ARM_ARCH_6M__)
#error FOO
#endif
int i;
} "-mthumb"]
}
# Return 1 if the target supports executing NEON instructions, 0
# otherwise. Cache the result.