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: make_reorder_chain_1: taken and fallthru edges can be the same


The enclosed patch appears to correct a segmentation fault in
make_reorder_chain_1.

The circumstances were as follows.  A basic block with one successor
ended with a jump with a probability that which indicated that the
taken edge would be more probable.  However, with the current code
only e_fall gets set when there is just one successor and the edge
has EDGE_FALLTHRU set.  This causes a segmentation fault in the
`next' assignment.

I concluded that the taken and fallthru edges should be the same
in this case.  However, possibly, there should always be at least
two edges and the problem is elsewhere.

This occured trying to bootstrap gcc with "-fPIC -O3" under hpux
10.20.  The patch is not tested.  However, I wanted to submit it
for comment.

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

2000-12-29  John David Anglin  <dave@hiauly.hia.nrc.ca>

	* bb-reorder.c (make_reorder_chain_1): Taken and fallthru edges may
	be the same edge.

--- bb-reorder.c.orig	Tue Dec  5 03:00:32 2000
+++ bb-reorder.c	Fri Dec 29 18:34:28 2000
@@ -397,14 +397,17 @@
 
       /* Find the normal taken edge and the normal fallthru edge.
          Note that there may in fact be other edges due to
-	 asynchronous_exceptions.  */
+	 asynchronous_exceptions and the taken edge may be the
+	 same as the normal fallthru edge.  */
 
       e_taken = e_fall = NULL;
       for (e = bb->succ; e ; e = e->succ_next)
-	if (e->flags & EDGE_FALLTHRU)
-	  e_fall = e;
-	else if (! (e->flags & EDGE_EH))
-	  e_taken = e;
+	{
+	  if (e->flags & EDGE_FALLTHRU)
+	    e_fall = e;
+	  if (! (e->flags & EDGE_EH))
+	    e_taken = e;
+	}
 
       next = (taken ? e_taken : e_fall)->dest;
     }

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