From dd4d567f4b6b498242097c41d63666bdae320ac1 Mon Sep 17 00:00:00 2001 From: dmalcolm Date: Tue, 12 May 2015 17:29:32 +0000 Subject: Move global state in timevar.c to a new "timer" class gcc/ChangeLog: * timevar.c (timevar_enable): Delete in favor of... (g_timer): New global. (struct timevar_def): Move to timevar.h inside class timer. (struct timevar_stack_def): Likewise. (timevars): Delete global in favor of field "m_timevars" within class timer in timevar.h (stack): Likewise, in favor of field "m_stack". (unused_stack_instances): Likewise, in favor of field "m_unused_stack_instances". (start_time): Likewise, in favor of field "m_start_time". (get_time): Eliminate check for timevar_enable. (timer::timer): New function, built from part of timevar_init. (timevar_init): Rewrite idempotency test from using "timevar_enable" bool to using dynamic allocation of "g_timer". Move rest of implementation into timer's constructor. (timevar_push_1): Rename to... (timer::push): ...this, adding "m_" prefixes to variables that are now fields of timer. (timevar_pop_1): Likewise, rename to... (timer::pop): ...this, and add "m_" prefixes. (timevar_start): Replace test for "timevar_enable" with one for "g_timer", and move bulk of implementation to... (timer::start): ...here, adding "m_" prefixes. (timevar_stop): Likewise, from here... (timer::stop): ...to here. (timevar_cond_start): Likewise, from here... (timer::cond_start): ...to here. (timevar_cond_stop): Likewise, from here... (timer::cond_stop): ...to here. (validate_phases): Rename to... (timer::validate_phases): ...this, and add "m_" prefixes. Make locals "total" and "tv" const. (timevar_print): Rename to... (timer::print): ...this, and add "m_" prefixes. Make locals "total" and "tv" const. Eliminate test for timevar_enable. * timevar.h (timevar_enable): Eliminate. (g_timer): New declaration. (timevar_push_1): Eliminate. (timevar_pop_1): Eliminate. (timevar_print): Eliminate. (class timer): New class. (timevar_push): Rewrite to use g_timer. (timevar_pop): Likewise. * toplev.c (toplev::~toplev): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223092 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/toplev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gcc/toplev.c') diff --git a/gcc/toplev.c b/gcc/toplev.c index 27736c29d08..9b1151b0186 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -2095,8 +2095,11 @@ toplev::toplev (bool use_TV_TOTAL, bool init_signals) toplev::~toplev () { - timevar_stop (TV_TOTAL); - timevar_print (stderr); + if (g_timer) + { + g_timer->stop (TV_TOTAL); + g_timer->print (stderr); + } } void -- cgit v1.2.1