Convert a GNU GCC Compiler tree dump file in a GML graph (Graph-Model-Language) to visualize with gml4gtk GML graph viewer or other tools

mooigraph 9f29264e33 added link to important pdf 2 years ago
src 19b25ab3f7 initial 3 years ago
.gitignore 7c42746609 Initial commit 3 years ago
AUTHORS 19b25ab3f7 initial 3 years ago
COPYING 19b25ab3f7 initial 3 years ago
ChangeLog 19b25ab3f7 initial 3 years ago
INSTALL 19b25ab3f7 initial 3 years ago
LICENSE 7c42746609 Initial commit 3 years ago
Makefile.am 19b25ab3f7 initial 3 years ago
NEWS 19b25ab3f7 initial 3 years ago
README 19b25ab3f7 initial 3 years ago
README.md 9f29264e33 added link to important pdf 2 years ago
THANKS 19b25ab3f7 initial 3 years ago
autogen.sh 19b25ab3f7 initial 3 years ago
configure.ac 19b25ab3f7 initial 3 years ago
dmake 19b25ab3f7 initial 3 years ago
example.gml 19b25ab3f7 initial 3 years ago
screenshot.jpg 19b25ab3f7 initial 3 years ago

README

./autogen.sh
./configure
make
cd src
./gcctree2gml gcc-tree-data-file output
Then use a gmlviewer as gml4gtk or other.

to generate data with gcc:
gcc test.c -fdump-tree-all-graph

https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html

-fdump-tree-switch
-fdump-tree-switch-options
-fdump-tree-switch-options=filename
Control the dumping at various stages of processing the intermediate language tree to a file. The file name is generated by appending a switch-specific suffix to the source file name, and the file is created in the same directory as the output file. In case of =filename option, the dump is output on the given file instead of the auto named dump files. If the ‘-options’ form is used, options is a list of ‘-’ separated options which control the details of the dump. Not all options are applicable to all dumps; those that are not meaningful are ignored. The following options are available

‘address’
Print the address of each node. Usually this is not meaningful as it changes according to the environment and source file. Its primary use is for tying up a dump file with a debug environment.
‘asmname’
If DECL_ASSEMBLER_NAME has been set for a given decl, use that in the dump instead of DECL_NAME. Its primary use is ease of use working backward from mangled names in the assembly file.
‘slim’
When dumping front-end intermediate representations, inhibit dumping of members of a scope or body of a function merely because that scope has been reached. Only dump such items when they are directly reachable by some other path.

When dumping pretty-printed trees, this option inhibits dumping the bodies of control structures.

When dumping RTL, print the RTL in slim (condensed) form instead of the default LISP-like representation.
‘raw’
Print a raw representation of the tree. By default, trees are pretty-printed into a C-like representation.
‘details’
Enable more detailed dumps (not honored by every dump option). Also include information from the optimization passes.
‘stats’
Enable dumping various statistics about the pass (not honored by every dump option).
‘blocks’
Enable showing basic block boundaries (disabled in raw dumps).
‘graph’
For each of the other indicated dump files (-fdump-rtl-pass), dump a representation of the control flow graph suitable for viewing with GraphViz to file.passid.pass.dot. Each function in the file is pretty-printed as a subgraph, so that GraphViz can render them all in a single plot.

This option currently only works for RTL dumps, and the RTL is always dumped in slim form.
‘vops’
Enable showing virtual operands for every statement.
‘lineno’
Enable showing line numbers for statements.
‘uid’
Enable showing the unique ID (DECL_UID) for each variable.
‘verbose’
Enable showing the tree dump for each statement.
‘eh’
Enable showing the EH region number holding each statement.
‘scev’
Enable showing scalar evolution analysis details.
‘optimized’
Enable showing optimization information (only available in certain passes).
‘missed’
Enable showing missed optimization information (only available in certain passes).
‘note’
Enable other detailed optimization information (only available in certain passes).
‘=filename’
Instead of an auto named dump file, output into the given file name. The file names stdout and stderr are treated specially and are considered already open standard streams. For example,

gcc -O2 -ftree-vectorize -fdump-tree-vect-blocks=foo.dump
-fdump-tree-pre=stderr file.c

outputs vectorizer dump into foo.dump, while the PRE dump is output on to stderr. If two conflicting dump filenames are given for the same pass, then the latter option overrides the earlier one.
‘all’
Turn on all options, except raw, slim, verbose and lineno.
‘optall’
Turn on all optimization options, i.e., optimized, missed, and note.

The following tree dumps are possible:

‘original’
Dump before any tree based optimization, to file.original.
‘optimized’
Dump after all tree based optimization, to file.optimized.
‘gimple’
Dump each function before and after the gimplification pass to a file. The file name is made by appending .gimple to the source file name.
‘cfg’
Dump the control flow graph of each function to a file. The file name is made by appending .cfg to the source file name.
‘ch’
Dump each function after copying loop headers. The file name is made by appending .ch to the source file name.
‘ssa’
Dump SSA related information to a file. The file name is made by appending .ssa to the source file name.
‘alias’
Dump aliasing information for each function. The file name is made by appending .alias to the source file name.
‘ccp’
Dump each function after CCP. The file name is made by appending .ccp to the source file name.
‘storeccp’
Dump each function after STORE-CCP. The file name is made by appending .storeccp to the source file name.
‘pre’
Dump trees after partial redundancy elimination. The file name is made by appending .pre to the source file name.
‘fre’
Dump trees after full redundancy elimination. The file name is made by appending .fre to the source file name.
‘copyprop’
Dump trees after copy propagation. The file name is made by appending .copyprop to the source file name.
‘store_copyprop’
Dump trees after store copy-propagation. The file name is made by appending .store_copyprop to the source file name.
‘dce’
Dump each function after dead code elimination. The file name is made by appending .dce to the source file name.
‘sra’
Dump each function after performing scalar replacement of aggregates. The file name is made by appending .sra to the source file name.
‘sink’
Dump each function after performing code sinking. The file name is made by appending .sink to the source file name.
‘dom’
Dump each function after applying dominator tree optimizations. The file name is made by appending .dom to the source file name.
‘dse’
Dump each function after applying dead store elimination. The file name is made by appending .dse to the source file name.
‘phiopt’
Dump each function after optimizing PHI nodes into straightline code. The file name is made by appending .phiopt to the source file name.
‘forwprop’
Dump each function after forward propagating single use variables. The file name is made by appending .forwprop to the source file name.
‘copyrename’
Dump each function after applying the copy rename optimization. The file name is made by appending .copyrename to the source file name.
‘nrv’
Dump each function after applying the named return value optimization on generic trees. The file name is made by appending .nrv to the source file name.
‘vect’
Dump each function after applying vectorization of loops. The file name is made by appending .vect to the source file name.
‘slp’
Dump each function after applying vectorization of basic blocks. The file name is made by appending .slp to the source file name.
‘vrp’
Dump each function after Value Range Propagation (VRP). The file name is made by appending .vrp to the source file name.
‘all’
Enable all the available tree dumps with the flags provided in this option.




Mingjie Xing mingjie.xing@gmail.com