From: Senthil Kumar Selvaraj Date: Tue, 4 Sep 2012 09:21:20 +0000 (+0000) Subject: backport: re PR target/54220 ([avr] Potential stack corruption in naked functions... X-Git-Tag: releases/gcc-4.6.4~385 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29ff39b4e0ac771901e472717bdd185d42e4d119;p=thirdparty%2Fgcc.git backport: re PR target/54220 ([avr] Potential stack corruption in naked functions at -O0) Backport from 2012-09-04 mainline r190914 PR target/54220 * config/avr/avr.c (TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS): New define to... (avr_allocate_stack_slots_for_args): ...this new static function. From-SVN: r190917 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fa648e15a9b8..a4edd5c6b4a6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2012-09-04 Senthil Kumar Selvaraj + + Backport from 2012-09-04 mainline r190914 + + PR target/54220 + * config/avr/avr.c (TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS): New + define to... + (avr_allocate_stack_slots_for_args): ...this new static function. + 2012-09-03 H.J. Lu Backported from mainline diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index afba77909e9e..e60857980d8a 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -94,6 +94,7 @@ static bool avr_hard_regno_scratch_ok (unsigned int); static unsigned int avr_case_values_threshold (void); static bool avr_frame_pointer_required_p (void); static bool avr_can_eliminate (const int, const int); +static bool avr_allocate_stack_slots_for_args (void); static bool avr_class_likely_spilled_p (reg_class_t c); static rtx avr_function_arg (CUMULATIVE_ARGS *, enum machine_mode, const_tree, bool); @@ -218,6 +219,9 @@ static const struct default_options avr_option_optimization_table[] = #undef TARGET_CAN_ELIMINATE #define TARGET_CAN_ELIMINATE avr_can_eliminate +#undef TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS +#define TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS avr_allocate_stack_slots_for_args + #undef TARGET_CLASS_LIKELY_SPILLED_P #define TARGET_CLASS_LIKELY_SPILLED_P avr_class_likely_spilled_p @@ -446,6 +450,16 @@ avr_regs_to_save (HARD_REG_SET *set) return count; } + +/* Implement `TARGET_ALLOCATE_STACK_SLOTS_FOR_ARGS' */ + +static bool +avr_allocate_stack_slots_for_args (void) +{ + return !cfun->machine->is_naked; +} + + /* Return true if register FROM can be eliminated via register TO. */ bool