aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/tree-cfg.c85
-rw-r--r--gcc/tree-nested.c10
3 files changed, 79 insertions, 25 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 02d9047..a24922b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 22215a3..a219d8b 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -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);
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index 124bbf9..2f9985d 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -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. */