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]

[tree-ssa] Minor bugfix to cfg_remove_useless_stmts


We might have a valid variable, but not a valid value when trying to find
useless statements created by out-of-ssa translation.     In this case
val will be set to null, then later dereferenced.  Bad.

The easiest fix is to nullify both var and val anytime one of them is
determined to be invalid.

I tripped over this with some unrelated changes, so I don't have a nice
little testcase that will trigger this with the current tree-ssa sources.


Bootstrapped and regression tested i686-pc-linux-gnu.

	* tree-cfg.c (cfg_remove_useless_stmts): Set both VAR and VAL to
	NULL anytime one of them is determined to be invalid.


Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.221
diff -c -3 -p -r1.1.4.221 tree-cfg.c
*** tree-cfg.c	20 Nov 2003 20:54:39 -0000	1.1.4.221
--- tree-cfg.c	21 Nov 2003 19:47:06 -0000
*************** cfg_remove_useless_stmts_bb (basic_block
*** 1322,1336 ****
  	  if (!ann
  	      || ann->may_aliases
  	      || TREE_ADDRESSABLE (var))
! 	    var = NULL_TREE;
  
! 	  if (! TREE_CONSTANT (val))
  	    {
  	      ann = var_ann (val);
  	      if (!ann
  		  || ann->may_aliases
  		  || TREE_ADDRESSABLE (val))
! 		val = NULL_TREE;
  	    }
  	}
  
--- 1322,1342 ----
  	  if (!ann
  	      || ann->may_aliases
  	      || TREE_ADDRESSABLE (var))
! 	    {
! 	      var = NULL_TREE;
! 	      val = NULL_TREE;
! 	    }
  
! 	  if (var && ! TREE_CONSTANT (val))
  	    {
  	      ann = var_ann (val);
  	      if (!ann
  		  || ann->may_aliases
  		  || TREE_ADDRESSABLE (val))
! 		{
! 		  val = NULL_TREE;
! 		  var = NULL_TREE;
! 		}
  	    }
  	}
  
*************** cfg_remove_useless_stmts_bb (basic_block
*** 1338,1344 ****
  	 them.  */
        if (var
  	  && FLOAT_TYPE_P (TREE_TYPE (var)))
! 	var = NULL_TREE;
      }
  
    for (bsi = bsi_start (bb); !bsi_end_p (bsi);)
--- 1344,1353 ----
  	 them.  */
        if (var
  	  && FLOAT_TYPE_P (TREE_TYPE (var)))
! 	{
! 	  var = NULL_TREE;
! 	  val = NULL_TREE;
! 	}
      }
  
    for (bsi = bsi_start (bb); !bsi_end_p (bsi);)
*************** cfg_remove_useless_stmts_bb (basic_block
*** 1369,1375 ****
  	      && (TREE_OPERAND (stmt, 0) == var
  		  || TREE_OPERAND (stmt, 0) == val
  		  || TREE_CODE (TREE_OPERAND (stmt, 1)) == VA_ARG_EXPR)))
! 	var = NULL_TREE;
    
        bsi_next (&bsi);
      }
--- 1378,1387 ----
  	      && (TREE_OPERAND (stmt, 0) == var
  		  || TREE_OPERAND (stmt, 0) == val
  		  || TREE_CODE (TREE_OPERAND (stmt, 1)) == VA_ARG_EXPR)))
! 	{
! 	  var = NULL_TREE;
! 	  val = NULL_TREE;
! 	}
    
        bsi_next (&bsi);
      }







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