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]

Re: [patch] tree-ssa-dom.c: Fix memory leak.


On Fri, 2004-12-10 at 19:31 -0500, Kazu Hirata wrote:
> Hi,
> 
> Attached is a patch to fix memory leak in record_edge_info.
> 
> In record_edge_info, we have a sequence of three "if" statements like
> so.
> 
>   if ((TREE_CODE (cond) == EQ_EXPR || TREE_CODE (cond) == NE_EXPR)
>       && TREE_CODE (op0) == SSA_NAME
>       && TREE_CODE (TREE_TYPE (op0)) == BOOLEAN_TYPE
>       && is_gimple_min_invariant (op1))
> 
>   if (is_gimple_min_invariant (op0)
>       && (TREE_CODE (op1) == SSA_NAME
> 	  || is_gimple_min_invariant (op1)))
> 
>   if (TREE_CODE (op0) == SSA_NAME
>       && (is_gimple_min_invariant (op1)
> 	  || TREE_CODE (op1) == SSA_NAME))
> 
> Blocks under each of these "if" statements allocate edge_info for two
> edges of a COND_EXPR.  The problem is that when the first "if"
> condition holds, the third one necessarily holds, too. 
Opps.  That was a goof on my part when I recently reorganized this code.


> 
> The patch fixes the problem by putting "else" in the second and third
> "if" statements so that at most one "if" will trigger.
That is the correct fix.

> 
> With this patch, we no longer record expressions like LE_EXPR or
> GE_EXPR for boolean equality, but that should be OK as I don't think
> we use LE_EXPR or GE_EXPR on booleans.
I don't really follow what you're trying to say here.  Can you elaborate
more?  I don't think it matters, but I would like to understand what
you're trying to say.


> 
> Tested on i686-pc-linux-gnu.  OK to apply?
> 
> Kazu Hirata
> 
> 2004-12-10  Kazu Hirata  <kazu@cs.umass.edu>
> 
> 	* tree-ssa-dom.c (record_edge_info): Fix memory leak.
OK.
jeff



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