This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Dump file for cgraph
- From: Jan Hubicka <jh at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org, rth at redhat dot com
- Date: Tue, 24 Jun 2003 14:52:59 +0200
- Subject: Dump file for cgraph
Hi,
I need place where to dump more verbose information than the stderr is.
This patch adds dump file .00.cgraph for it. I am not quite sure
whether using the rtl dump machinery is best idea, but I would like to
see it in the numbered dumps seqeunce (as this is very first
optimization performed).
OK?
Tue Jun 24 14:42:26 CEST 2003 Jan Hubicka <jh@suse.cz>
* cgraph.c (cgraph_node_name): New function.
(dump_cgraph): Use it.
* cgraph.h (cgraph_dump_file): Declare.
(cgraph_node_name): Declare.
* cgraphunit.c: Include timevar.h
(cgraph_finalize_compilation_unit): Use timevar; reorganize dumps.
(cgraph_optimize_function): Use TV_INTEGRATION.
(cgraph_mark_local_functions): reorganize dumps.
(cgraph_mark_functions_to_inline_once): Likewise.
(cgraph_optimize): Likewise; use timevar.
* timevar.def (TV_CGRAPH, TV_CGRAPHOPT): New.
* toplev.c (dump_file_index): Add DFI_cgraph.
(dump_file_info): Likewise.
(cgraph_dump_file): New global variable.
(do_compile): Open and close cgraph dump.
* invoke.texi (-d): Document new flag; renumber.
Index: cgraph.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraph.c,v
retrieving revision 1.12
diff -c -3 -p -r1.12 cgraph.c
*** cgraph.c 23 Jun 2003 21:11:44 -0000 1.12
--- cgraph.c 24 Jun 2003 12:32:42 -0000
*************** cgraph_rtl_info (decl)
*** 319,324 ****
--- 319,331 ----
return &node->rtl;
}
+ /* Return name of the node used in debug output. */
+ const char *
+ cgraph_node_name (node)
+ struct cgraph_node *node;
+ {
+ return (*lang_hooks.decl_printable_name) (node->decl, 2);
+ }
/* Dump the callgraph. */
*************** dump_cgraph (f)
*** 332,341 ****
for (node = cgraph_nodes; node; node = node->next)
{
struct cgraph_edge *edge;
! fprintf (f, "%s", IDENTIFIER_POINTER (DECL_NAME (node->decl)));
if (node->origin)
! fprintf (f, " nested in: %s",
! IDENTIFIER_POINTER (DECL_NAME (node->origin->decl)));
if (node->needed)
fprintf (f, " needed");
else if (node->reachable)
--- 339,347 ----
for (node = cgraph_nodes; node; node = node->next)
{
struct cgraph_edge *edge;
! fprintf (f, "%s", cgraph_node_name (node));
if (node->origin)
! fprintf (f, " nested in: %s", cgraph_node_name (node->origin));
if (node->needed)
fprintf (f, " needed");
else if (node->reachable)
*************** dump_cgraph (f)
*** 345,357 ****
fprintf (f, "\n called by :");
for (edge = node->callers; edge; edge = edge->next_caller)
! fprintf (f, "%s ",
! IDENTIFIER_POINTER (DECL_NAME (edge->caller->decl)));
fprintf (f, "\n calls: ");
for (edge = node->callees; edge; edge = edge->next_callee)
! fprintf (f, "%s ",
! IDENTIFIER_POINTER (DECL_NAME (edge->callee->decl)));
fprintf (f, "\n");
}
}
--- 351,361 ----
fprintf (f, "\n called by :");
for (edge = node->callers; edge; edge = edge->next_caller)
! fprintf (f, "%s ", cgraph_node_name (edge->caller));
fprintf (f, "\n calls: ");
for (edge = node->callees; edge; edge = edge->next_callee)
! fprintf (f, "%s ", cgraph_node_name (edge->callee));
fprintf (f, "\n");
}
}
Index: cgraph.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraph.h,v
retrieving revision 1.5
diff -c -3 -p -r1.5 cgraph.h
*** cgraph.h 23 Jun 2003 21:11:44 -0000 1.5
--- cgraph.h 24 Jun 2003 12:32:42 -0000
*************** extern struct cgraph_node *cgraph_nodes;
*** 101,106 ****
--- 101,107 ----
extern int cgraph_n_nodes;
extern bool cgraph_global_info_ready;
extern struct cgraph_node *cgraph_nodes_queue;
+ extern FILE *cgraph_dump_file;
/* In cgraph.c */
void dump_cgraph PARAMS ((FILE *));
*************** bool cgraph_calls_p PARAMS ((tree, tre
*** 113,118 ****
--- 114,120 ----
struct cgraph_local_info *cgraph_local_info PARAMS ((tree));
struct cgraph_global_info *cgraph_global_info PARAMS ((tree));
struct cgraph_rtl_info *cgraph_rtl_info PARAMS ((tree));
+ const char * cgraph_node_name PARAMS ((struct cgraph_node *));
/* In cgraphunit.c */
void cgraph_finalize_function PARAMS ((tree, tree));
Index: cgraphunit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cgraphunit.c,v
retrieving revision 1.6
diff -c -3 -p -r1.6 cgraphunit.c
*** cgraphunit.c 23 Jun 2003 21:11:44 -0000 1.6
--- cgraphunit.c 24 Jun 2003 12:32:42 -0000
*************** Software Foundation, 59 Temple Place - S
*** 34,39 ****
--- 34,40 ----
#include "target.h"
#include "cgraph.h"
#include "diagnostic.h"
+ #include "timevar.h"
static void cgraph_expand_functions PARAMS ((void));
static void cgraph_mark_functions_to_output PARAMS ((void));
*************** cgraph_finalize_compilation_unit ()
*** 144,155 ****
struct cgraph_node *node;
struct cgraph_edge *edge;
! if (!quiet_flag)
{
! fprintf (stderr, "\n\nInitial entry points:");
for (node = cgraph_nodes; node; node = node->next)
if (node->needed && DECL_SAVED_TREE (node->decl))
! announce_function (node->decl);
}
/* Propagate reachability flag and lower representation of all reachable
--- 145,158 ----
struct cgraph_node *node;
struct cgraph_edge *edge;
! timevar_push (TV_CGRAPH);
! if (cgraph_dump_file)
{
! fprintf (cgraph_dump_file, "\nInitial entry points:");
for (node = cgraph_nodes; node; node = node->next)
if (node->needed && DECL_SAVED_TREE (node->decl))
! fprintf (cgraph_dump_file, " %s", cgraph_node_name (node));
! fprintf (cgraph_dump_file, "\n");
}
/* Propagate reachability flag and lower representation of all reachable
*************** cgraph_finalize_compilation_unit ()
*** 191,206 ****
}
/* Collect entry points to the unit. */
! if (!quiet_flag)
{
! fprintf (stderr, "\n\nUnit entry points:");
for (node = cgraph_nodes; node; node = node->next)
if (node->needed && DECL_SAVED_TREE (node->decl))
! announce_function (node->decl);
}
! if (!quiet_flag)
! fprintf (stderr, "\n\nReclaiming functions:");
for (node = cgraph_nodes; node; node = node->next)
{
--- 194,210 ----
}
/* Collect entry points to the unit. */
! if (cgraph_dump_file)
{
! fprintf (cgraph_dump_file, "\nUnit entry points:");
for (node = cgraph_nodes; node; node = node->next)
if (node->needed && DECL_SAVED_TREE (node->decl))
! fprintf (cgraph_dump_file, " %s", cgraph_node_name (node));
! fprintf (cgraph_dump_file, "\n");
}
! if (cgraph_dump_file)
! fprintf (cgraph_dump_file, "\nReclaiming functions:");
for (node = cgraph_nodes; node; node = node->next)
{
*************** cgraph_finalize_compilation_unit ()
*** 210,218 ****
--- 214,227 ----
{
cgraph_remove_node (node);
announce_function (decl);
+ if (cgraph_dump_file)
+ fprintf (cgraph_dump_file, " %s", cgraph_node_name (node));
}
}
+ if (cgraph_dump_file)
+ fprintf (cgraph_dump_file, "\n");
ggc_collect ();
+ timevar_pop (TV_CGRAPH);
}
/* Figure out what functions we want to assemble. */
*************** cgraph_optimize_function (node)
*** 249,254 ****
--- 258,264 ----
{
tree decl = node->decl;
+ timevar_push (TV_INTEGRATION);
if (flag_inline_trees)
optimize_inline_calls (decl);
if (node->nested)
*************** cgraph_optimize_function (node)
*** 256,261 ****
--- 266,272 ----
for (node = node->nested; node; node = node->next_nested)
cgraph_optimize_function (node);
}
+ timevar_pop (TV_INTEGRATION);
}
/* Expand function specified by NODE. */
*************** cgraph_mark_local_functions ()
*** 378,385 ****
{
struct cgraph_node *node;
! if (!quiet_flag)
! fprintf (stderr, "\n\nMarking local functions:");
/* Figure out functions we want to assemble. */
for (node = cgraph_nodes; node; node = node->next)
--- 389,396 ----
{
struct cgraph_node *node;
! if (cgraph_dump_file)
! fprintf (cgraph_dump_file, "Marking local functions:");
/* Figure out functions we want to assemble. */
for (node = cgraph_nodes; node; node = node->next)
*************** cgraph_mark_local_functions ()
*** 388,396 ****
&& DECL_SAVED_TREE (node->decl)
&& !DECL_COMDAT (node->decl)
&& !TREE_PUBLIC (node->decl));
! if (node->local.local)
! announce_function (node->decl);
}
}
/* Decide what function should be inlined because they are invoked once
--- 399,409 ----
&& DECL_SAVED_TREE (node->decl)
&& !DECL_COMDAT (node->decl)
&& !TREE_PUBLIC (node->decl));
! if (cgraph_dump_file && node->local.local)
! fprintf (cgraph_dump_file, " %s", cgraph_node_name (node));
}
+ if (cgraph_dump_file)
+ fprintf (cgraph_dump_file, "\n");
}
/* Decide what function should be inlined because they are invoked once
*************** cgraph_mark_functions_to_inline_once ()
*** 401,408 ****
{
struct cgraph_node *node, *node1;
! if (!quiet_flag)
! fprintf (stderr, "\n\nMarking functions to inline once:");
/* Now look for function called only once and mark them to inline.
From this point number of calls to given function won't grow. */
--- 414,421 ----
{
struct cgraph_node *node, *node1;
! if (cgraph_dump_file)
! fprintf (cgraph_dump_file, "\n\nMarking functions to inline once:");
/* Now look for function called only once and mark them to inline.
From this point number of calls to given function won't grow. */
*************** cgraph_mark_functions_to_inline_once ()
*** 424,433 ****
if (ok)
{
node->global.inline_once = true;
! announce_function (node->decl);
}
}
}
}
--- 437,449 ----
if (ok)
{
node->global.inline_once = true;
! if (cgraph_dump_file)
! fprintf (cgraph_dump_file, " %s", cgraph_node_name (node));
}
}
}
+ if (cgraph_dump_file)
+ fprintf (cgraph_dump_file, "\n");
}
*************** cgraph_optimize ()
*** 439,449 ****
--- 455,477 ----
struct cgraph_node *node;
bool changed = true;
+ timevar_push (TV_CGRAPHOPT);
+ if (cgraph_dump_file)
+ {
+ fprintf (cgraph_dump_file, "Initial callgraph:");
+ dump_cgraph (cgraph_dump_file);
+ }
cgraph_mark_local_functions ();
cgraph_mark_functions_to_inline_once ();
cgraph_global_info_ready = true;
+ if (cgraph_dump_file)
+ {
+ fprintf (cgraph_dump_file, "Optimized callgraph:");
+ dump_cgraph (cgraph_dump_file);
+ }
+ timevar_pop (TV_CGRAPHOPT);
if (!quiet_flag)
fprintf (stderr, "\n\nAssembling functions:");
*************** cgraph_optimize ()
*** 477,481 ****
--- 505,514 ----
}
}
}
+ }
+ if (cgraph_dump_file)
+ {
+ fprintf (cgraph_dump_file, "Final callgraph:");
+ dump_cgraph (cgraph_dump_file);
}
}
Index: timevar.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/timevar.def,v
retrieving revision 1.18
diff -c -3 -p -r1.18 timevar.def
*** timevar.def 26 Feb 2003 11:09:33 -0000 1.18
--- timevar.def 24 Jun 2003 12:32:42 -0000
*************** DEFTIMEVAR (TV_GC , "
*** 39,44 ****
--- 39,46 ----
/* Time spent generating dump files. */
DEFTIMEVAR (TV_DUMP , "dump files")
+ DEFTIMEVAR (TV_CGRAPH , "callgraph construction")
+ DEFTIMEVAR (TV_CGRAPHOPT , "callgraph optimization")
/* Time spent by constructing CFG. */
DEFTIMEVAR (TV_CFG , "cfg construction")
/* Time spent by cleaning up CFG. */
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.785
diff -c -3 -p -r1.785 toplev.c
*** toplev.c 23 Jun 2003 16:11:56 -0000 1.785
--- toplev.c 24 Jun 2003 12:32:43 -0000
*************** struct dump_file_info
*** 249,254 ****
--- 249,255 ----
enum dump_file_index
{
+ DFI_cgraph,
DFI_rtl,
DFI_sibling,
DFI_eh,
*************** enum dump_file_index
*** 296,306 ****
Remaining -d letters:
" m q "
! " JK O Q UV YZ"
*/
static struct dump_file_info dump_file[DFI_MAX] =
{
{ "rtl", 'r', 0, 0, 0 },
{ "sibling", 'i', 0, 0, 0 },
{ "eh", 'h', 0, 0, 0 },
--- 297,308 ----
Remaining -d letters:
" m q "
! " JK O Q V YZ"
*/
static struct dump_file_info dump_file[DFI_MAX] =
{
+ { "cgraph", 'U', 0, 0, 0 },
{ "rtl", 'r', 0, 0, 0 },
{ "sibling", 'i', 0, 0, 0 },
{ "eh", 'h', 0, 0, 0 },
*************** static const lang_independent_options W_
*** 1554,1559 ****
--- 1556,1562 ----
FILE *asm_out_file;
FILE *aux_info_file;
FILE *rtl_dump_file = NULL;
+ FILE *cgraph_dump_file = NULL;
/* Decode the string P as an integral parameter.
If the string is indeed an integer return its numeric value else
*************** do_compile (void)
*** 5166,5174 ****
--- 5169,5190 ----
if (!no_backend)
backend_init ();
+ if (flag_unit_at_a_time)
+ {
+ open_dump_file (DFI_cgraph, NULL);
+ cgraph_dump_file = rtl_dump_file;
+ rtl_dump_file = NULL;
+ }
/* Language-dependent initialization. Returns true on success. */
if (lang_dependent_init (main_input_filename))
compile_file ();
+
+ if (flag_unit_at_a_time)
+ {
+ rtl_dump_file = cgraph_dump_file;
+ cgraph_dump_file = NULL;
+ close_dump_file (DFI_cgraph, NULL, NULL_RTX);
+ }
finalize ();
}
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.301
diff -c -3 -p -r1.301 invoke.texi
*** doc/invoke.texi 23 Jun 2003 13:29:41 -0000 1.301
--- doc/invoke.texi 24 Jun 2003 12:32:45 -0000
*************** meanings:
*** 3114,3228 ****
Annotate the assembler output with miscellaneous debugging information.
@item b
@opindex db
! Dump after computing branch probabilities, to @file{@var{file}.15.bp}.
@item B
@opindex dB
! Dump after block reordering, to @file{@var{file}.31.bbro}.
@item c
@opindex dc
! Dump after instruction combination, to the file @file{@var{file}.21.combine}.
@item C
@opindex dC
! Dump after the first if conversion, to the file @file{@var{file}.16.ce1}.
! Also dump after the second if conversion, to the file @file{@var{file}.22.ce2}.
@item d
@opindex dd
! Dump after branch target load optimization, to to @file{@var{file}.33.btl}.
! Also dump after delayed branch scheduling, to @file{@var{file}.36.dbr}.
@item D
@opindex dD
Dump all macro definitions, at the end of preprocessing, in addition to
normal output.
@item e
@opindex de
! Dump after SSA optimizations, to @file{@var{file}.04.ssa} and
! @file{@var{file}.07.ussa}.
@item E
@opindex dE
! Dump after the second if conversion, to @file{@var{file}.32.ce3}.
@item f
@opindex df
! Dump after control and data flow analysis, to @file{@var{file}.14.cfg}.
! Also dump after life analysis, to @file{@var{file}.20.life}.
@item F
@opindex dF
! Dump after purging @code{ADDRESSOF} codes, to @file{@var{file}.10.addressof}.
@item g
@opindex dg
! Dump after global register allocation, to @file{@var{file}.26.greg}.
@item G
@opindex dG
! Dump after GCSE, to @file{@var{file}.11.gcse}.
Also dump after jump bypassing and control flow optimizations, to
! @file{@var{file}.13.bypass}.
@item h
@opindex dh
! Dump after finalization of EH handling code, to @file{@var{file}.02.eh}.
@item i
@opindex di
! Dump after sibling call optimizations, to @file{@var{file}.01.sibling}.
@item j
@opindex dj
! Dump after the first jump optimization, to @file{@var{file}.03.jump}.
@item k
@opindex dk
! Dump after conversion from registers to stack, to @file{@var{file}.35.stack}.
@item l
@opindex dl
! Dump after local register allocation, to @file{@var{file}.25.lreg}.
@item L
@opindex dL
! Dump after loop optimization passes, to @file{@var{file}.12.loop} and
! @file{@var{file}.18.loop2}.
@item M
@opindex dM
Dump after performing the machine dependent reorganization pass, to
! @file{@var{file}.36.mach}.
@item n
@opindex dn
! Dump after register renumbering, to @file{@var{file}.30.rnreg}.
@item N
@opindex dN
! Dump after the register move pass, to @file{@var{file}.23.regmove}.
@item o
@opindex do
! Dump after post-reload optimizations, to @file{@var{file}.27.postreload}.
@item r
@opindex dr
! Dump after RTL generation, to @file{@var{file}.00.rtl}.
@item R
@opindex dR
! Dump after the second scheduling pass, to @file{@var{file}.34.sched2}.
@item s
@opindex ds
Dump after CSE (including the jump optimization that sometimes follows
! CSE), to @file{@var{file}.09.cse}.
@item S
@opindex dS
! Dump after the first scheduling pass, to @file{@var{file}.24.sched}.
@item t
@opindex dt
Dump after the second CSE pass (including the jump optimization that
! sometimes follows CSE), to @file{@var{file}.19.cse2}.
@item T
@opindex dT
! Dump after running tracer, to @file{@var{file}.17.tracer}.
@item u
@opindex du
! Dump after null pointer elimination pass to @file{@var{file}.08.null}.
! @item w
@opindex dw
! Dump after the second flow pass, to @file{@var{file}.28.flow2}.
@item W
@opindex dW
Dump after SSA conditional constant propagation, to
! @file{@var{file}.05.ssaccp}.
@item X
@opindex dX
! Dump after SSA dead code elimination, to @file{@var{file}.06.ssadce}.
@item z
@opindex dz
! Dump after the peephole pass, to @file{@var{file}.29.peephole2}.
@item a
@opindex da
Produce all the dumps listed above.
--- 3114,3231 ----
Annotate the assembler output with miscellaneous debugging information.
@item b
@opindex db
! Dump after computing branch probabilities, to @file{@var{file}.16.bp}.
@item B
@opindex dB
! Dump after block reordering, to @file{@var{file}.32.bbro}.
@item c
@opindex dc
! Dump after instruction combination, to the file @file{@var{file}.22.combine}.
@item C
@opindex dC
! Dump after the first if conversion, to the file @file{@var{file}.17.ce1}.
! Also dump after the second if conversion, to the file @file{@var{file}.23.ce2}.
@item d
@opindex dd
! Dump after branch target load optimization, to to @file{@var{file}.34.btl}.
! Also dump after delayed branch scheduling, to @file{@var{file}.37.dbr}.
@item D
@opindex dD
Dump all macro definitions, at the end of preprocessing, in addition to
normal output.
@item e
@opindex de
! Dump after SSA optimizations, to @file{@var{file}.05.ssa} and
! @file{@var{file}.010.ussa}.
@item E
@opindex dE
! Dump after the second if conversion, to @file{@var{file}.33.ce3}.
@item f
@opindex df
! Dump after control and data flow analysis, to @file{@var{file}.15.cfg}.
! Also dump after life analysis, to @file{@var{file}.21.life}.
@item F
@opindex dF
! Dump after purging @code{ADDRESSOF} codes, to @file{@var{file}.11.addressof}.
@item g
@opindex dg
! Dump after global register allocation, to @file{@var{file}.27.greg}.
@item G
@opindex dG
! Dump after GCSE, to @file{@var{file}.12.gcse}.
Also dump after jump bypassing and control flow optimizations, to
! @file{@var{file}.14.bypass}.
@item h
@opindex dh
! Dump after finalization of EH handling code, to @file{@var{file}.03.eh}.
@item i
@opindex di
! Dump after sibling call optimizations, to @file{@var{file}.02.sibling}.
@item j
@opindex dj
! Dump after the first jump optimization, to @file{@var{file}.04.jump}.
@item k
@opindex dk
! Dump after conversion from registers to stack, to @file{@var{file}.36.stack}.
@item l
@opindex dl
! Dump after local register allocation, to @file{@var{file}.26.lreg}.
@item L
@opindex dL
! Dump after loop optimization passes, to @file{@var{file}.13.loop} and
! @file{@var{file}.19.loop2}.
@item M
@opindex dM
Dump after performing the machine dependent reorganization pass, to
! @file{@var{file}.37.mach}.
@item n
@opindex dn
! Dump after register renumbering, to @file{@var{file}.31.rnreg}.
@item N
@opindex dN
! Dump after the register move pass, to @file{@var{file}.24.regmove}.
@item o
@opindex do
! Dump after post-reload optimizations, to @file{@var{file}.28.postreload}.
@item r
@opindex dr
! Dump after RTL generation, to @file{@var{file}.01.rtl}.
@item R
@opindex dR
! Dump after the second scheduling pass, to @file{@var{file}.35.sched2}.
@item s
@opindex ds
Dump after CSE (including the jump optimization that sometimes follows
! CSE), to @file{@var{file}.019.cse}.
@item S
@opindex dS
! Dump after the first scheduling pass, to @file{@var{file}.25.sched}.
@item t
@opindex dt
Dump after the second CSE pass (including the jump optimization that
! sometimes follows CSE), to @file{@var{file}.20.cse2}.
@item T
@opindex dT
! Dump after running tracer, to @file{@var{file}.18.tracer}.
@item u
@opindex du
! Dump after null pointer elimination pass to @file{@var{file}.018.null}.
! @item U
! @opindex dU
! Dump callgraph and unit-at-a-time optimization @file{@var{file}.00.unit}.
! @litem w
@opindex dw
! Dump after the second flow pass, to @file{@var{file}.29.flow2}.
@item W
@opindex dW
Dump after SSA conditional constant propagation, to
! @file{@var{file}.06.ssaccp}.
@item X
@opindex dX
! Dump after SSA dead code elimination, to @file{@var{file}.07.ssadce}.
@item z
@opindex dz
! Dump after the peephole pass, to @file{@var{file}.30.peephole2}.
@item a
@opindex da
Produce all the dumps listed above.
*************** Also turns on @option{-dp} annotation.
*** 3245,3251 ****
@item v
@opindex dv
For each of the other indicated dump files (except for
! @file{@var{file}.00.rtl}), dump a representation of the control flow graph
suitable for viewing with VCG to @file{@var{file}.@var{pass}.vcg}.
@item x
@opindex dx
--- 3248,3254 ----
@item v
@opindex dv
For each of the other indicated dump files (except for
! @file{@var{file}.01.rtl}), dump a representation of the control flow graph
suitable for viewing with VCG to @file{@var{file}.@var{pass}.vcg}.
@item x
@opindex dx