PR 23714
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 6 Oct 2005 00:02:57 +0000 (00:02 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 6 Oct 2005 00:02:57 +0000 (00:02 +0000)
        * 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105022 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/g++.dg/opt/pr23714.C [new file with mode: 0644]
gcc/tree-cfg.c
gcc/tree-flow.h
gcc/tree-optimize.c

index 930e25b..a1ad324 100644 (file)
@@ -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 (file)
index 0000000..bf1b4ac
--- /dev/null
@@ -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)
+  {
+  }
+}
index d5d466e..74e6063 100644 (file)
@@ -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
index ac34f66..f00f09e 100644 (file)
@@ -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);
index 0678889..64b11d2 100644 (file)
@@ -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 ();