From c231c91e55dc682714c19682e79d06c191f4a30d Mon Sep 17 00:00:00 2001 From: Richard Earnshaw Date: Thu, 21 Nov 2002 10:22:02 +0000 Subject: [PATCH] arm.c (arm_get_frame_size): A leaf function does not need its stack padding to an aligned boundary if... * arm.c (arm_get_frame_size): A leaf function does not need its stack padding to an aligned boundary if it has no frame. (thumb_get_frame_size): Likewise. From-SVN: r59339 --- gcc/ChangeLog | 6 ++++++ gcc/config/arm/arm.c | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9dad9619023..df994334a80 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2002-11-21 Richard Earnshaw + + * arm.c (arm_get_frame_size): A leaf function does not need its + stack padding to an aligned boundary if it has no frame. + (thumb_get_frame_size): Likewise. + 2002-11-20 Steve Ellcey * emit-rtl.c (gen_reg_rtx): Simplify mapping of Complex type diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index bc89418e1e5..a6203c3fbe3 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -8252,6 +8252,7 @@ arm_get_frame_size () int base_size = ROUND_UP (get_frame_size ()); int entry_size = 0; unsigned long func_type = arm_current_func_type (); + int leaf; if (! TARGET_ARM) abort(); @@ -8259,6 +8260,31 @@ arm_get_frame_size () if (! TARGET_ATPCS) return base_size; + /* We need to know if we are a leaf function. Unfortunately, it + is possible to be called after start_sequence has been called, + which causes get_insns to return the insns for the sequence, + not the function, which will cause leaf_function_p to return + the incorrect result. + + To work around this, we cache the computed frame size. This + works because we will only be calling RTL expanders that need + to know about leaf functions once reload has completed, and the + frame size cannot be changed after that time, so we can safely + use the cached value. */ + + if (reload_completed) + return cfun->machine->frame_size; + + leaf = leaf_function_p (); + + /* A leaf function does not need any stack alignment if it has nothing + on the stack. */ + if (leaf && base_size == 0) + { + cfun->machine->frame_size = 0; + return 0; + } + /* We know that SP will be word aligned on entry, and we must preserve that condition at any subroutine call. But those are the only constraints. */ @@ -8283,6 +8309,8 @@ arm_get_frame_size () if ((entry_size + base_size + current_function_outgoing_args_size) & 7) abort (); + cfun->machine->frame_size = base_size; + return base_size; } @@ -10278,6 +10306,7 @@ thumb_get_frame_size () int base_size = ROUND_UP (get_frame_size ()); int count_regs = 0; int entry_size = 0; + int leaf; if (! TARGET_THUMB) abort (); @@ -10300,6 +10329,16 @@ thumb_get_frame_size () if (reload_completed) return cfun->machine->frame_size; + leaf = leaf_function_p (); + + /* A leaf function does not need any stack alignment if it has nothing + on the stack. */ + if (leaf && base_size == 0) + { + cfun->machine->frame_size = 0; + return 0; + } + /* We know that SP will be word aligned on entry, and we must preserve that condition at any subroutine call. But those are the only constraints. */ @@ -10322,7 +10361,7 @@ thumb_get_frame_size () entry_size += 16; } - if (count_regs || !leaf_function_p () || thumb_far_jump_used_p (1)) + if (count_regs || !leaf || thumb_far_jump_used_p (1)) count_regs++; /* LR */ entry_size += count_regs * 4; -- 2.30.2