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]
Other format: [Raw text]

[patch] tree-phinodes.c: Make sure an edge exist before adding aPHI argument.


Hi,

Attached is a patch to tell add_phi_arg to reject a request to add a
PHI argument if its associated edge does not exist.

One case that's trapped by the new gcc_assert is thread_block in
tree-ssa-threadupdate.c, but that's fixed by

  http://gcc.gnu.org/ml/gcc-patches/2004-10/msg02666.html

I briefly looked over uses of add_phi_args.  I didn't find any place
where PHI arguments are added before an edge.  According to Steven
Bosscher, thread_block should be the only place that does that as far
as he knows.

Tested on i686-pc-linux-gnu on top of

  http://gcc.gnu.org/ml/gcc-patches/2004-10/msg02666.html

OK to apply?

Kazu Hirata

2004-10-30  Kazu Hirata  <kazu@cs.umass.edu>

	* tree-phinodes.c (add_phi_arg): Add an assertion that the
	edge already exists.

Index: tree-phinodes.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-phinodes.c,v
retrieving revision 2.15
diff -u -d -p -r2.15 tree-phinodes.c
--- tree-phinodes.c	30 Oct 2004 00:13:52 -0000	2.15
+++ tree-phinodes.c	30 Oct 2004 02:48:19 -0000
@@ -295,12 +295,14 @@ create_phi_node (tree var, basic_block b
 void
 add_phi_arg (tree *phi, tree def, edge e)
 {
+  basic_block bb = e->dest;
   int i = PHI_NUM_ARGS (*phi);
 
+  gcc_assert (bb == bb_for_stmt (*phi));
+
   if (i >= PHI_ARG_CAPACITY (*phi))
     {
       tree old_phi = *phi;
-      basic_block bb;
 
       /* Resize the phi.  Unfortunately, this will relocate it.  */
       resize_phi_node (phi, ideal_phi_node_len (i + 4));
@@ -311,13 +313,6 @@ add_phi_arg (tree *phi, tree def, edge e
       /* The result of the phi is defined by this phi node.  */
       SSA_NAME_DEF_STMT (PHI_RESULT (*phi)) = *phi;
 
-      /* Extract the basic block for the PHI from the PHI's annotation
-	 rather than the edge.  This works better as the edge's
-	 destination may not currently be the block with the PHI node
-	 if we are in the process of threading the edge to a new
-	 destination.  */
-      bb = bb_for_stmt (*phi);
-
       release_phi_node (old_phi);
 
       /* Update the list head if replacing the first listed phi.  */


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