Patchwork [PR43920,5/9] Cross-jumping - Add missing use of return register.

login
register
mail settings
Submitter Tom de Vries
Date March 31, 2011, 6:40 p.m.
Message ID <4D94CA95.4080309@codesourcery.com>
Download mbox | patch
Permalink /patch/89110/
State New
Headers show

Comments

Tom de Vries - March 31, 2011, 6:40 p.m.
Inserts use of return register in epilogue threading, to keep
representation consistent, and prevent mismatch in crossjump matching.

Thanks,
- Tom
Jeff Law - March 31, 2011, 6:45 p.m.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 03/31/11 12:40, Tom de Vries wrote:
> Inserts use of return register in epilogue threading, to keep
> representation consistent, and prevent mismatch in crossjump matching.
OK.
Jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNlMu/AAoJEBRtltQi2kC7lTwIAJeKk9DQjxzDqI4wk2skl6x3
a5AJ5QfxCG35V0djxabJgapTKuxg7FzLPHcXyHCA44/eOiHTOZwlP6wRDlkQtVpA
NszbRIkFyRXMI6r5h9G7uITKes1xUYFMvBFRVFjTyDZYoNZoxGtIPYw4+6CVGXg2
7jD1LWUwaJRwQVqqdC3JMu9GwsxPK81Fsl2zjCRvYcwXhCB2YjzjQiA5ZGIGmd5G
DQ5RPavum8QsP8pHPBo+oWB/1Lc1lKbE4Gbal4IPWVR+GuyY3JuTIOcfTljhbkWe
kOj0R++Yt/3UUcwT8i8ywRxIlsAYQgR6AZrbLaqQ3u85BgEjjotrCur7x76z7TA=
=RU+t
-----END PGP SIGNATURE-----

Patch

Index: gcc/function.c
===================================================================
--- gcc/function.c	(revision 170556)
+++ gcc/function.c	(working copy)
@@ -5241,6 +5241,19 @@  prologue_epilogue_contains (const_rtx in
   return 0;
 }
 
+/* Insert use of return register before the end of BB.  */
+
+static void
+emit_use_return_register_into_block (basic_block bb)
+{
+  rtx seq;
+  start_sequence ();
+  use_return_register ();
+  seq = get_insns ();
+  end_sequence ();
+  emit_insn_before (seq, BB_END (bb));
+}
+
 #ifdef HAVE_return
 /* Insert gen_return at the end of block BB.  This also means updating
    block_for_insn appropriately.  */
@@ -5395,6 +5408,15 @@  thread_prologue_and_epilogue_insns (void
 		 with a simple return instruction.  */
 	      if (simplejump_p (jump))
 		{
+		  /* The use of the return register might be present in the exit
+		     fallthru block.  Either:
+		     - removing the use is safe, and we should remove the use in
+		       the exit fallthru block, or
+		     - removing the use is not safe, and we should add it here.
+		     For now, we conservatively choose the latter.  Either of the
+		     2 helps in crossjumping.  */
+		  emit_use_return_register_into_block (bb);
+
 		  emit_return_into_block (bb);
 		  delete_insn (jump);
 		}
@@ -5409,6 +5431,9 @@  thread_prologue_and_epilogue_insns (void
 		      continue;
 		    }
 
+                  /* See comment in simple_jump_p case above.  */
+		  emit_use_return_register_into_block (bb);
+
 		  /* If this block has only one successor, it both jumps
 		     and falls through to the fallthru block, so we can't
 		     delete the edge.  */