Hi, On Wed, 10 Feb 2016, Richard Biener wrote:
> > The problem is that TV_PHASE_DBGINFO is now nested within > > TV_PHASE_OPT_GEN, which violates the above mutual exclusivity > > requirement. Therefore the attached patch simply gets rid of > > TV_PHASE_DBGINFO (as well as of the sibling TV_PHASE_CHECK_DBGINFO > > which was already unused). > > > > Tested on x86_64-suse-linux, OK for the mainline? > > Ok. I had this in my tree for a while, asserting that such nesting doesn't happen (it asserts that we're always in some phase, and that phases don't nest). Might be a good addition for gcc 7. Ciao, Michael. Index: timevar.c =================================================================== --- timevar.c (revision 232927) +++ timevar.c (working copy) @@ -325,6 +325,8 @@ timer::push (timevar_id_t timevar) push_internal (tv); } +static timevar_id_t global_phase; + /* Push TV onto the timing stack, either one of the builtin ones for a timevar_id_t, or one provided by client code to libgccjit. */ @@ -350,6 +352,8 @@ timer::push_internal (struct timevar_def if (m_stack) timevar_accumulate (&m_stack->timevar->elapsed, &m_start_time, &now); + gcc_assert (global_phase >= TV_PHASE_SETUP + && global_phase <= TV_PHASE_FINALIZE); /* Reset the start time; from now on, time is attributed to TIMEVAR. */ m_start_time = now; @@ -432,6 +436,9 @@ timer::start (timevar_id_t timevar) { struct timevar_def *tv = &m_timevars[timevar]; + gcc_assert (global_phase == TV_NONE || global_phase == TV_TOTAL); + global_phase = timevar; + /* Mark this timing variable as used. */ tv->used = 1; @@ -463,6 +470,12 @@ timer::stop (timevar_id_t timevar) struct timevar_def *tv = &m_timevars[timevar]; struct timevar_time_def now; + gcc_assert (global_phase == timevar); + if (timevar == TV_TOTAL) + global_phase = TV_NONE; + else + global_phase = TV_TOTAL; + /* TIMEVAR must have been started via timevar_start. */ gcc_assert (tv->standalone); tv->standalone = 0; /* Enable a restart. */