OSDN Git Service

PR 23714
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 16 Oct 2005 00:07:17 +0000 (00:07 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 16 Oct 2005 00:07:17 +0000 (00:07 +0000)
        * builtins.c (expand_builtin_trap): Export.
        * expr.h (expand_builtin_trap): Declare.
        * expr.c (expand_assignment): Emit a trap for integral offsets
        from registers that weren't reduced to bitpos.

        * tree-cfg.c (mark_array_ref_addressable_1): Remove.
        (mark_array_ref_addressable): Remove.
        * tree-flow.h (mark_array_ref_addressable): Remove.
        * tree-optimize.c (execute_cleanup_cfg_post_optimizing): Don't call it.

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

gcc/ChangeLog
gcc/builtins.c
gcc/expr.c
gcc/expr.h
gcc/tree-cfg.c
gcc/tree-flow.h
gcc/tree-optimize.c

index b4ef9c9..23ccab6 100644 (file)
@@ -1,3 +1,16 @@
+2005-10-15  Richard Henderson  <rth@redhat.com>
+
+       PR 23714
+       * builtins.c (expand_builtin_trap): Export.
+       * expr.h (expand_builtin_trap): Declare.
+       * expr.c (expand_assignment): Emit a trap for integral offsets 
+       from registers that weren't reduced to bitpos.
+
+       * tree-cfg.c (mark_array_ref_addressable_1): Remove.
+       (mark_array_ref_addressable): Remove.
+       * tree-flow.h (mark_array_ref_addressable): Remove.
+       * tree-optimize.c (execute_cleanup_cfg_post_optimizing): Don't call it.
+
 2005-10-15  James E Wilson  <wilson@specifix.com>
 
        PR target/24232
index a4c3bfc..2136900 100644 (file)
@@ -4751,7 +4751,7 @@ expand_builtin_expect_jump (tree exp, rtx if_false_label, rtx if_true_label)
   return ret;
 }
 
-static void
+void
 expand_builtin_trap (void)
 {
 #ifdef HAVE_trap
index 00419c8..9743c2a 100644 (file)
@@ -3924,10 +3924,18 @@ expand_assignment (tree to, tree from)
 
       if (offset != 0)
        {
-         rtx offset_rtx = expand_expr (offset, NULL_RTX, VOIDmode, EXPAND_SUM);
+         rtx offset_rtx;
 
-         gcc_assert (MEM_P (to_rtx));
+         if (!MEM_P (to_rtx))
+           {
+             /* We can get constant negative offsets into arrays with broken
+                user code.  Translate this to a trap instead of ICEing.  */
+             gcc_assert (TREE_CODE (offset) == INTEGER_CST);
+             expand_builtin_trap ();
+             to_rtx = gen_rtx_MEM (BLKmode, const0_rtx);
+           }
 
+         offset_rtx = expand_expr (offset, NULL_RTX, VOIDmode, EXPAND_SUM);
 #ifdef POINTERS_EXTEND_UNSIGNED
          if (GET_MODE (offset_rtx) != Pmode)
            offset_rtx = convert_to_mode (Pmode, offset_rtx, 0);
index 224e285..ef42387 100644 (file)
@@ -341,6 +341,7 @@ extern rtx default_expand_builtin (tree, rtx, rtx, enum machine_mode, int);
 extern void expand_builtin_setjmp_setup (rtx, rtx);
 extern void expand_builtin_setjmp_receiver (rtx);
 extern rtx expand_builtin_saveregs (void);
+extern void expand_builtin_trap (void);
 \f
 /* Functions from expr.c:  */
 
index 2a0d75a..90c2730 100644 (file)
@@ -421,39 +421,6 @@ 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 135c475..135a4e8 100644 (file)
@@ -556,7 +556,6 @@ 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 64b11d2..0678889 100644 (file)
@@ -133,7 +133,6 @@ 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 ();