diff mbox

PowerPC shrink-wrap support 2 of 3

Message ID 20110917071837.GV10321@bubble.grove.modra.org
State New
Headers show

Commit Message

Alan Modra Sept. 17, 2011, 7:18 a.m. UTC
This patch corrects some cases where a return jump jump_label wrongly
uses ret_rtx with a simple_return, thus triggering the assert in
mark_jump_label_1.  PowerPC doesn't need this patch with the final
version of my shrink wrap support, but at one stage I was using

(define_expand "return"
  [(simple_return)]
  "direct_return ()")

(define_insn "simple_return"
  [(simple_return)]
  ""
  "{br|blr}"
  [(set_attr "type" "jmpreg")])

in rs6000.md, similar to mips.md.  So gen_return() would create an
instruction using simple_return, and the code patched here would put
ret_rtx into JUMP_LABEL.

	* rtl.h (set_return_jump_label): Declare.
	* function.c (set_return_jump_label): New function, extracted..
	(thread_prologue_and_epilogue_insns): ..from here.  Use it in
	another instance to set return jump_label.
	* cfgrtl.c (force_nonfallthru_and_redirect): Use set_return_jump_label.
	* reorg.c (find_end_label): Likewise.
diff mbox

Patch

diff -urp -x.svn -x'*~' -x'*.orig' gcc-bernd/gcc/rtl.h gcc-current/gcc/rtl.h
--- gcc-bernd/gcc/rtl.h	2011-09-16 11:52:14.000000000 +0930
+++ gcc-current/gcc/rtl.h	2011-09-16 00:24:55.000000000 +0930
@@ -2502,6 +2502,7 @@  extern int sibcall_epilogue_contains (co
 extern void mark_temp_addr_taken (rtx);
 extern void update_temp_slot_address (rtx, rtx);
 extern void maybe_copy_prologue_epilogue_insn (rtx, rtx);
+extern void set_return_jump_label (rtx);
 
 /* In stmt.c */
 extern void expand_null_return (void);
diff -urp -x.svn -x'*~' -x'*.orig' gcc-bernd/gcc/function.c gcc-current/gcc/function.c
--- gcc-bernd/gcc/function.c	2011-09-16 11:53:40.000000000 +0930
+++ gcc-current/gcc/function.c	2011-09-16 00:24:55.000000000 +0930
@@ -5395,6 +5395,20 @@  emit_return_into_block (bool simple_p, b
 }
 #endif
 
+/* Set JUMP_LABEL for a return insn.  */
+
+void
+set_return_jump_label (rtx returnjump)
+{
+  rtx pat = PATTERN (returnjump);
+  if (GET_CODE (pat) == PARALLEL)
+    pat = XVECEXP (pat, 0, 0);
+  if (ANY_RETURN_P (pat))
+    JUMP_LABEL (returnjump) = pat;
+  else
+    JUMP_LABEL (returnjump) = ret_rtx;
+}
+
 /* Generate the prologue and epilogue RTL if the machine supports it.  Thread
    this into place with notes indicating where the prologue ends and where
    the epilogue begins.  Update the basic block information when possible.
@@ -5883,7 +5897,7 @@  thread_prologue_and_epilogue_insns (void
 	  emit_return_into_block (false, last_bb);
 	  epilogue_end = BB_END (last_bb);
 	  if (JUMP_P (epilogue_end))
-	    JUMP_LABEL (epilogue_end) = ret_rtx;
+	    set_return_jump_label (epilogue_end);
 	  single_succ_edge (last_bb)->flags &= ~EDGE_FALLTHRU;
 	  goto epilogue_done;
 	}
@@ -5948,15 +5962,7 @@  thread_prologue_and_epilogue_insns (void
       inserted = true;
 
       if (JUMP_P (returnjump))
-	{
-	  rtx pat = PATTERN (returnjump);
-	  if (GET_CODE (pat) == PARALLEL)
-	    pat = XVECEXP (pat, 0, 0);
-	  if (ANY_RETURN_P (pat))
-	    JUMP_LABEL (returnjump) = pat;
-	  else
-	    JUMP_LABEL (returnjump) = ret_rtx;
-	}
+	set_return_jump_label (returnjump);
     }
   else
 #endif
diff -urp -x.svn -x'*~' -x'*.orig' gcc-bernd/gcc/cfgrtl.c gcc-current/gcc/cfgrtl.c
--- gcc-bernd/gcc/cfgrtl.c	2011-09-16 11:52:15.000000000 +0930
+++ gcc-current/gcc/cfgrtl.c	2011-09-16 09:55:38.000000000 +0930
@@ -1273,7 +1273,7 @@  force_nonfallthru_and_redirect (edge e, 
 	  gcc_unreachable ();
 #endif
 	}
-      JUMP_LABEL (BB_END (jump_block)) = jump_label;
+      set_return_jump_label (BB_END (jump_block));
     }
   else
     {
diff -urp -x.svn -x'*~' -x'*.orig' gcc-bernd/gcc/reorg.c gcc-current/gcc/reorg.c
--- gcc-bernd/gcc/reorg.c	2011-09-16 11:52:12.000000000 +0930
+++ gcc-current/gcc/reorg.c	2011-09-16 00:07:46.000000000 +0930
@@ -467,7 +467,7 @@  find_end_label (rtx kind)
 	      /* The return we make may have delay slots too.  */
 	      rtx insn = gen_return ();
 	      insn = emit_jump_insn (insn);
-	      JUMP_LABEL (insn) = ret_rtx;
+	      set_return_jump_label (insn);
 	      emit_barrier ();
 	      if (num_delay_slots (insn) > 0)
 		obstack_ptr_grow (&unfilled_slots_obstack, insn);