On 10/05/2011 16:23, Ian Lance Taylor wrote:
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
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?