aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/testsuite/g++.dg/opt/pr23714.C16
-rw-r--r--gcc/tree-cfg.c33
-rw-r--r--gcc/tree-flow.h1
-rw-r--r--gcc/tree-optimize.c1
5 files changed, 59 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 930e25b..a1ad324 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2005-10-05 Richard Henderson <rth@redhat.com>
+
+ PR 23714
+ * tree-cfg.c (mark_array_ref_addressable_1): New.
+ (mark_array_ref_addressable): New.
+ * tree-flow.h (mark_array_ref_addressable): Declare.
+ * tree-optimize.c (execute_cleanup_cfg_post_optimizing): Use it.
+
2005-10-05 Andrew Pinski <pinskia@physics.uc.edu>
PR middle-end/20606
diff --git a/gcc/testsuite/g++.dg/opt/pr23714.C b/gcc/testsuite/g++.dg/opt/pr23714.C
new file mode 100644
index 0000000..bf1b4ac
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr23714.C
@@ -0,0 +1,16 @@
+// { dg-do compile }
+// { dg-options "-O2 -fnon-call-exceptions" }
+
+void run (void) {
+ float stack[1];
+ float *sp = stack;
+ try
+ {
+ float value2 = ((float) *(--sp));
+ float value1 = ((float) *(--sp));
+ *(sp++) = (value1 - value2);
+ }
+ catch (int *ex)
+ {
+ }
+}
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index d5d466e..74e6063 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -421,6 +421,39 @@ fold_cond_expr_cond (void)
}
}
+/* Mark the array of any remaining ARRAY_REFs as addressable. */
+
+static tree
+mark_array_ref_addressable_1 (tree *tp, int *walk_subtrees,
+ void *data ATTRIBUTE_UNUSED)
+{
+ tree t = *tp;
+
+ if (DECL_P (t) || TYPE_P (t))
+ *walk_subtrees = 0;
+ else if (TREE_CODE (t) == ARRAY_REF)
+ {
+ tree base = get_base_address (TREE_OPERAND (t, 0));
+ if (base && DECL_P (base))
+ TREE_ADDRESSABLE (base) = 1;
+ }
+
+ return NULL_TREE;
+}
+
+void
+mark_array_ref_addressable (void)
+{
+ basic_block bb;
+ block_stmt_iterator i;
+
+ FOR_EACH_BB (bb)
+ {
+ for (i = bsi_start (bb); !bsi_end_p(i); bsi_next(&i))
+ walk_tree (bsi_stmt_ptr (i), mark_array_ref_addressable_1, NULL, NULL);
+ }
+}
+
/* Join all the blocks in the flowgraph. */
static void
diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h
index ac34f66..f00f09e 100644
--- a/gcc/tree-flow.h
+++ b/gcc/tree-flow.h
@@ -556,6 +556,7 @@ extern tree gimplify_build3 (block_stmt_iterator *, enum tree_code,
tree, tree, tree, tree);
extern void init_empty_tree_cfg (void);
extern void fold_cond_expr_cond (void);
+extern void mark_array_ref_addressable (void);
extern void replace_uses_by (tree, tree);
extern void start_recording_case_labels (void);
extern void end_recording_case_labels (void);
diff --git a/gcc/tree-optimize.c b/gcc/tree-optimize.c
index 0678889..64b11d2 100644
--- a/gcc/tree-optimize.c
+++ b/gcc/tree-optimize.c
@@ -133,6 +133,7 @@ static void
execute_cleanup_cfg_post_optimizing (void)
{
fold_cond_expr_cond ();
+ mark_array_ref_addressable ();
cleanup_tree_cfg ();
cleanup_dead_labels ();
group_case_labels ();