avr.c (avr_regs_to_save): No need to save any registers in a noreturn function.
authorMarek Michalkiewicz <marekm@amelek.gda.pl>
Sat, 8 Jun 2002 17:25:43 +0000 (19:25 +0200)
committerMarek Michalkiewicz <marekm@gcc.gnu.org>
Sat, 8 Jun 2002 17:25:43 +0000 (17:25 +0000)
* config/avr/avr.c (avr_regs_to_save): No need to save any registers
in a noreturn function.
(avr_output_function_prologue, avr_output_function_epilogue):
Correct function size calculation.  Do not crash on empty function.
(avr_output_function_epilogue): No need for epilogue after a BARRIER.

From-SVN: r54386

gcc/ChangeLog
gcc/config/avr/avr.c

index 2bfaaf45ad94912cdc6b3a32d6ed0d5014f347e6..79f4ae56e09af1121e91baae7a6e8feac3416b13 100644 (file)
@@ -1,3 +1,11 @@
+2002-06-08  Marek Michalkiewicz  <marekm@amelek.gda.pl>
+
+       * config/avr/avr.c (avr_regs_to_save): No need to save any registers
+       in a noreturn function.
+       (avr_output_function_prologue, avr_output_function_epilogue):
+       Correct function size calculation.  Do not crash on empty function.
+       (avr_output_function_epilogue): No need for epilogue after a BARRIER.
+
 2002-06-08  Jason Thorpe  <thorpej@wasabisystems.com>
 
        * config/mips/netbsd.h (SUBTARGET_EXTRA_SPECS): Add
index c23059c6823e08d68971e999f44bf816ac9a7be5..41dcfbc74bbc8160091b81c400583f1728535386 100644 (file)
@@ -395,6 +395,11 @@ avr_regs_to_save (set)
   if (set)
     CLEAR_HARD_REG_SET (*set);
   count = 0;
+
+  /* No need to save any registers if the function never returns.  */
+  if (TREE_THIS_VOLATILE (current_function_decl))
+    return 0;
+
   for (reg = 0; reg < 32; reg++)
     {
       /* Do not push/pop __tmp_reg__, __zero_reg__, as well as
@@ -609,11 +614,16 @@ avr_output_function_prologue (file, size)
   int main_p;
   int live_seq;
   int minimize;
-  
+
+  last_insn_address = 0;
+  jump_tables_size = 0;
+  prologue_size = 0;
+  fprintf (file, "/* prologue: frame size=%d */\n", size);
+
   if (avr_naked_function_p (current_function_decl))
     {
-      fprintf (file, "/* prologue: naked */\n");
-      return;
+      fputs ("/* prologue: naked */\n", file);
+      goto out;
     }
 
   interrupt_func_p = interrupt_function_p (current_function_decl);
@@ -623,11 +633,6 @@ avr_output_function_prologue (file, size)
   minimize = (TARGET_CALL_PROLOGUES
              && !interrupt_func_p && !signal_func_p && live_seq);
 
-  last_insn_address = 0;
-  jump_tables_size = 0;
-  prologue_size = 0;
-  fprintf (file, "/* prologue: frame size=%d */\n", size);
-  
   if (interrupt_func_p)
     {
       fprintf (file,"\tsei\n");
@@ -722,6 +727,8 @@ avr_output_function_prologue (file, size)
          }
        }
     }
+
+ out:
   fprintf (file, "/* prologue end (size=%d) */\n", prologue_size);
 }
 
@@ -739,25 +746,39 @@ avr_output_function_epilogue (file, size)
   int function_size;
   int live_seq;
   int minimize;
+  rtx last = get_last_nonnote_insn ();
+
+  function_size = jump_tables_size;
+  if (last)
+    {
+      rtx first = get_first_nonnote_insn ();
+      function_size += (INSN_ADDRESSES (INSN_UID (last)) -
+                       INSN_ADDRESSES (INSN_UID (first)));
+      function_size += get_attr_length (last);
+    }
+
+  fprintf (file, "/* epilogue: frame size=%d */\n", size);
+  epilogue_size = 0;
 
   if (avr_naked_function_p (current_function_decl))
     {
-      fprintf (file, "/* epilogue: naked */\n");
-      return;
+      fputs ("/* epilogue: naked */\n", file);
+      goto out;
+    }
+
+  if (last && GET_CODE (last) == BARRIER)
+    {
+      fputs ("/* epilogue: noreturn */\n", file);
+      goto out;
     }
 
   interrupt_func_p = interrupt_function_p (current_function_decl);
   signal_func_p = signal_function_p (current_function_decl);
   main_p = MAIN_NAME_P (DECL_NAME (current_function_decl));
-  function_size = (INSN_ADDRESSES (INSN_UID (get_last_nonnote_insn ()))
-                  - INSN_ADDRESSES (INSN_UID (get_first_nonnote_insn ())));
-  function_size += jump_tables_size;
   live_seq = sequent_regs_live ();
   minimize = (TARGET_CALL_PROLOGUES
              && !interrupt_func_p && !signal_func_p && live_seq);
   
-  epilogue_size = 0;
-  fprintf (file, "/* epilogue: frame size=%d */\n", size);
   if (main_p)
     {
       /* Return value from main() is already in the correct registers
@@ -850,7 +871,8 @@ avr_output_function_epilogue (file, size)
        fprintf (file, "\tret\n");
       ++epilogue_size;
     }
-  
+
+ out:
   fprintf (file, "/* epilogue end (size=%d) */\n", epilogue_size);
   fprintf (file, "/* function %s size %d (%d) */\n", current_function_name,
           prologue_size + function_size + epilogue_size, function_size);