tree-cfg.c (verify_expr, [...]): Verify invariant, constant and side_effects of the...
authorDaniel Berlin <dberlin@dberlin.org>
Wed, 25 May 2005 21:36:24 +0000 (21:36 +0000)
committerJeff Law <law@gcc.gnu.org>
Wed, 25 May 2005 21:36:24 +0000 (15:36 -0600)
        * tree-cfg.c (verify_expr, case ADDR_EXPR): Verify invariant,
        constant and side_effects of the ADDR_EXPR are consistent.

        * tree-nested.c (convert_local_reference): Set CURRENT_FUNCTION_DECL
        appropriately around calls to recompute_tree_invarant_for_addr_expr.

Co-Authored-By: Jeff Law <law@redhat.com>
From-SVN: r100168

gcc/ChangeLog
gcc/tree-cfg.c
gcc/tree-nested.c

index 02d90470820d78c79856ef2d0c01613295aaba46..a24922b4430aac76f57765cae2152e2a0b03fc8b 100644 (file)
@@ -1,3 +1,12 @@
+2005-05-25  Daniel Berlin  <dberlin@dberlin.org>
+           Jeff Law  <law@redhat.com>
+
+       * tree-cfg.c (verify_expr, case ADDR_EXPR): Verify invariant,
+       constant and side_effects of the ADDR_EXPR are consistent.
+
+       * tree-nested.c (convert_local_reference): Set CURRENT_FUNCTION_DECL
+       appropriately around calls to recompute_tree_invarant_for_addr_expr.
+
 2005-05-25  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * config/s390/s390.c (GP_ARG_NUM_REG, FP_ARG_NUM_REG): New defines.
index 22215a391277561f6aa65c060f64b620c88f928e..a219d8b760f097e3d0a4df55c983a9652d4dc003 100644 (file)
@@ -3429,32 +3429,67 @@ verify_expr (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
       break;
 
     case ADDR_EXPR:
-      /* ??? tree-ssa-alias.c may have overlooked dead PHI nodes, missing
-        dead PHIs that take the address of something.  But if the PHI
-        result is dead, the fact that it takes the address of anything
-        is irrelevant.  Because we can not tell from here if a PHI result
-        is dead, we just skip this check for PHIs altogether.  This means
-        we may be missing "valid" checks, but what can you do?
-        This was PR19217.  */
-      if (in_phi)
-       break;
+      {
+       bool old_invariant;
+       bool old_constant;
+       bool old_side_effects;
+       bool new_invariant;
+       bool new_constant;
+       bool new_side_effects;
+
+        /* ??? tree-ssa-alias.c may have overlooked dead PHI nodes, missing
+          dead PHIs that take the address of something.  But if the PHI
+          result is dead, the fact that it takes the address of anything
+          is irrelevant.  Because we can not tell from here if a PHI result
+          is dead, we just skip this check for PHIs altogether.  This means
+          we may be missing "valid" checks, but what can you do?
+          This was PR19217.  */
+        if (in_phi)
+         break;
 
-      /* 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);
-          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;
+       old_invariant = TREE_INVARIANT (t);
+       old_constant = TREE_CONSTANT (t);
+       old_side_effects = TREE_SIDE_EFFECTS (t);
+
+       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);
+            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:
       x = COND_EXPR_COND (t);
index 124bbf98cfb2ce78e446e5fc2b1596f31f050680..2f9985dcfac0227ee584127e9b12251a056f0456 100644 (file)
@@ -871,9 +871,14 @@ convert_nonlocal_reference (tree *tp, int *walk_subtrees, void *data)
 
        if (wi->changed)
          {
+           tree save_context;
+
            /* If we changed anything, then TREE_INVARIANT is be wrong,
               since we're no longer directly referencing a decl.  */
+           save_context = current_function_decl;
+           current_function_decl = info->context;
            recompute_tree_invarant_for_addr_expr (t);
+           current_function_decl = save_context;
 
            /* If the callback converted the address argument in a context
               where we only accept variables (and min_invariant, presumably),
@@ -996,10 +1001,15 @@ convert_local_reference (tree *tp, int *walk_subtrees, void *data)
        /* If we converted anything ... */
        if (wi->changed)
          {
+           tree save_context;
+
            /* Then the frame decl is now addressable.  */
            TREE_ADDRESSABLE (info->frame_decl) = 1;
            
+           save_context = current_function_decl;
+           current_function_decl = info->context;
            recompute_tree_invarant_for_addr_expr (t);
+           current_function_decl = save_context;
 
            /* If we are in a context where we only accept values, then
               compute the address into a temporary.  */