Hello,

> What I am trying to do is something like counting the times of a particular 
> function call, i.e.,  whenever there is a CALL_EXPR in the tree, I want to 
> look at the id to see if that is the function I want to count during 
> runtime.  If the id is the function name I want to count, I insert a 
> counter instruction.
>
> It seems that I can mimic the code of dump_generic_node() (which is called 
> by dump_function() ) to do my instrumentation. However, here I have two 
> questions:
> (1) dump_generic_node() is definietly an overkill to my problem because it 
> takes care of all the NODE type, even the node I am not interested in, such 
> as TYPEs, DECLs. Based on what I want to do (described above), is there an 
> easy and cleaner way than the following pseudo code? i.e, is there a way 
> that I don't need to go through all the GIMPLE grammar situation (because 
> this is error-prone)?

pass_tree_profile seems to be more appropriate place for this
transformation.  You already have some infrastructure in place there
(see value-prof.c), so it might be easier to implement than starting
from scratch.  In that case, you do not even have to worry about the
internal representation too much, just add what you need to
tree_values_to_profile (and use get_call_expr_in to find function calls
in statements).

Zdenek

Reply via email to