Denis Chertykov schrieb: > 2011/2/26 Georg-Johann Lay <a...@gjlay.de>: >> Georg-Johann Lay schrieb: >> >> http://gcc.gnu.org/ml/gcc-patches/2011-02/msg01441.html >> >>> The patch implements target hook TARGET_CANNOT_MODIFY_JUMPS_P in order >>> to inhibit post-reload bb reorder for naked functions. >>> >>> It's basically the same patch as proposed in bug data base and works >>> for the test case attached there. >>> >>> The patch works just as well for gcc-4.5.2. Should I provide a >>> seperate patch against 4.5.2 (tags/gcc_4_5_2_release) or is this patch >>> (against trunk) sufficient? >>> >>> Johann >>> >>> -- >>> >>> 2011-02-11 Georg-Johann Lay <a...@gjlay.de> >>> >>> PR target/42240 >>> * config/avr/avr.c (avr_cannot_modify_jumps_p): New function. >>> (TARGET_CANNOT_MODIFY_JUMPS_P): Define. >>> > > Applied. > > Denis.
This are backports to 4.3, 4.4, 4.5 branch, respectively (branches/gcc-4_*-branch/) I think PR42240 can be closed now Johann
Index: config/avr/avr.c =================================================================== --- config/avr/avr.c (revision 170651) +++ config/avr/avr.c (working copy) @@ -69,6 +69,7 @@ static void avr_file_start (void); static void avr_file_end (void); 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 void avr_insert_attributes (tree, tree *); static void avr_asm_init_sections (void); static unsigned int avr_section_type_flags (tree, const char *, int); @@ -328,6 +329,9 @@ int avr_case_values_threshold = 30000; #undef TARGET_STRICT_ARGUMENT_NAMING #define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true +#undef TARGET_CANNOT_MODIFY_JUMPS_P +#define TARGET_CANNOT_MODIFY_JUMPS_P avr_cannot_modify_jumps_p + struct gcc_target targetm = TARGET_INITIALIZER; void @@ -951,6 +955,27 @@ avr_asm_function_begin_epilogue (FILE *f 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. */
Index: config/avr/avr.c =================================================================== --- config/avr/avr.c (revision 170651) +++ config/avr/avr.c (working copy) @@ -72,6 +72,7 @@ static void avr_file_start (void); static void avr_file_end (void); 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); @@ -361,6 +362,9 @@ int avr_case_values_threshold = 30000; #undef TARGET_HARD_REGNO_SCRATCH_OK #define TARGET_HARD_REGNO_SCRATCH_OK avr_hard_regno_scratch_ok +#undef TARGET_CANNOT_MODIFY_JUMPS_P +#define TARGET_CANNOT_MODIFY_JUMPS_P avr_cannot_modify_jumps_p + struct gcc_target targetm = TARGET_INITIALIZER; void @@ -1093,6 +1097,27 @@ avr_asm_function_begin_epilogue (FILE *f 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. */
Index: config/avr/avr.c =================================================================== --- config/avr/avr.c (revision 170651) +++ config/avr/avr.c (working copy) @@ -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_a #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 *f 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. */