This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

patch affecting functions that fall off end



This patch fixes a problem on targets where have_RETURN can be set
before reload (from what I can see, that's i960 and sparc when
-mno-epilogue is passed).  When a function was declared to return
a value but had no 'return' statements, we weren't emitting
the CLOBBERS of the return value registers, which caused
among other things GCC to not warn that the function could fail
to return a value.  This patch fixes it.

Tested by bootstrap on sparc-sun-solaris2.6 and 'make check' with and
without -mno-epilogue (the 'make check' is still running, I'll commit
when it's done, I note that sparc does not bootstrap cleanly at
present due to some problem in libffi).

-- 
- Geoffrey Keating <geoffk@geoffk.org>

===File ~/patches/cygnus/nortel-returnwarn.patch============
2001-04-24  Geoffrey Keating  <geoffk@redhat.com>

	* function.c (expand_function_end): Always clobber the
	return registers, even if there is no return label.

Index: function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.265
diff -p -u -p -r1.265 function.c
--- function.c	2001/04/20 07:56:50	1.265
+++ function.c	2001/04/24 16:49:38
@@ -6777,31 +6777,29 @@ expand_function_end (filename, line, end
      SDB depends on this.  */
   emit_line_note_force (filename, line);
 
+  /* Before the return label (if any), clobber the return
+     registers so that they are not propogated live to the rest of
+     the function.  This can only happen with functions that drop
+     through; if there had been a return statement, there would
+     have either been a return rtx, or a jump to the return label.  */
+  {
+    rtx before, after;
+    
+    before = get_last_insn ();
+    clobber_return_register ();
+    after = get_last_insn ();
+    
+    if (before != after)
+      cfun->x_clobber_return_insn = after;
+  }
+
   /* Output the label for the actual return from the function,
      if one is expected.  This happens either because a function epilogue
      is used instead of a return instruction, or because a return was done
      with a goto in order to run local cleanups, or because of pcc-style
      structure returning.  */
-
   if (return_label)
-    {
-      rtx before, after;
-
-      /* Before the return label, clobber the return registers so that
-         they are not propogated live to the rest of the function.  This
-	 can only happen with functions that drop through; if there had
-	 been a return statement, there would have either been a return
-	 rtx, or a jump to the return label.  */
-
-      before = get_last_insn ();
-      clobber_return_register ();
-      after = get_last_insn ();
-
-      if (before != after)
-	cfun->x_clobber_return_insn = after;
-
-      emit_label (return_label);
-    }
+    emit_label (return_label);
 
   /* C++ uses this.  */
   if (end_bindings)
============================================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]