gcc/ChangeLog: * gcc.c (execute): Identify certain commands, and account their time to specific timevars. * gcc.h (driver::get_timer): New accessor. * timevar.def (TV_DRIVER_EXECUTE_AS): New. (TV_DRIVER_EXECUTE_COLLECT2): New. (TV_DRIVER_EXECUTE_LD): New. (TV_DRIVER_EXECUTE_OTHER): New. --- gcc/gcc.c | 19 +++++++++++++++++++ gcc/gcc.h | 2 ++ gcc/timevar.def | 4 ++++ 3 files changed, 25 insertions(+)
diff --git a/gcc/gcc.c b/gcc/gcc.c index 46e750d..93f41ec 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -2845,6 +2845,25 @@ execute (void) if (strcmp (arg, "|") == 0) n_commands++; + /* If we're timing things, and we have a single command in the + pipeline, bill the time to that command. Given that we + need a timevar for each one, we only split out a few important + commands. */ + timevar_id_t tv_id; + tv_id = TV_DRIVER_EXECUTE_OTHER; + gcc_assert (g_driver); + timer *driver_timer = g_driver->get_timer (); + if (driver_timer && n_commands == 1) + { + if (0 == strcmp (argbuf[0], "as")) + tv_id = TV_DRIVER_EXECUTE_AS; + else if (0 == strcmp (argbuf[0], "collect2")) + tv_id = TV_DRIVER_EXECUTE_COLLECT2; + else if (0 == strcmp (argbuf[0], "ld")) + tv_id = TV_DRIVER_EXECUTE_LD; + } + auto_timevar tv (driver_timer, tv_id); + /* Get storage for each command. */ commands = (struct command *) alloca (n_commands * sizeof (struct command)); diff --git a/gcc/gcc.h b/gcc/gcc.h index cfff8ef..15bc11d 100644 --- a/gcc/gcc.h +++ b/gcc/gcc.h @@ -37,6 +37,8 @@ class driver int main (int argc, char **argv); void finalize (); + timer *get_timer () const { return m_timer; } + private: void set_progname (const char *argv0) const; void expand_at_files (int *argc, char ***argv) const; diff --git a/gcc/timevar.def b/gcc/timevar.def index d04a729..ce9236d 100644 --- a/gcc/timevar.def +++ b/gcc/timevar.def @@ -291,6 +291,10 @@ DEFTIMEVAR (TV_ASSEMBLE , "assemble JIT code") DEFTIMEVAR (TV_DRIVER_SETUP , "driver: setup") DEFTIMEVAR (TV_DRIVER_SPEC , "driver: do spec on infiles") DEFTIMEVAR (TV_DRIVER_LINK , "driver: run linker") +DEFTIMEVAR (TV_DRIVER_EXECUTE_AS , "driver: executing \"as\"") +DEFTIMEVAR (TV_DRIVER_EXECUTE_COLLECT2, "driver: executing \"collect2\"") +DEFTIMEVAR (TV_DRIVER_EXECUTE_LD , "driver: executing \"ld\"") +DEFTIMEVAR (TV_DRIVER_EXECUTE_OTHER , "driver: executing subprocess") DEFTIMEVAR (TV_LINK , "link JIT code") DEFTIMEVAR (TV_LOAD , "load JIT result") DEFTIMEVAR (TV_JIT_ACQUIRING_MUTEX , "acquiring JIT mutex") -- 1.8.5.3