This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR39827


The previous patch to phiprop contains an error - we have to remember
the original allocation size as num_ssa_names may change.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2009-04-21  Richard Guenther  <rguenther@suse.de>

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

Index: gcc/tree-ssa-phiprop.c
===================================================================
*** gcc/tree-ssa-phiprop.c	(revision 146426)
--- gcc/tree-ssa-phiprop.c	(working copy)
*************** propagate_with_phi (basic_block bb, gimp
*** 253,258 ****
--- 253,259 ----
  	   /* 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;
*************** tree_ssa_phiprop (void)
*** 336,353 ****
    basic_block bb;
    gimple_stmt_iterator gsi;
    unsigned i;
  
    calculate_dominance_info (CDI_DOMINATORS);
  
!   phivn = XCNEWVEC (struct phiprop_d, num_ssa_names);
  
    /* 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);
  
    if (did_something)
      gsi_commit_edge_inserts ();
--- 337,355 ----
    basic_block bb;
    gimple_stmt_iterator gsi;
    unsigned i;
+   size_t n;
  
    calculate_dominance_info (CDI_DOMINATORS);
  
!   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, n);
  
    if (did_something)
      gsi_commit_edge_inserts ();


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]