re PR middle-end/39827 (ICE (segfault) when compiling gcc/varasm.c (in notice_global_...
authorRichard Guenther <rguenther@suse.de>
Tue, 21 Apr 2009 09:58:38 +0000 (09:58 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 21 Apr 2009 09:58:38 +0000 (09:58 +0000)
2009-04-21  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/39827
* tree-ssa-phiprop.c (propagate_with_phi): Check SSA_NAME
is in range.
(tree_ssa_phiprop): Pass the correct array size.

From-SVN: r146515

gcc/ChangeLog
gcc/tree-ssa-phiprop.c

index 930937f2972d3f996eca9a1fdbaeb3b890eb0e93..c1261665585c45dac323c380ba2f0f21a7de93cb 100644 (file)
@@ -1,3 +1,10 @@
+2009-04-21  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/39827
+       * tree-ssa-phiprop.c (propagate_with_phi): Check SSA_NAME
+       is in range.
+       (tree_ssa_phiprop): Pass the correct array size.
+
 2009-04-21  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/alpha/alpha.md (tune): Add cast to enum attr_tune.
index f608f1d056ec94df220fcdd2ae4ff11afd064521..4e6e09c477df6d684c041d656be32fce51efaee1 100644 (file)
@@ -253,6 +253,7 @@ propagate_with_phi (basic_block bb, gimple phi, struct phiprop_d *phivn,
           /* Avoid to have to decay *&a to a[0] later.  */
           || !is_gimple_reg_type (TREE_TYPE (TREE_OPERAND (arg, 0))))
          && !(TREE_CODE (arg) == SSA_NAME
+              && SSA_NAME_VERSION (arg) < n
               && phivn[SSA_NAME_VERSION (arg)].value != NULL_TREE
               && phivn_valid_p (phivn, arg, bb)))
        return false;
@@ -336,18 +337,19 @@ tree_ssa_phiprop (void)
   basic_block bb;
   gimple_stmt_iterator gsi;
   unsigned i;
+  size_t n;
 
   calculate_dominance_info (CDI_DOMINATORS);
 
-  phivn = XCNEWVEC (struct phiprop_d, num_ssa_names);
+  n = num_ssa_names;
+  phivn = XCNEWVEC (struct phiprop_d, n);
 
   /* Walk the dominator tree in preorder.  */
   bbs = get_all_dominated_blocks (CDI_DOMINATORS,
                                  single_succ (ENTRY_BLOCK_PTR));
   for (i = 0; VEC_iterate (basic_block, bbs, i, bb); ++i)
     for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-      did_something |= propagate_with_phi (bb, gsi_stmt (gsi),
-                                          phivn, num_ssa_names);
+      did_something |= propagate_with_phi (bb, gsi_stmt (gsi), phivn, n);
 
   if (did_something)
     gsi_commit_edge_inserts ();