]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/23714 (ICE in expand_assignment)
authorRichard Henderson <rth@redhat.com>
Sun, 16 Oct 2005 00:07:17 +0000 (17:07 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Sun, 16 Oct 2005 00:07:17 +0000 (17:07 -0700)
        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.

From-SVN: r105449

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

index b4ef9c95b880d031a1518174bc1141e86a2fda52..23ccab683a2d4f27af893785b56c980fcdd43f8d 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 a4c3bfc1bc6f5122508d65d656114df1c2388383..2136900f0831bf7e28f64c9cec9be1670545bd1a 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 00419c8ba0c33c675df18cf780ed7ff000a0ff84..9743c2a608222ebb5aecfc27e6f10a74066b3c8f 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 224e2857f2b9ad601bd2a64501b8ae96b09b80c9..ef4238787b6795ca95dcf3904dfb1f8565af0df2 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 2a0d75a29706cd250a5fa1be14b8f463045802ef..90c27307b3e1c4c17ef333b69769efe460b205ef 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 135c475f62babee9f55b2d154724df4caa724f21..135a4e823604b91e13fed77fb8e7daf829a246ba 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 64b11d29927a2c274ad942cca656d27ff6bca3be..0678889c7722cbf8a9bb6a6046b65fd78e48cf32 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 ();