Commit a3f94870 by Joey Ye

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
parent 96332fd8
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> 2011-08-18 Joseph Myers <joseph@codesourcery.com>
* c-decl.c (shadow_tag_warned): Check for _Noreturn. * c-decl.c (shadow_tag_warned): Check for _Noreturn.
......
...@@ -15230,6 +15230,7 @@ arm_output_epilogue (rtx sibling) ...@@ -15230,6 +15230,7 @@ arm_output_epilogue (rtx sibling)
&& !crtl->calls_eh_return && !crtl->calls_eh_return
&& bit_count(saved_regs_mask) * 4 == count && bit_count(saved_regs_mask) * 4 == count
&& !IS_INTERRUPT (func_type) && !IS_INTERRUPT (func_type)
&& !IS_STACKALIGN (func_type)
&& !crtl->tail_call_emit) && !crtl->tail_call_emit)
{ {
unsigned long mask; unsigned long mask;
......
2011-08-19 Joey Ye <joey.ye@arm.com> 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. * gcc.c-torture/execute/20101011-1.c (DO_TEST): Skip on ARM.
2011-08-19 Mikael Morin <mikael.morin@sfr.fr> 2011-08-19 Mikael Morin <mikael.morin@sfr.fr>
......
/* 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;
}
...@@ -2116,6 +2116,19 @@ proc check_effective_target_arm_thumb2 { } { ...@@ -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 # Return 1 if the target supports executing NEON instructions, 0
# otherwise. Cache the result. # otherwise. Cache the result.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment