Re: basic bloc chaining: using dominance

2011-05-12 Thread Richard Guenther
On Wed, May 11, 2011 at 10:03 PM, Ian Lance Taylor i...@google.com wrote:
 Pierre Vittet pier...@pvittet.com writes:

 First, thanks for your help. I have looked at several function using
 calculate_dominance_info(). From what I understand, when you have
 finish to use it, you have to clear the structure by making a
 free_dominance_info().
 In the function flow_loops_find (file gcc/cfgloop.c), there is a call
 to calculate_dominance_info() without call to free_dominance_info(). I
 feel it is a bug, no?

 Not in this case, no.  The caller or a later pass is responsible for
 freeing it in this case.  There should ideally be a comment about this.

dominator information should be freed if it is made invalid by CFG
transformations.
Otherwise the policy is to keep it around to avoid re-computing it (too many
passes need it).  For post-dominator info the policy is to always free it.

Richard.

 Ian



Re: basic bloc chaining: using dominance

2011-05-11 Thread Pierre Vittet

On 10/05/2011 16:23, Ian Lance Taylor wrote:

Pierre Vittetpier...@pvittet.com  writes:

   

I am working on a plugin at the GIMPLE state, I am parsing basic
blocks and I need to check that a call to foo() is only present once
in a function. Howerver, it can be present several times if it is in
different basic blocks and only one is executed at execution time.

I think the most convenient way is to use dominance relation between
the basic blocks: I can warn in a basic block A calling the foo()
function only if there is a block B calling foo and dominating A. In
others cases, I cannot be sure that there is several calls to foo().

In the file gcc/dominance.c, there is a dominated_by_p function which
allows to test dominance between 2 basic blocks and I would like to
use it to solve this problem.

I would like to have your opinion, does it looks the google solution
to the problem or is there another way to do this?

If this is a good solution, I will implement a primitive in MELT
allowing to use dominated_by_p function in MELT.
 

Yes, dominated_by_p and friends are the right way to test for basic
block dominance.  Note that you have to build the graph first; see uses
of calculate_dominance_info.

Ian

   
First, thanks for your help. I have looked at several function using 
calculate_dominance_info(). From what I understand, when you have finish 
to use it, you have to clear the structure by making a 
free_dominance_info().
In the function flow_loops_find (file gcc/cfgloop.c), there is a call to 
calculate_dominance_info() without call to free_dominance_info(). I feel 
it is a bug, no?


Re: basic bloc chaining: using dominance

2011-05-11 Thread Ian Lance Taylor
Pierre Vittet pier...@pvittet.com writes:

 First, thanks for your help. I have looked at several function using
 calculate_dominance_info(). From what I understand, when you have
 finish to use it, you have to clear the structure by making a
 free_dominance_info().
 In the function flow_loops_find (file gcc/cfgloop.c), there is a call
 to calculate_dominance_info() without call to free_dominance_info(). I
 feel it is a bug, no?

Not in this case, no.  The caller or a later pass is responsible for
freeing it in this case.  There should ideally be a comment about this.

Ian


basic bloc chaining: using dominance

2011-05-10 Thread Pierre Vittet

Hello,

I am working on a plugin at the GIMPLE state, I am parsing basic blocks 
and I need to check that a call to foo() is only present once in a 
function. Howerver, it can be present several times if it is in 
different basic blocks and only one is executed at execution time.


I think the most convenient way is to use dominance relation between the 
basic blocks: I can warn in a basic block A calling the foo() function 
only if there is a block B calling foo and dominating A. In others 
cases, I cannot be sure that there is several calls to foo().


In the file gcc/dominance.c, there is a dominated_by_p function which 
allows to test dominance between 2 basic blocks and I would like to use 
it to solve this problem.


I would like to have your opinion, does it looks the google solution to 
the problem or is there another way to do this?


If this is a good solution, I will implement a primitive in MELT 
allowing to use dominated_by_p function in MELT.


Thanks!

Pierre Vittet

My Google Summer Of Code projet: 
http://www.google-melange.com/gsoc/project/google/gsoc2011/piervit/15001


Re: basic bloc chaining: using dominance

2011-05-10 Thread Ian Lance Taylor
Pierre Vittet pier...@pvittet.com writes:

 I am working on a plugin at the GIMPLE state, I am parsing basic
 blocks and I need to check that a call to foo() is only present once
 in a function. Howerver, it can be present several times if it is in
 different basic blocks and only one is executed at execution time.

 I think the most convenient way is to use dominance relation between
 the basic blocks: I can warn in a basic block A calling the foo()
 function only if there is a block B calling foo and dominating A. In
 others cases, I cannot be sure that there is several calls to foo().

 In the file gcc/dominance.c, there is a dominated_by_p function which
 allows to test dominance between 2 basic blocks and I would like to
 use it to solve this problem.

 I would like to have your opinion, does it looks the google solution
 to the problem or is there another way to do this?

 If this is a good solution, I will implement a primitive in MELT
 allowing to use dominated_by_p function in MELT.

Yes, dominated_by_p and friends are the right way to test for basic
block dominance.  Note that you have to build the graph first; see uses
of calculate_dominance_info.

Ian