diff options
Diffstat (limited to 'gcc/toplev.c')
-rw-r--r-- | gcc/toplev.c | 68 |
1 files changed, 53 insertions, 15 deletions
diff --git a/gcc/toplev.c b/gcc/toplev.c index 7df9cc79004..a87ff9a2ff8 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -83,6 +83,10 @@ along with GCC; see the file COPYING3. If not see #include "diagnostic-color.h" #include "context.h" #include "pass_manager.h" +#include "dwarf2out.h" +#include "ipa-reference.h" +#include "ipa-prop.h" +#include "gcse.h" #include "optabs.h" #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) @@ -101,7 +105,7 @@ along with GCC; see the file COPYING3. If not see #include <new> static void general_init (const char *); -static void do_compile (void); +static void do_compile (); static void process_options (void); static void backend_init (void); static int lang_dependent_init (const char *); @@ -1161,6 +1165,7 @@ general_init (const char *argv0) table. */ init_ggc (); init_stringpool (); + input_location = UNKNOWN_LOCATION; line_table = ggc_alloc<line_maps> (); linemap_init (line_table, BUILTINS_LOCATION); line_table->reallocator = realloc_for_line_map; @@ -1708,16 +1713,16 @@ lang_dependent_init_target (void) /* Perform initializations that are lang-dependent or target-dependent. but matters only for late optimizations and RTL generation. */ +static int rtl_initialized; + void initialize_rtl (void) { - static int initialized_once; - /* Initialization done just once per compilation, but delayed till code generation. */ - if (!initialized_once) + if (!rtl_initialized) ira_init_once (); - initialized_once = true; + rtl_initialized = true; /* Target specific RTL backend initialization. */ if (!this_target_rtl->target_specific_initialized) @@ -1922,14 +1927,8 @@ standard_type_bitsize (int bitsize) /* Initialize the compiler, and compile the input file. */ static void -do_compile (void) +do_compile () { - /* Initialize timing first. The C front ends read the main file in - the post_options hook, and C++ does file timings. */ - if (time_report || !quiet_flag || flag_detailed_statistics) - timevar_init (); - timevar_start (TV_TOTAL); - process_options (); /* Don't do any more if an error has already occurred. */ @@ -1987,12 +1986,30 @@ do_compile (void) timevar_stop (TV_PHASE_FINALIZE); } +} - /* Stop timing and print the times. */ +toplev::toplev (bool use_TV_TOTAL) + : m_use_TV_TOTAL (use_TV_TOTAL) +{ + if (!m_use_TV_TOTAL) + start_timevars (); +} + +toplev::~toplev () +{ timevar_stop (TV_TOTAL); timevar_print (stderr); } +void +toplev::start_timevars () +{ + if (time_report || !quiet_flag || flag_detailed_statistics) + timevar_init (); + + timevar_start (TV_TOTAL); +} + /* Entry point of cc1, cc1plus, jc1, f771, etc. Exit code is FATAL_EXIT_CODE if can't open files or if there were any errors, or SUCCESS_EXIT_CODE if compilation succeeded. @@ -2000,7 +2017,7 @@ do_compile (void) It is not safe to call this function more than once. */ int -toplev_main (int argc, char **argv) +toplev::main (int argc, char **argv) { /* Parsing and gimplification sometimes need quite large stack. Increase stack size limits if possible. */ @@ -2050,7 +2067,11 @@ toplev_main (int argc, char **argv) /* Exit early if we can (e.g. -help). */ if (!exit_after_options) - do_compile (); + { + if (m_use_TV_TOTAL) + start_timevars (); + do_compile (); + } if (warningcount || errorcount || werrorcount) print_ignored_options (); @@ -2068,3 +2089,20 @@ toplev_main (int argc, char **argv) return (SUCCESS_EXIT_CODE); } + +/* For those that want to, this function aims to clean up enough state that + you can call toplev::main again. */ +void +toplev::finalize (void) +{ + rtl_initialized = false; + this_target_rtl->target_specific_initialized = false; + + cgraph_c_finalize (); + cgraphunit_c_finalize (); + dwarf2out_c_finalize (); + gcse_c_finalize (); + ipa_cp_c_finalize (); + ipa_reference_c_finalize (); + params_c_finalize (); +} |