GCC Middle and Back End API Reference
timevar.c File Reference
#include "config.h"
#include "system.h"
#include "timevar.h"
#include "timevar.def"
Include dependency graph for timevar.c:

Data Structures

struct  tms
struct  timevar_def
struct  timevar_stack_def

Macros

#define RUSAGE_SELF   0
#define TICKS_PER_SECOND   100 /* often the correct value */
#define GGC_MEM_BOUND   (1 << 20)
#define DEFTIMEVAR(identifier__, name__)   timevars[identifier__].name = name__;

Typedefs

typedef int clock_t

Functions

static void get_time (struct timevar_time_def *)
static void timevar_accumulate (struct timevar_time_def *, struct timevar_time_def *, struct timevar_time_def *)
static void get_time ()
void timevar_init ()
void timevar_push_1 ()
void timevar_pop_1 ()
void timevar_start ()
void timevar_stop ()
bool timevar_cond_start ()
void timevar_cond_stop ()
static void validate_phases ()
void timevar_print ()
void print_time ()

Variables

bool timevar_enable
size_t timevar_ggc_mem_total
static struct timevar_def timevars [TIMEVAR_LAST]
static struct timevar_stack_defstack
static struct timevar_stack_defunused_stack_instances
static struct timevar_time_def start_time

Macro Definition Documentation

#define DEFTIMEVAR (   identifier__,
  name__ 
)    timevars[identifier__].name = name__;
#define GGC_MEM_BOUND   (1 << 20)

The amount of memory that will cause us to report the timevar even if the time spent is not significant.

Referenced by validate_phases().

#define RUSAGE_SELF   0
#define TICKS_PER_SECOND   100 /* often the correct value */

Calculation of scale factor to convert ticks to microseconds. We mustn't use CLOCKS_PER_SEC except with clock().


Typedef Documentation

typedef int clock_t

Timing variables for measuring compiler performance. Copyright (C) 2000-2013 Free Software Foundation, Inc. Contributed by Alex Samuel samue.nosp@m.l@co.nosp@m.desou.nosp@m.rcer.nosp@m.y.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/.


Function Documentation

static void get_time ( struct timevar_time_def )
static
static void get_time ( )
static

Fill the current times into TIME. The definition of this function also defines any or all of the HAVE_USER_TIME, HAVE_SYS_TIME, and HAVE_WALL_TIME macros.

void print_time ( )

Prints a message to stderr stating that time elapsed in STR is TOTAL (given in microseconds).

static void timevar_accumulate ( struct timevar_time_def timer,
struct timevar_time_def start_time,
struct timevar_time_def stop_time 
)
static

Add the difference between STOP_TIME and START_TIME to TIMER.

Referenced by timevar_init(), timevar_stop(), and validate_phases().

bool timevar_cond_start ( )

Conditionally start timing TIMEVAR independently of the timing stack. If the timer is already running, leave it running and return true. Otherwise, start the timer and return false. Elapsed time until the corresponding timevar_cond_stop is called for the same timing variable is attributed to TIMEVAR.

Mark this timing variable as used.

 Don't allow the same timing variable
 to be unconditionally started more than once.   

References timevar_def::elapsed, timevar_time_def::ggc_mem, timevar_def::name, timevar_time_def::sys, timevars, timevar_def::used, timevar_time_def::user, and timevar_time_def::wall.

void timevar_cond_stop ( )

Conditionally stop timing TIMEVAR. The RUNNING parameter must come from the return value of a dynamically matching timevar_cond_start. If the timer had already been RUNNING, do nothing. Otherwise, time elapsed since timevar_cond_start was called is attributed to it.

TIMEVAR must have been started via timevar_cond_start.

References gcc_unreachable, timevar_time_def::ggc_mem, timevar_time_def::sys, timevar_time_def::user, and timevar_time_def::wall.

void timevar_init ( void  )

Initialize timing variables.

 Zero all elapsed times.   
 Initialize the names of timing variables.   

This file contains the definitions for timing variables used to measure run-time performance of the compiler. Copyright (C) 2000-2013 Free Software Foundation, Inc. Contributed by Alex Samuel samue.nosp@m.l@co.nosp@m.desou.nosp@m.rcer.nosp@m.y.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.c.

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. Ideally, they would sum to near the total time.

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.

References timevar_def::elapsed, gcc_assert, get_time(), NULL, timevar_def::standalone, start_time, timevar_stack_def::timevar, timevar_accumulate(), timevars, and timevar_def::used.

void timevar_pop_1 ( )

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.

 What time is it?   
 Attribute the elapsed time to the element we're popping.   
 Reset the start time; from now on, time is attributed to the
 element just exposed on the stack.   
 Take the item off the stack.   
 Don't delete the stack element; instead, add it to the list of
 unused elements for later use.   
void timevar_print ( )

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.

Only print stuff if we have some sort of time information.

void timevar_push_1 ( )

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.

 Mark this timing variable as used.   
 Can't push a standalone timer.   
 What time is it?   
 If the stack isn't empty, attribute the current elapsed time to
 the old topmost element.   
 Reset the start time; from now on, time is attributed to
 TIMEVAR.   
 See if we have a previously-allocated stack instance.  If so,
 take it off the list.  If not, malloc a new one.   
 Fill it in and put it on the stack.   

References timevar_stack_def::next, and unused_stack_instances.

void timevar_start ( )

Start timing TIMEVAR independently of the timing stack. Elapsed time until timevar_stop is called for the same timing variable is attributed to TIMEVAR.

Mark this timing variable as used.

 Don't allow the same timing variable to be started more than
 once.   

References get_time(), timevar_def::standalone, timevar_def::start_time, timevar_enable, timevars, and timevar_def::used.

Referenced by lhd_gimplify_expr().

void timevar_stop ( )

Stop timing TIMEVAR. Time elapsed since timevar_start was called is attributed to it.

TIMEVAR must have been started via timevar_start.

References timevar_def::elapsed, gcc_assert, get_time(), timevar_def::standalone, timevar_def::start_time, timevar_accumulate(), timevar_enable, and timevars.

static void validate_phases ( )
static

Variable Documentation

struct timevar_stack_def* stack
static

The top of the timing stack.

Referenced by dfs_next_edge(), and insert_store().

struct timevar_time_def start_time
static

The time at which the topmost element on the timing stack was pushed. Time elapsed since then is attributed to the topmost element.

Referenced by timevar_init(), and validate_phases().

bool timevar_enable

Prefer times to getrusage to clock (each gives successively less information). libc is very likely to have snuck a call to sysconf() into one of the underlying constants, and that can be very slow, so we have to precompute them. Whose wonderful idea was it to make all those constants variable at run time, anyway? True if timevars should be used. In GCC, this happens with the -ftime-report flag.

Referenced by timevar_start(), timevar_stop(), and validate_phases().

size_t timevar_ggc_mem_total

Total amount of memory allocated by garbage collector.

struct timevar_def timevars[TIMEVAR_LAST]
static

Declared timing variables. Constructed from the contents of timevar.def.

Referenced by timevar_cond_start(), timevar_init(), timevar_start(), timevar_stop(), and validate_phases().

struct timevar_stack_def* unused_stack_instances
static

A list of unused (i.e. allocated and subsequently popped) timevar_stack_def instances.

Referenced by timevar_push_1().