Hi Jeff, Hi Alex,

  Sorry - another MN10300 patch - this time for the stack size reported
  with -fstack-usage.  Currently the value includes the stack frame, but
  it does not take into account any registers that might have been
  pushed onto the stack.

  The patch below fixes this problem, but there is one thing that I am
  not sure about - is it OK to use __builtin_popcount() or should I be
  calling some other function ?

  Tested with no regression on an mn10300-elf toolchain.

  OK to apply ?

Cheers
  Nick

gcc/ChangeLog
2014-02-05  Nick Clifton  <ni...@redhat.com>

        * config/mn10300/mn10300.c (mn10300_expand_prologue): Include
        saved registers in current function's stack size.

Index: gcc/config/mn10300/mn10300.c
===================================================================
--- gcc/config/mn10300/mn10300.c        (revision 207498)
+++ gcc/config/mn10300/mn10300.c        (working copy)
@@ -745,13 +745,15 @@
 mn10300_expand_prologue (void)
 {
   HOST_WIDE_INT size = mn10300_frame_size ();
+  int mask;
 
+  mask = mn10300_get_live_callee_saved_regs (NULL);
+  /* If we use any of the callee-saved registers, save them now.  */
+  mn10300_gen_multiple_store (mask);
+
   if (flag_stack_usage_info)
-    current_function_static_stack_size = size;
+    current_function_static_stack_size = size + __builtin_popcount (mask) * 4;
 
-  /* If we use any of the callee-saved registers, save them now.  */
-  mn10300_gen_multiple_store (mn10300_get_live_callee_saved_regs (NULL));
-
   if (TARGET_AM33_2 && fp_regs_to_save ())
     {
       int num_regs_to_save = fp_regs_to_save (), i;
@@ -767,6 +769,9 @@
       unsigned int strategy_size = (unsigned)-1, this_strategy_size;
       rtx reg;
 
+      if (flag_stack_usage_info)
+       current_function_static_stack_size += num_regs_to_save * 4;
+
       /* We have several different strategies to save FP registers.
         We can store them using SP offsets, which is beneficial if
         there are just a few registers to save, or we can use `a0' in

Reply via email to