OSDN Git Service

* arm.c (arm_get_frame_size): A leaf function does not need its
authorrearnsha <rearnsha@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Nov 2002 10:22:02 +0000 (10:22 +0000)
committerrearnsha <rearnsha@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 21 Nov 2002 10:22:02 +0000 (10:22 +0000)
stack padding to an aligned boundary if it has no frame.
(thumb_get_frame_size): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@59339 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/arm/arm.c

index 9dad961..df99433 100644 (file)
@@ -1,3 +1,9 @@
+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>
 
        * emit-rtl.c (gen_reg_rtx): Simplify mapping of Complex type
index bc89418..a6203c3 100644 (file)
@@ -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;