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]

FIx memory corruption in uncprop


Hi,
pretty-ipa fails to bootstrap because of buffer overrun in uncprop.
I looked for similar patterns and noticed same mistake in bt-load.c
so fixed it too.

Bootstrapped/regtested i686-linux and comitted.
	* tree-ssa-uncprop.c (associate_equivalences_with_edges): Use
	last_basic_block for size of bb->index indexed array.
	* bt-load.c (compute_defs_uses_and_gen, compute_kill,
	compute_out, link_btr_uses, build_btr_def_use_webs,
	build_btr_def_use_webs, migrate_btr_defs): Likewise.
Index: tree-ssa-uncprop.c
===================================================================
*** tree-ssa-uncprop.c	(revision 145545)
--- tree-ssa-uncprop.c	(working copy)
*************** associate_equivalences_with_edges (void)
*** 177,183 ****
  	      && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (cond))
  	    {
  	      int i, n_labels = gimple_switch_num_labels (stmt);
! 	      tree *info = XCNEWVEC (tree, n_basic_blocks);
  
  	      /* Walk over the case label vector.  Record blocks
  		 which are reached by a single case label which represents
--- 177,183 ----
  	      && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (cond))
  	    {
  	      int i, n_labels = gimple_switch_num_labels (stmt);
! 	      tree *info = XCNEWVEC (tree, last_basic_block);
  
  	      /* Walk over the case label vector.  Record blocks
  		 which are reached by a single case label which represents
Index: bt-load.c
===================================================================
*** bt-load.c	(revision 145545)
--- bt-load.c	(working copy)
*************** compute_defs_uses_and_gen (fibheap_t all
*** 457,464 ****
    btr_def_group all_btr_def_groups = NULL;
    defs_uses_info info;
  
!   sbitmap_vector_zero (bb_gen, n_basic_blocks);
!   for (i = NUM_FIXED_BLOCKS; i < n_basic_blocks; i++)
      {
        basic_block bb = BASIC_BLOCK (i);
        int reg;
--- 457,464 ----
    btr_def_group all_btr_def_groups = NULL;
    defs_uses_info info;
  
!   sbitmap_vector_zero (bb_gen, last_basic_block);
!   for (i = NUM_FIXED_BLOCKS; i < last_basic_block; i++)
      {
        basic_block bb = BASIC_BLOCK (i);
        int reg;
*************** compute_kill (sbitmap *bb_kill, sbitmap 
*** 618,625 ****
  
    /* For each basic block, form the set BB_KILL - the set
       of definitions that the block kills.  */
!   sbitmap_vector_zero (bb_kill, n_basic_blocks);
!   for (i = NUM_FIXED_BLOCKS; i < n_basic_blocks; i++)
      {
        for (regno = first_btr; regno <= last_btr; regno++)
  	if (TEST_HARD_REG_BIT (all_btrs, regno)
--- 618,625 ----
  
    /* For each basic block, form the set BB_KILL - the set
       of definitions that the block kills.  */
!   sbitmap_vector_zero (bb_kill, last_basic_block);
!   for (i = NUM_FIXED_BLOCKS; i < last_basic_block; i++)
      {
        for (regno = first_btr; regno <= last_btr; regno++)
  	if (TEST_HARD_REG_BIT (all_btrs, regno)
*************** compute_out (sbitmap *bb_out, sbitmap *b
*** 642,655 ****
    int changed;
    sbitmap bb_in = sbitmap_alloc (max_uid);
  
!   for (i = NUM_FIXED_BLOCKS; i < n_basic_blocks; i++)
      sbitmap_copy (bb_out[i], bb_gen[i]);
  
    changed = 1;
    while (changed)
      {
        changed = 0;
!       for (i = NUM_FIXED_BLOCKS; i < n_basic_blocks; i++)
  	{
  	  sbitmap_union_of_preds (bb_in, bb_out, i);
  	  changed |= sbitmap_union_of_diff_cg (bb_out[i], bb_gen[i],
--- 642,655 ----
    int changed;
    sbitmap bb_in = sbitmap_alloc (max_uid);
  
!   for (i = NUM_FIXED_BLOCKS; i < last_basic_block; i++)
      sbitmap_copy (bb_out[i], bb_gen[i]);
  
    changed = 1;
    while (changed)
      {
        changed = 0;
!       for (i = NUM_FIXED_BLOCKS; i < last_basic_block; i++)
  	{
  	  sbitmap_union_of_preds (bb_in, bb_out, i);
  	  changed |= sbitmap_union_of_diff_cg (bb_out[i], bb_gen[i],
*************** link_btr_uses (btr_def *def_array, btr_u
*** 668,674 ****
  
    /* Link uses to the uses lists of all of their reaching defs.
       Count up the number of reaching defs of each use.  */
!   for (i = NUM_FIXED_BLOCKS; i < n_basic_blocks; i++)
      {
        basic_block bb = BASIC_BLOCK (i);
        rtx insn;
--- 668,674 ----
  
    /* Link uses to the uses lists of all of their reaching defs.
       Count up the number of reaching defs of each use.  */
!   for (i = NUM_FIXED_BLOCKS; i < last_basic_block; i++)
      {
        basic_block bb = BASIC_BLOCK (i);
        rtx insn;
*************** build_btr_def_use_webs (fibheap_t all_bt
*** 780,787 ****
    btr_user *use_array   = XCNEWVEC (btr_user, max_uid);
    sbitmap *btr_defset   = sbitmap_vector_alloc (
  			   (last_btr - first_btr) + 1, max_uid);
!   sbitmap *bb_gen      = sbitmap_vector_alloc (n_basic_blocks, max_uid);
!   HARD_REG_SET *btrs_written = XCNEWVEC (HARD_REG_SET, n_basic_blocks);
    sbitmap *bb_kill;
    sbitmap *bb_out;
  
--- 780,787 ----
    btr_user *use_array   = XCNEWVEC (btr_user, max_uid);
    sbitmap *btr_defset   = sbitmap_vector_alloc (
  			   (last_btr - first_btr) + 1, max_uid);
!   sbitmap *bb_gen      = sbitmap_vector_alloc (last_basic_block, max_uid);
!   HARD_REG_SET *btrs_written = XCNEWVEC (HARD_REG_SET, last_basic_block);
    sbitmap *bb_kill;
    sbitmap *bb_out;
  
*************** build_btr_def_use_webs (fibheap_t all_bt
*** 790,800 ****
    compute_defs_uses_and_gen (all_btr_defs, def_array, use_array, btr_defset,
  			     bb_gen, btrs_written);
  
!   bb_kill = sbitmap_vector_alloc (n_basic_blocks, max_uid);
    compute_kill (bb_kill, btr_defset, btrs_written);
    free (btrs_written);
  
!   bb_out = sbitmap_vector_alloc (n_basic_blocks, max_uid);
    compute_out (bb_out, bb_gen, bb_kill, max_uid);
  
    sbitmap_vector_free (bb_gen);
--- 790,800 ----
    compute_defs_uses_and_gen (all_btr_defs, def_array, use_array, btr_defset,
  			     bb_gen, btrs_written);
  
!   bb_kill = sbitmap_vector_alloc (last_basic_block, max_uid);
    compute_kill (bb_kill, btr_defset, btrs_written);
    free (btrs_written);
  
!   bb_out = sbitmap_vector_alloc (last_basic_block, max_uid);
    compute_out (bb_out, bb_gen, bb_kill, max_uid);
  
    sbitmap_vector_free (bb_gen);
*************** migrate_btr_defs (enum reg_class btr_cla
*** 1403,1409 ****
      {
        int i;
  
!       for (i = NUM_FIXED_BLOCKS; i < n_basic_blocks; i++)
  	{
  	  basic_block bb = BASIC_BLOCK (i);
  	  fprintf(dump_file,
--- 1403,1409 ----
      {
        int i;
  
!       for (i = NUM_FIXED_BLOCKS; i < last_basic_block; i++)
  	{
  	  basic_block bb = BASIC_BLOCK (i);
  	  fprintf(dump_file,
*************** migrate_btr_defs (enum reg_class btr_cla
*** 1426,1433 ****
  	  first_btr = reg;
        }
  
!   btrs_live = XCNEWVEC (HARD_REG_SET, n_basic_blocks);
!   btrs_live_at_end = XCNEWVEC (HARD_REG_SET, n_basic_blocks);
  
    build_btr_def_use_webs (all_btr_defs);
  
--- 1426,1433 ----
  	  first_btr = reg;
        }
  
!   btrs_live = XCNEWVEC (HARD_REG_SET, last_basic_block);
!   btrs_live_at_end = XCNEWVEC (HARD_REG_SET, last_basic_block);
  
    build_btr_def_use_webs (all_btr_defs);
  


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