Still missing some addr_expr invariant recomputations

Daniel Berlin dberlin@dberlin.org
Mon Sep 13 16:53:00 GMT 2004


As evidenced by the attached patch.

If you don't feel like tracking this down, let me know, and i'll just file 
a bug.

(I'm going to bitmask the recompute_addr_expr_* function and just use that
in verify_*, as you suggested, so that we don't have side effects from the 
checking.)

../../../libjava/prims.cc: In function `java::lang::Object* 
_Jv_NewPrimArray(java::lang::Class*, jint)':
../../../libjava/prims.cc:533: error: invariant not recomputed when 
ADDR_EXPR changed
&0B->dataD.3692[0];

../../../libjava/prims.cc:533: error: invariant not recomputed when 
ADDR_EXPR changed
&0B->dataD.3711[0];

../../../libjava/prims.cc:533: error: invariant not recomputed when 
ADDR_EXPR changed
&0B->dataD.3730[0];

../../../libjava/prims.cc:533: error: invariant not recomputed when 
ADDR_EXPR changed
&0B->dataD.3749[0];

../../../libjava/prims.cc:533: error: invariant not recomputed when 
ADDR_EXPR changed
&0B->dataD.3673[0];

../../../libjava/prims.cc:533: error: invariant not recomputed when 
ADDR_EXPR changed
&0B->dataD.3654[0];

../../../libjava/prims.cc:533: error: invariant not recomputed when 
ADDR_EXPR changed
&0B->dataD.3768[0];

../../../libjava/prims.cc:533: error: invariant not recomputed when 
ADDR_EXPR changed
&0B->dataD.3787[0];

../../../libjava/prims.cc:533: error: invariant not recomputed when 
ADDR_EXPR changed
&0B->dataD.8855[0];

-------------- next part --------------
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.50
diff -u -p -r2.50 tree-cfg.c
--- tree-cfg.c	11 Sep 2004 20:42:03 -0000	2.50
+++ tree-cfg.c	13 Sep 2004 15:43:58 -0000
@@ -3108,23 +3108,50 @@ verify_expr (tree *tp, int *walk_subtree
       break;
 
     case ADDR_EXPR:
-      /* Skip any references (they will be checked when we recurse down the
-	 tree) and ensure that any variable used as a prefix is marked
-	 addressable.  */
-      for (x = TREE_OPERAND (t, 0);
-	   (handled_component_p (x)
-	    || TREE_CODE (x) == REALPART_EXPR
-	    || TREE_CODE (x) == IMAGPART_EXPR);
-	   x = TREE_OPERAND (x, 0))
-	;
-
-      if (TREE_CODE (x) != VAR_DECL && TREE_CODE (x) != PARM_DECL)
-	return NULL;
-      if (!TREE_ADDRESSABLE (x))
-	{
-	  error ("address taken, but ADDRESSABLE bit not set");
-	  return x;
-	}
+      {
+	bool old_invariant = TREE_INVARIANT (t);
+	bool old_constant = TREE_CONSTANT (t);
+	bool old_side_effects = TREE_SIDE_EFFECTS (t);
+	bool new_invariant;
+	bool new_constant;
+	bool new_side_effects;
+	recompute_tree_invarant_for_addr_expr (t);
+	new_invariant = TREE_INVARIANT (t);
+	new_side_effects = TREE_SIDE_EFFECTS (t);
+	new_constant = TREE_CONSTANT (t);
+	if (old_invariant != new_invariant)
+	  {
+	    error ("invariant not recomputed when ADDR_EXPR changed");
+	    return t;
+	  }
+        if (old_constant != new_constant)
+	  {
+	    error ("constant not recomputed when ADDR_EXPR changed");
+	    return t;
+	  }
+	if (old_side_effects != new_side_effects)
+	  {
+	    error ("side effects not recomputed when ADDR_EXPR changed");
+	    return t;
+	  }
+	/* Skip any references (they will be checked when we recurse down the
+	   tree) and ensure that any variable used as a prefix is marked
+	   addressable.  */
+	for (x = TREE_OPERAND (t, 0);
+	     (handled_component_p (x)
+	      || TREE_CODE (x) == REALPART_EXPR
+	      || TREE_CODE (x) == IMAGPART_EXPR);
+	     x = TREE_OPERAND (x, 0))
+	  ;
+	
+	if (TREE_CODE (x) != VAR_DECL && TREE_CODE (x) != PARM_DECL)
+	  return NULL;
+	if (!TREE_ADDRESSABLE (x))
+	  {
+	    error ("address taken, but ADDRESSABLE bit not set");
+	    return x;
+	  }
+      }
       break;
 
     case COND_EXPR:


More information about the Gcc mailing list