GCC Middle and Back End API Reference
|
#include <timevar.h>
Data Structures | |
class | named_items |
struct | timevar_def |
struct | timevar_stack_def |
Public Member Functions | |
timer () | |
~timer () | |
void | start (timevar_id_t tv) |
void | stop (timevar_id_t tv) |
void | push (timevar_id_t tv) |
void | pop (timevar_id_t tv) |
bool | cond_start (timevar_id_t tv) |
void | cond_stop (timevar_id_t tv) |
void | push_client_item (const char *item_name) |
void | pop_client_item () |
void | print (FILE *fp) |
json::value * | make_json () const |
const char * | get_topmost_item_name () const |
Private Types | |
typedef hash_map< timevar_def *, timevar_time_def > | child_map_t |
Private Member Functions | |
void | validate_phases (FILE *fp) const |
void | push_internal (struct timevar_def *tv) |
void | pop_internal () |
Static Private Member Functions | |
static void | print_row (FILE *fp, const timevar_time_def *total, const char *name, const timevar_time_def &elapsed) |
static bool | all_zero (const timevar_time_def &elapsed) |
Private Attributes | |
timevar_def | m_timevars [TIMEVAR_LAST] |
timevar_stack_def * | m_stack |
timevar_stack_def * | m_unused_stack_instances |
timevar_time_def | m_start_time |
named_items * | m_jit_client_items |
Friends | |
class | named_items |
The public (within GCC) interface for timing.
|
private |
timer::timer | ( | ) |
Class timer's constructor.
This file contains the definitions for timing variables used to measure run-time performance of the compiler. Copyright (C) 2000-2024 Free Software Foundation, Inc. Contributed by Alex Samuel <samuel@codesourcery.com> This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
This file contains timing variable definitions, used by timevar.h and timevar.cc. Syntax: DEFTIMEVAR (id, name) where ID is the enumeral value used to identify the timing variable, and NAME is a character string describing its purpose.
The total execution time.
The compiler phases. These must be mutually exclusive, and the NAME field must begin with "phase". Also, their sum must be within a millionth of the total time (see validate_phases).
Concurrent timers, indicated by "|".
Time spent garbage-collecting.
Time spent generating dump files.
Time spent saving/restoring PCH state.
Time spent by constructing CFG.
Time spent by cleaning up CFG.
Time spent in dataflow problems.
Timing in various stages of the compiler.
Everything else in rest_of_compilation not included above.
Stuff used by libgccjit.so.
Analyzer timevars.
References m_timevars.
timer::~timer | ( | ) |
Class timer's destructor.
References free(), i, m_jit_client_items, m_stack, m_timevars, m_unused_stack_instances, timer::timevar_stack_def::next, and TIMEVAR_LAST.
|
staticprivate |
Return whether ELAPSED is all zero.
References timevar_time_def::ggc_mem, GGC_MEM_BOUND, and timevar_time_def::wall.
Referenced by make_json(), timer::timevar_def::make_json(), and print().
bool timer::cond_start | ( | timevar_id_t | timevar | ) |
See timevar_cond_start above.
References get_time(), m_timevars, timer::timevar_def::standalone, timer::timevar_def::start_time, and timer::timevar_def::used.
Referenced by auto_cond_timevar::start(), and timevar_cond_start().
void timer::cond_stop | ( | timevar_id_t | timevar | ) |
See timevar_cond_stop above.
References timer::timevar_def::elapsed, gcc_assert, get_time(), m_timevars, timer::timevar_def::standalone, timer::timevar_def::start_time, and timevar_accumulate().
Referenced by timevar_cond_stop(), and auto_cond_timevar::~auto_cond_timevar().
const char * timer::get_topmost_item_name | ( | ) | const |
Get the name of the topmost item. For use by jit for validating inputs to gcc_jit_timer_pop.
References m_stack, timer::timevar_def::name, NULL, and timer::timevar_stack_def::timevar.
json::value * timer::make_json | ( | ) | const |
Create a json value representing this object, suitable for use in SARIF output.
References all_zero(), json::array::append(), hash_map< KeyId, Value, Traits >::begin(), timer::timevar_def::children, timer::timevar_def::elapsed, hash_map< KeyId, Value, Traits >::end(), get_time(), i, m_jit_client_items, m_timevars, timer::named_items::make_json(), timer::timevar_def::make_json(), make_json_for_timevar_time_def(), NULL, json::object::set(), json::object::set_bool(), json::object::set_string(), timevar_diff(), TIMEVAR_LAST, and timer::timevar_def::used.
Referenced by compiler_data_hooks::add_sarif_invocation_properties().
void timer::pop | ( | timevar_id_t | timevar | ) |
Pop the topmost timing variable element off the timing stack. The popped variable must be TIMEVAR. Elapsed time since the that element was pushed on, or since it was last exposed on top of the stack when the element above it was popped off, is credited to that timing variable.
References gcc_assert, m_stack, m_timevars, pop_internal(), and timer::timevar_stack_def::timevar.
Referenced by timevar_pop(), and auto_timevar::~auto_timevar().
void timer::pop_client_item | ( | ) |
Pop the top-most client item from the timing stack.
References gcc_assert, m_jit_client_items, and timer::named_items::pop().
|
private |
Pop the topmost item from the stack, either one of the builtin ones for a timevar_id_t, or one provided by client code to libgccjit.
References timer::timevar_def::children, timer::timevar_def::elapsed, hash_map< KeyId, Value, Traits >::get_or_insert(), get_time(), m_stack, m_start_time, m_unused_stack_instances, timer::timevar_stack_def::next, timer::timevar_stack_def::timevar, and timevar_accumulate().
Referenced by pop().
void timer::print | ( | FILE * | fp | ) |
Summarize timing variables to FP. The timing variable TV_TOTAL has a special meaning -- it's considered to be the total elapsed time, for normalizing the others, and is displayed last.
References all_zero(), hash_map< KeyId, Value, Traits >::begin(), timer::timevar_def::children, timer::timevar_def::elapsed, hash_map< KeyId, Value, Traits >::end(), get_time(), timevar_time_def::ggc_mem, i, m_jit_client_items, m_stack, m_start_time, m_timevars, timer::timevar_def::name, nanosec_to_floating_sec, timer::named_items::print(), print_row(), PRsa, SIZE_AMOUNT, timer::timevar_stack_def::timevar, timevar_accumulate(), TIMEVAR_LAST, timer::timevar_def::used, validate_phases(), and timevar_time_def::wall.
Referenced by toplev::~toplev().
|
staticprivate |
Helper function for timer::print.
References timevar_time_def::ggc_mem, nanosec_to_floating_sec, percent_of, PRsa, SIZE_AMOUNT, and timevar_time_def::wall.
Referenced by print().
void timer::push | ( | timevar_id_t | timevar | ) |
Push TIMEVAR onto the timing stack. No further elapsed time is attributed to the previous topmost timing variable on the stack; subsequent elapsed time is attributed to TIMEVAR, until it is popped or another element is pushed on top. TIMEVAR cannot be running as a standalone timer.
References m_timevars, and push_internal().
Referenced by auto_timevar::auto_timevar(), auto_timevar::auto_timevar(), and timevar_push().
void timer::push_client_item | ( | const char * | item_name | ) |
Push the named item onto the timing stack.
References gcc_assert, m_jit_client_items, named_items, and timer::named_items::push().
|
private |
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.
References timer::timevar_def::elapsed, gcc_assert, get_time(), m_stack, m_start_time, m_unused_stack_instances, timer::timevar_stack_def::next, NULL, timer::timevar_def::standalone, timer::timevar_stack_def::timevar, timevar_accumulate(), and timer::timevar_def::used.
Referenced by push().
void timer::start | ( | timevar_id_t | timevar | ) |
See timevar_start above.
References gcc_assert, get_time(), m_timevars, timer::timevar_def::standalone, timer::timevar_def::start_time, and timer::timevar_def::used.
Referenced by timevar_start().
void timer::stop | ( | timevar_id_t | timevar | ) |
See timevar_stop above.
References timer::timevar_def::elapsed, gcc_assert, get_time(), m_timevars, timer::timevar_def::standalone, timer::timevar_def::start_time, and timevar_accumulate().
Referenced by timevar_stop(), and toplev::~toplev().
|
private |
Validate that phase times are consistent.
References timer::timevar_def::elapsed, gcc_unreachable, timevar_time_def::ggc_mem, m_timevars, timer::timevar_def::name, PRIu64, startswith(), TIMEVAR_LAST, timer::timevar_def::used, and timevar_time_def::wall.
Referenced by print().
|
friend |
Referenced by push_client_item().
|
private |
Referenced by make_json(), pop_client_item(), print(), push_client_item(), and ~timer().
|
private |
Referenced by get_topmost_item_name(), pop(), pop_internal(), print(), push_internal(), and ~timer().
|
private |
Referenced by pop_internal(), print(), and push_internal().
|
private |
Referenced by cond_start(), cond_stop(), make_json(), pop(), print(), push(), start(), stop(), timer(), validate_phases(), and ~timer().
|
private |
Referenced by pop_internal(), push_internal(), and ~timer().