public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* How to create a "finish" function for a tree opt pass
@ 2008-02-29  6:59 Haifeng He
  2008-02-29 13:23 ` Diego Novillo
  0 siblings, 1 reply; 4+ messages in thread
From: Haifeng He @ 2008-02-29  6:59 UTC (permalink / raw)
  To: gcc-help

Hi,

I have wrote a tree pass and I would like to create a "finish" function to dump
the analysis results. Since the results contains some global
information, I want to dump them
after the pass has been executed though all the functions of current
file. Is there a good way
that I can do that?

Thanks

Haifeng

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to create a "finish" function for a tree opt pass
  2008-02-29  6:59 How to create a "finish" function for a tree opt pass Haifeng He
@ 2008-02-29 13:23 ` Diego Novillo
  2008-02-29 20:27   ` Haifeng He
  0 siblings, 1 reply; 4+ messages in thread
From: Diego Novillo @ 2008-02-29 13:23 UTC (permalink / raw)
  To: Haifeng He; +Cc: gcc-help

On 2/29/08 12:16 AM, Haifeng He wrote:
> Hi,
> 
> I have wrote a tree pass and I would like to create a "finish" function to dump
> the analysis results. Since the results contains some global
> information, I want to dump them
> after the pass has been executed though all the functions of current
> file. Is there a good way
> that I can do that?

If you want to dump the IL after your pass is done, simply add 
TODO_dump_funcs to the todo_flags_finish field in the pass declaration.

If you need to dump other information, simply do it just before 
returning from the entry point function to your pass.


Diego.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to create a "finish" function for a tree opt pass
  2008-02-29 13:23 ` Diego Novillo
@ 2008-02-29 20:27   ` Haifeng He
  2008-02-29 20:36     ` Diego Novillo
  0 siblings, 1 reply; 4+ messages in thread
From: Haifeng He @ 2008-02-29 20:27 UTC (permalink / raw)
  To: Diego Novillo; +Cc: gcc-help

On Fri, Feb 29, 2008 at 6:00 AM, Diego Novillo <dnovillo@google.com> wrote:
>
> On 2/29/08 12:16 AM, Haifeng He wrote:
>  > Hi,
>  >
>  > I have wrote a tree pass and I would like to create a "finish" function to dump
>  > the analysis results. Since the results contains some global
>  > information, I want to dump them
>  > after the pass has been executed though all the functions of current
>  > file. Is there a good way
>  > that I can do that?
>
>  If you want to dump the IL after your pass is done, simply add
>  TODO_dump_funcs to the todo_flags_finish field in the pass declaration.
>
>  If you need to dump other information, simply do it just before
>  returning from the entry point function to your pass.
>

Thanks for the response. Probably I did not say it clearly. in my
previous mail. What I wanted was something
little different. Basically, I want to dump all the RECORD_TYPE used
in all the functions of the current
compilation unit. Since a tree pass is executed at function level (if
I understood correctly),
if I dump such information at the end of my pass, a RECORD_TYPE will
be written out
multiple times if the type is used in several functions.

What I did currently was to add my dump routine in
toplev.c:compile_file, after finish_aliases_2
and coverage_finish. I thought it might be nice if there is already
some kind of method defined in the
tree_opt_pass so that user can use to do similar finish-up work.

Haifeng

>
>  Diego.
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to create a "finish" function for a tree opt pass
  2008-02-29 20:27   ` Haifeng He
@ 2008-02-29 20:36     ` Diego Novillo
  0 siblings, 0 replies; 4+ messages in thread
From: Diego Novillo @ 2008-02-29 20:36 UTC (permalink / raw)
  To: Haifeng He; +Cc: gcc-help

On 2/29/08 3:15 PM, Haifeng He wrote:

> What I did currently was to add my dump routine in
> toplev.c:compile_file, after finish_aliases_2
> and coverage_finish. I thought it might be nice if there is already
> some kind of method defined in the
> tree_opt_pass so that user can use to do similar finish-up work.

If you are writing an intra-procedural pass, this is not possible.  Your 
code will be executed once per function in the callgraph.

You can accomplish this if you are implementing an inter-procedural 
pass.  See for instance, pass_ipa_cp.

We don't have finalizer hooks for executing after all the functions have 
been optimized.  You'd have to put your code in cgraph_optimize, maybe. 
Though where you put it now may be just as good.  Though, I think I'd 
rather see what you're trying to do first.  Maybe your pass should be an 
IPA pass.

Diego.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-02-29 20:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-29  6:59 How to create a "finish" function for a tree opt pass Haifeng He
2008-02-29 13:23 ` Diego Novillo
2008-02-29 20:27   ` Haifeng He
2008-02-29 20:36     ` Diego Novillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).