aboutsummaryrefslogtreecommitdiff
path: root/gcc/timevar.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2015-08-03 20:14:21 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2015-08-03 20:14:21 +0000
commitafed345982d5923b04d41885e868c9ca345ff3f9 (patch)
treeb90c7df0235fa14daf2c76f22203ee08c2c32bcb /gcc/timevar.h
parentef9da28d8fa1e2c0dc890f87374c0f21b18430c3 (diff)
downloadgcc-afed345982d5923b04d41885e868c9ca345ff3f9.zip
gcc-afed345982d5923b04d41885e868c9ca345ff3f9.tar.gz
gcc-afed345982d5923b04d41885e868c9ca345ff3f9.tar.bz2
Refactoring of timevar API
gcc/ChangeLog: * main.c (main): Pass in NULL for toplev's external_timer. * timevar.c: Include coretypes.h. (class timer::named_items): New. (timer::named_items::named_items): New. (timer::named_items::~named_items): New. (timer::named_items::push): New. (timer::named_items::pop): New. (timer::named_items::print): New. (timer::timer): Initialize field "m_jit_client_items". (timer::~timer): New. (timer::push): Move bulk of implementation to... (timer::push_internal): ...here. New function. (timer::pop): Move bulk of implementation to... (timer::pop_internal): ...here. New function. (timer::push_client_item): New. (timer::pop_client_item): New. (timer::print_row): New function, taken from timer::print. (timer::print): Print "GCC items" header if we also have client items. Move row-printing to timer::print_row. Print any client items. (timer::get_topmost_item_name): New method. * timevar.def (TV_JIT_ACQUIRING_MUTEX): New. (TV_JIT_CLIENT_CODE): New. * timevar.h (timer::push_client_item): New declaration. (timer::pop_client_item): New declaration. (timer::get_topmost_item_name): New method. (timer::push_internal): New declaration. (timer::pop_internal): New declaration. (timer::print_row): New declaration. (timer::named_items): New declaration. (timer::m_jit_client_items): New field. (timer): Add friend class named_items. (auto_timevar::auto_timevar): Add timer param. (auto_timevar::~auto_timevar): Use field "m_timer". (auto_timevar::m_timer): New field. * toplev.c (initialize_rtl): Add g_timer as param when constructing auto_timevar instance. (toplev::toplev): Add "external_timer" param, and use it to initialize the "g_timer" global if non-NULL. (toplev::~toplev): If this created "g_timer", delete it. * toplev.h (toplev::toplev): Replace "use_TV_TOTAL" bool param with "external_timer" timer *. gcc/jit/ChangeLog: * docs/topics/compatibility.rst (LIBGCCJIT_ABI_4): New. * docs/topics/contexts.rst (GCC_JIT_BOOL_OPTION_DUMP_SUMMARY): We no longer show a profile. * docs/topics/index.rst (Topic Reference): Add performance.rst. * docs/topics/performance.rst: New file. * docs/_build/texinfo/libgccjit.texi: Regenerate. * jit-playback.c (gcc::jit::playback::context::compile): Add timer param when constructing the "toplev" instance. (gcc::jit::playback::context::acquire_mutex): Add timer param when constructing auto_timevar instance. (gcc::jit::playback::context::make_fake_args): If we have a timer, add "-ftime-report". (gcc::jit::playback::context::invoke_driver): Add timer param when constructing auto_timevar instance. (gcc::jit::playback::context::dlopen_built_dso): Likewise. * jit-playback.h (gcc::jit::playback::context::get_timer): New accessor. * jit-recording.c: Include timevar.h. (gcc::jit::recording::context::context): Initialize field "m_timer". * jit-recording.h: Add forward declaration of class timer. (gcc::jit::recording::context::set_timer): New method. (gcc::jit::recording::context::get_timer): New method. (gcc::jit::recording::context::m_timer): New field. * libgccjit++.h (gccjit::timer): New class. (gccjit::auto_time): New class. (gccjit::context::set_timer): New method. (gccjit::context::get_timer): New. (gccjit::timer::timer): New. (gccjit::timer::push): New. (gccjit::timer::pop): New. (timer::print): New. (timer::get_inner_timer): New. (timer::release): New. (auto_time::auto_time): New. (auto_time::~auto_time): New. * libgccjit.c: Include timevar.h. (struct gcc_jit_timer): New. (gcc_jit_timer_new): New function. (gcc_jit_timer_release): New function. (gcc_jit_context_set_timer): New function. (gcc_jit_context_get_timer): New function. (gcc_jit_timer_push): New function. (gcc_jit_timer_pop): New function. (gcc_jit_timer_print): New function. * libgccjit.h (LIBGCCJIT_HAVE_TIMING_API): New macro. (gcc_jit_timer): New typedef. (gcc_jit_timer_new): New function. (gcc_jit_timer_release): New function. (gcc_jit_context_set_timer): New function. (gcc_jit_context_get_timer): New function. (gcc_jit_timer_push): New function. (gcc_jit_timer_pop): New function. (gcc_jit_timer_print): New function. * libgccjit.map (LIBGCCJIT_ABI_4): New. (gcc_jit_timer_new): New function. (gcc_jit_timer_release): New function. (gcc_jit_context_set_timer): New function. (gcc_jit_context_get_timer): New function. (gcc_jit_timer_push): New function. (gcc_jit_timer_pop): New function. (gcc_jit_timer_print): New function. gcc/testsuite/ChangeLog: * jit.dg/test-benchmark.c (test_jit): Add param "timer" and use it to push/pop timing items. (main): For each optimization level, create a gcc_jit_timer, and time all of the iteration within that level cumulatively. * jit.dg/test-error-gcc_jit_timer_pop-mismatch.c: New test case. * jit.dg/test-error-gcc_jit_timer_pop-too-many.c: New test case. From-SVN: r226530
Diffstat (limited to 'gcc/timevar.h')
-rw-r--r--gcc/timevar.h35
1 files changed, 31 insertions, 4 deletions
diff --git a/gcc/timevar.h b/gcc/timevar.h
index 71a814a..85c7610 100644
--- a/gcc/timevar.h
+++ b/gcc/timevar.h
@@ -115,12 +115,24 @@ class timer
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);
+ const char *get_topmost_item_name () const;
+
private:
/* Private member functions. */
void validate_phases (FILE *fp) const;
+ struct timevar_def;
+ void push_internal (struct timevar_def *tv);
+ void pop_internal ();
+ static void print_row (FILE *fp,
+ const timevar_time_def *total,
+ const timevar_def *tv);
+
private:
/* Private type: a timing variable. */
@@ -157,6 +169,12 @@ class timer
struct timevar_stack_def *next;
};
+ /* A class for managing a collection of named timing items, for use
+ e.g. by libgccjit for timing client code. This class is declared
+ inside timevar.c to avoid everything using timevar.h
+ from needing vec and hash_map. */
+ class named_items;
+
private:
/* Data members (all private). */
@@ -176,6 +194,11 @@ class timer
pushed. Time elapsed since then is attributed to the topmost
element. */
timevar_time_def m_start_time;
+
+ /* If non-NULL, for use when timing libgccjit's client code. */
+ named_items *m_jit_client_items;
+
+ friend class named_items;
};
/* Provided for backward compatibility. */
@@ -198,15 +221,18 @@ timevar_pop (timevar_id_t tv)
class auto_timevar
{
public:
- auto_timevar (timevar_id_t tv)
- : m_tv (tv)
+ auto_timevar (timer *t, timevar_id_t tv)
+ : m_timer (t),
+ m_tv (tv)
{
- timevar_push (m_tv);
+ if (m_timer)
+ m_timer->push (m_tv);
}
~auto_timevar ()
{
- timevar_pop (m_tv);
+ if (m_timer)
+ m_timer->pop (m_tv);
}
private:
@@ -214,6 +240,7 @@ class auto_timevar
// Private to disallow copies.
auto_timevar (const auto_timevar &);
+ timer *m_timer;
timevar_id_t m_tv;
};