Commit c231c91e by Richard Earnshaw Committed by Richard Earnshaw

arm.c (arm_get_frame_size): A leaf function does not need its stack padding to…

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
parent c3e0633c
2002-11-21 Richard Earnshaw <rearnsha@arm.com>
* 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 <sje@cup.hp.com> 2002-11-20 Steve Ellcey <sje@cup.hp.com>
* emit-rtl.c (gen_reg_rtx): Simplify mapping of Complex type * emit-rtl.c (gen_reg_rtx): Simplify mapping of Complex type
......
...@@ -8252,6 +8252,7 @@ arm_get_frame_size () ...@@ -8252,6 +8252,7 @@ arm_get_frame_size ()
int base_size = ROUND_UP (get_frame_size ()); int base_size = ROUND_UP (get_frame_size ());
int entry_size = 0; int entry_size = 0;
unsigned long func_type = arm_current_func_type (); unsigned long func_type = arm_current_func_type ();
int leaf;
if (! TARGET_ARM) if (! TARGET_ARM)
abort(); abort();
...@@ -8259,6 +8260,31 @@ arm_get_frame_size () ...@@ -8259,6 +8260,31 @@ arm_get_frame_size ()
if (! TARGET_ATPCS) if (! TARGET_ATPCS)
return base_size; 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 /* We know that SP will be word aligned on entry, and we must
preserve that condition at any subroutine call. But those are preserve that condition at any subroutine call. But those are
the only constraints. */ the only constraints. */
...@@ -8283,6 +8309,8 @@ arm_get_frame_size () ...@@ -8283,6 +8309,8 @@ arm_get_frame_size ()
if ((entry_size + base_size + current_function_outgoing_args_size) & 7) if ((entry_size + base_size + current_function_outgoing_args_size) & 7)
abort (); abort ();
cfun->machine->frame_size = base_size;
return base_size; return base_size;
} }
...@@ -10278,6 +10306,7 @@ thumb_get_frame_size () ...@@ -10278,6 +10306,7 @@ thumb_get_frame_size ()
int base_size = ROUND_UP (get_frame_size ()); int base_size = ROUND_UP (get_frame_size ());
int count_regs = 0; int count_regs = 0;
int entry_size = 0; int entry_size = 0;
int leaf;
if (! TARGET_THUMB) if (! TARGET_THUMB)
abort (); abort ();
...@@ -10300,6 +10329,16 @@ thumb_get_frame_size () ...@@ -10300,6 +10329,16 @@ thumb_get_frame_size ()
if (reload_completed) if (reload_completed)
return cfun->machine->frame_size; 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 /* We know that SP will be word aligned on entry, and we must
preserve that condition at any subroutine call. But those are preserve that condition at any subroutine call. But those are
the only constraints. */ the only constraints. */
...@@ -10322,7 +10361,7 @@ thumb_get_frame_size () ...@@ -10322,7 +10361,7 @@ thumb_get_frame_size ()
entry_size += 16; 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 */ count_regs++; /* LR */
entry_size += count_regs * 4; entry_size += count_regs * 4;
......
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