[PATCH]: PR 10024

John David Anglin dave@hiauly1.hia.nrc.ca
Thu Mar 13 23:37:00 GMT 2003


Here is a possible fix for PR 10024.  The testcase provided with PR 10024
ICE's because we have a conditional jump with e_taken == 0.  There
appears to be an implicit assumption in fixup_reorder_chain that the
loop to set e_fall and e_taken will always set both e_fall and e_taken
when we have a conditional jump.  If that's the case, then this isn't
the right fix.  However, the proposed fix corrects the ICE, and I have
done complete bootstrap on hppa2.0w-hp-hpux11.00 and hppa64-hp-hpux11.00
with no regressions.

Ok for main and 3.3?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2003-03-13  John David Anglin  <dave.angln@nrc-cnrc.gc.ca>

	PR 10024
	* cfglayout.c (fixup_reorder_chain): Don't try to invert a conditional
	jump if we didn't find an edge for a taken jump.

Index: cfglayout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfglayout.c,v
retrieving revision 1.28
diff -u -3 -p -r1.28 cfglayout.c
--- cfglayout.c	10 Mar 2003 12:59:12 -0000	1.28
+++ cfglayout.c	13 Mar 2003 21:58:19 -0000
@@ -465,35 +465,38 @@ fixup_reorder_chain ()
 		      && e_fall->dest == EXIT_BLOCK_PTR))
 		continue;
 
-	      /* There is one special case: if *neither* block is next,
-		 such as happens at the very end of a function, then we'll
-		 need to add a new unconditional jump.  Choose the taken
-		 edge based on known or assumed probability.  */
-	      if (RBI (bb)->next != e_taken->dest)
+	      if (e_taken)
 		{
-		  rtx note = find_reg_note (bb_end_insn, REG_BR_PROB, 0);
+		  /* There is one special case: if *neither* block is next,
+		     such as happens at the very end of a function, then we'll
+		     need to add a new unconditional jump.  Choose the taken
+		     edge based on known or assumed probability.  */
+		  if (RBI (bb)->next != e_taken->dest)
+		    {
+		      rtx note = find_reg_note (bb_end_insn, REG_BR_PROB, 0);
+
+		      if (note
+			  && INTVAL (XEXP (note, 0)) < REG_BR_PROB_BASE / 2
+			  && invert_jump (bb_end_insn,
+					  label_for_bb (e_fall->dest), 0))
+			{
+			  e_fall->flags &= ~EDGE_FALLTHRU;
+			  e_taken->flags |= EDGE_FALLTHRU;
+			  update_br_prob_note (bb);
+			  e = e_fall, e_fall = e_taken, e_taken = e;
+			}
+		    }
 
-		  if (note
-		      && INTVAL (XEXP (note, 0)) < REG_BR_PROB_BASE / 2
-		      && invert_jump (bb_end_insn,
-				      label_for_bb (e_fall->dest), 0))
+		  /* Otherwise we can try to invert the jump.  This will
+		     basically never fail, however, keep up the pretense.  */
+		  else if (invert_jump (bb_end_insn,
+					label_for_bb (e_fall->dest), 0))
 		    {
 		      e_fall->flags &= ~EDGE_FALLTHRU;
 		      e_taken->flags |= EDGE_FALLTHRU;
 		      update_br_prob_note (bb);
-		      e = e_fall, e_fall = e_taken, e_taken = e;
+		      continue;
 		    }
-		}
-
-	      /* Otherwise we can try to invert the jump.  This will
-		 basically never fail, however, keep up the pretense.  */
-	      else if (invert_jump (bb_end_insn,
-				    label_for_bb (e_fall->dest), 0))
-		{
-		  e_fall->flags &= ~EDGE_FALLTHRU;
-		  e_taken->flags |= EDGE_FALLTHRU;
-		  update_br_prob_note (bb);
-		  continue;
 		}
 	    }
 	  else if (returnjump_p (bb_end_insn))



More information about the Gcc-patches mailing list