Patchwork resent [PATCH] Fix PR50496

login
register
mail settings
Submitter Markus Trippelsdorf
Date Oct. 14, 2011, 8:51 a.m.
Message ID <20111014085134.GA1662@x4.trippels.de>
Download mbox | patch
Permalink /patch/119734/
State New
Headers show

Comments

Markus Trippelsdorf - Oct. 14, 2011, 8:51 a.m.
This patch, originally from Chung-Lin Tang, fixes PR50496.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50496

Can someone please review and commit it? 
Thanks.

Bootstrapped and tested on x86_64-pc-linux-gnu.

	PR middle-end/50496
	* cfgrtl.c (try_redirect_by_replacing_jump): Treat EXIT_BLOCK_PTR case
	separately before call to redirect_jump(). Add assertion.
	(patch_jump_insn): Same.
Eric Botcazou - Oct. 14, 2011, 11:10 a.m.
> This patch, originally from Chung-Lin Tang, fixes PR50496.
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50496
>
> Can someone please review and commit it?

A proper patch submission should include a description of the problem and a 
rationale for the proposed fix (unless it is trivial).

Patch

diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index b3f045b..57f561f 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -846,11 +846,10 @@  try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout)
       if (dump_file)
 	fprintf (dump_file, "Redirecting jump %i from %i to %i.\n",
 		 INSN_UID (insn), e->dest->index, target->index);
-      if (!redirect_jump (insn, block_label (target), 0))
-	{
-	  gcc_assert (target == EXIT_BLOCK_PTR);
-	  return NULL;
-	}
+      if (target == EXIT_BLOCK_PTR)
+	return NULL;
+      if (! redirect_jump (insn, block_label (target), 0))
+	gcc_unreachable ();
     }
 
   /* Cannot do anything for target exit block.  */
@@ -1030,11 +1029,10 @@  patch_jump_insn (rtx insn, rtx old_label, basic_block new_bb)
 	  /* If the substitution doesn't succeed, die.  This can happen
 	     if the back end emitted unrecognizable instructions or if
 	     target is exit block on some arches.  */
-	  if (!redirect_jump (insn, block_label (new_bb), 0))
-	    {
-	      gcc_assert (new_bb == EXIT_BLOCK_PTR);
-	      return false;
-	    }
+	  if (new_bb == EXIT_BLOCK_PTR)
+	    return false;
+	  if (! redirect_jump (insn, block_label (new_bb), 0))
+	    gcc_unreachable ();
 	}
     }
   return true;