From 340fbfdc1bca32ef264e50a1bf654c8ae11c7954 Mon Sep 17 00:00:00 2001 From: Denis Chertykov Date: Thu, 3 Mar 2011 19:58:26 +0300 Subject: [PATCH] backport: re PR target/42240 (wrong epilogue on naked function) Backport from mainline 2011-02-22 Georg-Johann Lay PR target/42240 * config/avr/avr.c (avr_cannot_modify_jumps_p): New function. (TARGET_CANNOT_MODIFY_JUMPS_P): Define. From-SVN: r170657 --- gcc/ChangeLog | 9 +++++++++ gcc/config/avr/avr.c | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7c82dbade2ed..2013cf352e0f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2011-03-03 Denis Chertykov + + Backport from mainline + 2011-02-22 Georg-Johann Lay + + PR target/42240 + * config/avr/avr.c (avr_cannot_modify_jumps_p): New function. + (TARGET_CANNOT_MODIFY_JUMPS_P): Define. + 2011-03-03 Richard Guenther * tree-vect-stmt.c (vectorizable_operation): Remove unused vars. diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index 1e22f15c1fb4..639c770e8a8a 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -73,6 +73,7 @@ static void avr_file_end (void); static bool avr_legitimate_address_p (enum machine_mode, rtx, bool); static void avr_asm_function_end_prologue (FILE *); static void avr_asm_function_begin_epilogue (FILE *); +static bool avr_cannot_modify_jumps_p (void); static rtx avr_function_value (const_tree, const_tree, bool); static void avr_insert_attributes (tree, tree *); static void avr_asm_init_sections (void); @@ -196,6 +197,9 @@ static const struct attribute_spec avr_attribute_table[] = #undef TARGET_HELP #define TARGET_HELP avr_help +#undef TARGET_CANNOT_MODIFY_JUMPS_P +#define TARGET_CANNOT_MODIFY_JUMPS_P avr_cannot_modify_jumps_p + struct gcc_target targetm = TARGET_INITIALIZER; void @@ -991,6 +995,27 @@ avr_asm_function_begin_epilogue (FILE *file) fprintf (file, "/* epilogue start */\n"); } + +/* Implement TARGET_CANNOT_MODITY_JUMPS_P */ + +static bool +avr_cannot_modify_jumps_p (void) +{ + + /* Naked Functions must not have any instructions after + their epilogue, see PR42240 */ + + if (reload_completed + && cfun->machine + && cfun->machine->is_naked) + { + return true; + } + + return false; +} + + /* Return nonzero if X (an RTX) is a legitimate memory address on the target machine for a memory operand of mode MODE. */ -- 2.47.2