Dumping tree with no opt flag

2007-07-30 Thread Emmanuel Fleury
Hi all,

I try to develop a tool that get the final CFG of gcc by passing the
-fdump-tree-final_cleanup-lineno option and parsing the file dumped by gcc.

I noticed that this flag does create an output only if at least the
'-O1' (or more) is in the command line.

I just would like to know if it would be possible to get the
final_cleanup target even though no optimization flag has been given in
the command line (for now, I'm just forcing '-O1' to be present if no
other optimization flag has been detected in the command line).

A final remark, not really significant, I noticed that since gcc 4.2,
the name of the dumped tree files have slightly changed. Indeed before,
I was used to src_file_name.t#id.type where in 4.2 it is more like
src_file_name.#idt.type.

I agree that this change is nothing but is there a reason for changing
the position of the 't' character ?

Regards
-- 
Emmanuel Fleury

There are only 10 types of people in the world.
Those who understand binary and those who don't
  -- Unknown


Re: Dumping tree with no opt flag

2007-07-30 Thread Diego Novillo
On 7/30/07 11:15 AM, Emmanuel Fleury wrote:

 I just would like to know if it would be possible to get the
 final_cleanup target even though no optimization flag has been given in
 the command line (for now, I'm just forcing '-O1' to be present if no
 other optimization flag has been detected in the command line).

No, because the final_cleanup pass is only executed when optimizing.
For -O0, you need to determine what's the last phase executed and
request a dump to that phase.  Also, future versions of GCC may not have
this phase as the final phase, or the dump file name may change, or both.

Dump files are merely debugging aids.  We make no guarantees as to their
content or naming convention.

 A final remark, not really significant, I noticed that since gcc 4.2,
 the name of the dumped tree files have slightly changed. Indeed before,
 I was used to src_file_name.t#id.type where in 4.2 it is more like
 src_file_name.#idt.type.

We amalgamated the dumping mechanism for trees and RTL.  The 't' denotes
a 'tree' dump, 'r' an RTL dump and 'i' an IPA dump.


Re: Dumping tree with no opt flag

2007-07-30 Thread Emmanuel Fleury
Wow, that was quick. :)

Diego Novillo wrote:
 On 7/30/07 11:15 AM, Emmanuel Fleury wrote:
 
 I just would like to know if it would be possible to get the
 final_cleanup target even though no optimization flag has been given in
 the command line (for now, I'm just forcing '-O1' to be present if no
 other optimization flag has been detected in the command line).
 
 No, because the final_cleanup pass is only executed when optimizing.
 For -O0, you need to determine what's the last phase executed and
 request a dump to that phase. 

Ok, this is more or less what I though. I guess that nobody want
unoptimized code in his final build, so I think I can go with my hack
(adding -O1 when needed).

 Also, future versions of GCC may not have
 this phase as the final phase, or the dump file name may change, or both.
 
 Dump files are merely debugging aids.  We make no guarantees as to their
 content or naming convention.

Hum, I'm coding a tool for static and (symbolic) dynamic analysis of
code, would you recommend me a way to get the most final CFG you get
inside GCC (other than the -fdump-tree-flags) ???

It would be very helpful for me to get a GENERIC/GIMPLE CFG (with SSA
and so on) of the source code so that I can analyze all the languages
that go through a gimplifier. :-/

 A final remark, not really significant, I noticed that since gcc 4.2,
 the name of the dumped tree files have slightly changed. Indeed before,
 I was used to src_file_name.t#id.type where in 4.2 it is more like
 src_file_name.#idt.type.
 
 We amalgamated the dumping mechanism for trees and RTL.  The 't' denotes
 a 'tree' dump, 'r' an RTL dump and 'i' an IPA dump.

Damn, you also have inter-procedural analysis dumps !
More I know about GCC, more I love it ! I'll dig this. :)

Actually, I know that these dumps are here, as you said, just for
debugging purpose but why not making them 'permanent' and kind-of
'standardized' (I mean, not changing it too frequently), so that code
analysis tools could plug on GCC ? (I know I'm asking a lot... sorry)

Regards
-- 
Emmanuel Fleury

The memory management on the PowerPC
can be used to frighten small children.
  -- Linus Torvalds


Re: Dumping tree with no opt flag

2007-07-30 Thread Diego Novillo
On 7/30/07 11:34 AM, Emmanuel Fleury wrote:

 Actually, I know that these dumps are here, as you said, just for
 debugging purpose but why not making them 'permanent' and kind-of
 'standardized' (I mean, not changing it too frequently), so that code
 analysis tools could plug on GCC ? (I know I'm asking a lot... sorry)

Because that's not their goal.  The suggested way of doing this kind of
analyses is to implement them in GCC directly.  This way, instead of
parsing the text output, you can access the data structures directly.
That will be faster and easier to maintain in the future.

We also realize that dealing with GCC's code base is time consuming and
even difficult at first.  You may be interested in a couple of recent
projects to add plug-in functionality to future versions of GCC.  You
can read about them in the proceedings for this year's GCC Summit
(http://gcc.gnu.org/wiki/HomePage?action=AttachFiledo=gettarget=GCC2007-Proceedings.pdf)