aboutsummaryrefslogtreecommitdiff
path: root/gcc/lto
diff options
context:
space:
mode:
authorLawrence Crowl <crowl@google.com>2012-06-19 01:30:31 +0000
committerLawrence Crowl <crowl@google.com>2012-06-19 01:30:31 +0000
commit4420cdc3e589fe8ac12f54e3f82ffd078d7bd33e (patch)
treeed63d482b0f935843a41c0fe609e366f30e528ed /gcc/lto
parent8980227b8ed5a690404b2e9673ccd871229d4df2 (diff)
The intent of the phases was to have a high-level but mutually exclusive
accounting of compile time. We want to track compile time in a way that tells us which conceptual phases are taking the most time. That intent is not currently satisfied. This patch restores that intent. Add code to verify that the sum of the phase times is less than the total time, to detect when phases are overlapped. A slight amount of leeway is required due to time jitters. This verification is done as the last step in printing timevars so that any timevar information is not lost. Rename the phases to be clearer about what they measure, so that they are less likely to be modified to be overlapping. The primary example is to change TV_PHASE_GENERATE to TV_PHASE_LATE_ASM, meaning late work on the assembly. This name change avoids confusion n moving the timevar start call after the call to lang_hooks.decls.final_write_globals, which prevents overlapping phases. Each implementation of lang_hooks.decls.final_write_globals, is responsible for starting and stopping its own phases. Each implementation currently has a first phase of TV_PHASE_DEFERRED for front-end work deferred until after parsing is complete. The second phase has been renamed from TV_PHASE_CGRAPH to TV_PHASE_OPT_GEN, to better reflect its use as the main optimization and generation phase. This phase accounts for 70%-80% of compilation time during bootstrap. The third phase is TV_PHASE_DBGINFO, except in cp/decl2.c, where it is TV_PHASE_CHECK_DBGINFO because cc1plus mixes checking in with debug info generation. In langhooks.c, write_global_declarations was using TV_PHASE_CHECK_DBGINFO, but it was doing no checking. So, it now uses TV_PHASE_DBGINFO. The changes to LTO are significant. First, initialization now uses TV_PHASE_SETUP. Reading files now uses TV_PHASE_STREAM_IN. Writing files now uses TV_PHASE_STREAM_OUT. The remaining phase is TV_PHASE_OPT_GEN (formerly TV_PHASE_CGRAPH). Finally, because LTO is treated as a front end, TV_PHASE_PARSING and TV_PARSE_GLOBAL active around it. It is not parsing, and so those timers should not be active. Rather than make all front ends manage them, we turn them off as the first thing in LTO and turn them back on as the last thing. Tested on x86_64. Index: gcc/ChangeLog 2012-06-18 Lawrence Crowl <crowl@google.com> * timevar.def (TV_PHASE_GENERATE): Rename to TV_PHASE_LATE_ASM. (TV_PHASE_CGRAPH): Rename to TV_PHASE_OPT_GEN. (TV_PHASE_STREAM_IN): New. (TV_PHASE_STREAM_OUT): New. * timevar.c (validate_phases): New. (timevar_print): Call validate_phases. * c-decl.c (c_write_global_declarations): Rename use of TV_PHASE_CGRAPH to TV_PHASE_OPT_GEN. * langhooks.c (write_global_declarations): Rename use of TV_PHASE_CGRAPH to TV_PHASE_OPT_GEN. Use TV_PHASE_DBGINFO instead of TV_PHASE_CHECK_DBGINFO. * toplev.c (compile_file): Rename use of TV_PHASE_GENERATE to TV_PHASE_LATE_ASM. Move start of TV_PHASE_LATE_ASM to after call to lang_hooks.decls.final_write_globals. Index: gcc/cp/ChangeLog 2012-06-18 Lawrence Crowl <crowl@google.com> * decl2.c (cp_write_global_declarations): Rename use of TV_PHASE_CGRAPH to TV_PHASE_OPT_GEN. Index: gcc/lto/ChangeLog 2012-06-18 Lawrence Crowl <crowl@google.com> * lto.c (do_whole_program_analysis): Rename use of TV_PHASE_CGRAPH to TV_PHASE_OPT_GEN. Use new timevar TV_PHASE_STREAM_OUT around the call to lto_wpa_write_files. (lto_main): Rename use of TV_PHASE_CGRAPH to TV_PHASE_OPT_GEN. Move start of TV_PHASE_OPT_GEN to include call to materialize_cgraph. Use TV_PHASE_SETUP for the call to lto_init. Use new timevar TV_PHASE_STREAM_IN around the call to read_cgraph_and_symbols. Turn TV_PHASE_PARSING off then back on again, because LTO is pretending to be a front end, but is not one. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@188765 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/lto')
-rw-r--r--gcc/lto/ChangeLog12
-rw-r--r--gcc/lto/lto.c36
2 files changed, 43 insertions, 5 deletions
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog
index 06774d833b0..3f025dc8363 100644
--- a/gcc/lto/ChangeLog
+++ b/gcc/lto/ChangeLog
@@ -1,3 +1,15 @@
+2012-06-18 Lawrence Crowl <crowl@google.com>
+
+ * lto.c (do_whole_program_analysis): Rename use of TV_PHASE_CGRAPH to
+ TV_PHASE_OPT_GEN. Use new timevar TV_PHASE_STREAM_OUT around the call
+ to lto_wpa_write_files.
+ (lto_main): Rename use of TV_PHASE_CGRAPH to TV_PHASE_OPT_GEN. Move
+ start of TV_PHASE_OPT_GEN to include call to materialize_cgraph. Use
+ TV_PHASE_SETUP for the call to lto_init. Use new timevar
+ TV_PHASE_STREAM_IN around the call to read_cgraph_and_symbols.
+ Turn TV_PHASE_PARSING off then back on again, because LTO is pretending
+ to be a front end, but is not one.
+
2012-05-18 Jan Hubicka <jh@suse.cz>
* lto.c (lto_materialize_constructors_and_inits): Remove.
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index b94c8a7f869..df5c3df2ef3 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -1935,7 +1935,8 @@ materialize_cgraph (void)
static void
do_whole_program_analysis (void)
{
- timevar_start (TV_PHASE_CGRAPH);
+ timevar_start (TV_PHASE_OPT_GEN);
+
/* Note that since we are in WPA mode, materialize_cgraph will not
actually read in all the function bodies. It only materializes
the decls and cgraph nodes so that analysis can be performed. */
@@ -1979,23 +1980,27 @@ do_whole_program_analysis (void)
else
lto_balanced_map ();
+ timevar_stop (TV_PHASE_OPT_GEN);
+ timevar_start (TV_PHASE_STREAM_OUT);
+
if (!quiet_flag)
{
fprintf (stderr, "\nStreaming out");
fflush (stderr);
}
lto_wpa_write_files ();
- ggc_collect ();
if (!quiet_flag)
fprintf (stderr, "\n");
+ timevar_stop (TV_PHASE_STREAM_OUT);
+
+ ggc_collect ();
if (post_ipa_mem_report)
{
fprintf (stderr, "Memory consumption after IPA\n");
dump_memory_report (false);
}
- timevar_stop (TV_PHASE_CGRAPH);
/* Show the LTO report before launching LTRANS. */
if (flag_lto_report)
print_lto_report ();
@@ -2075,13 +2080,28 @@ lto_init (void)
void
lto_main (void)
{
+ /* LTO is called as a front end, even though it is not a front end.
+ Because it is called as a front end, TV_PHASE_PARSING and
+ TV_PARSE_GLOBAL are active, and we need to turn them off while
+ doing LTO. Later we turn them back on so they are active up in
+ toplev.c. */
+ timevar_pop (TV_PARSE_GLOBAL);
+ timevar_stop (TV_PHASE_PARSING);
+
+ timevar_start (TV_PHASE_SETUP);
+
/* Initialize the LTO front end. */
lto_init ();
+ timevar_stop (TV_PHASE_SETUP);
+ timevar_start (TV_PHASE_STREAM_IN);
+
/* Read all the symbols and call graph from all the files in the
command line. */
read_cgraph_and_symbols (num_in_fnames, in_fnames);
+ timevar_stop (TV_PHASE_STREAM_IN);
+
if (!seen_error ())
{
/* If WPA is enabled analyze the whole call graph and create an
@@ -2091,13 +2111,15 @@ lto_main (void)
do_whole_program_analysis ();
else
{
+ timevar_start (TV_PHASE_OPT_GEN);
+
materialize_cgraph ();
/* Let the middle end know that we have read and merged all of
the input files. */
- timevar_start (TV_PHASE_CGRAPH);
compile ();
- timevar_stop (TV_PHASE_CGRAPH);
+
+ timevar_stop (TV_PHASE_OPT_GEN);
/* FIXME lto, if the processes spawned by WPA fail, we miss
the chance to print WPA's report, so WPA will call
@@ -2108,6 +2130,10 @@ lto_main (void)
print_lto_report ();
}
}
+
+ /* Here we make LTO pretend to be a parser. */
+ timevar_start (TV_PHASE_PARSING);
+ timevar_push (TV_PARSE_GLOBAL);
}
#include "gt-lto-lto.h"