diff options
author | David Malcolm <dmalcolm@redhat.com> | 2018-07-19 20:49:25 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2018-07-19 20:49:25 +0000 |
commit | 4df3629eb775ef9a4578c0bed3194565ca30e690 (patch) | |
tree | 6a3d9241b9f22c4142966a40b77cd934a1fc00e3 /gcc/dumpfile.h | |
parent | 30c460535576882863fe4e0db740b4ac4bcfaba9 (diff) | |
download | gcc-4df3629eb775ef9a4578c0bed3194565ca30e690.zip gcc-4df3629eb775ef9a4578c0bed3194565ca30e690.tar.gz gcc-4df3629eb775ef9a4578c0bed3194565ca30e690.tar.bz2 |
Add "optinfo" framework
This patch implements a way to consolidate dump_* calls into
optinfo objects, as enabling work towards being able to write out
optimization records to a file.
The patch adds the support for building optinfo instances from dump_*
calls, but leaves implementing any *users* of them to followup patches.
gcc/ChangeLog:
* Makefile.in (OBJS): Add optinfo.o.
* coretypes.h (class symtab_node): New forward decl.
(struct cgraph_node): New forward decl.
(class varpool_node): New forward decl.
* dump-context.h: New file.
* dumpfile.c: Include "optinfo.h", "dump-context.h", "cgraph.h",
"tree-pass.h".
(refresh_dumps_are_enabled): Use optinfo_enabled_p.
(set_dump_file): Call dumpfile_ensure_any_optinfo_are_flushed.
(set_alt_dump_file): Likewise.
(dump_context::~dump_context): New dtor.
(dump_gimple_stmt): Move implementation to...
(dump_context::dump_gimple_stmt): ...this new member function.
Add the stmt to any pending optinfo, creating one if need be.
(dump_gimple_stmt_loc): Move implementation to...
(dump_context::dump_gimple_stmt_loc): ...this new member function.
Start a new optinfo and add the stmt to it.
(dump_gimple_expr): Move implementation to...
(dump_context::dump_gimple_expr): ...this new member function.
Add the stmt to any pending optinfo, creating one if need be.
(dump_gimple_expr_loc): Move implementation to...
(dump_context::dump_gimple_expr_loc): ...this new member function.
Start a new optinfo and add the stmt to it.
(dump_generic_expr): Move implementation to...
(dump_context::dump_generic_expr): ...this new member function.
Add the tree to any pending optinfo, creating one if need be.
(dump_generic_expr_loc): Move implementation to...
(dump_context::dump_generic_expr_loc): ...this new member
function. Add the tree to any pending optinfo, creating one if
need be.
(dump_printf): Move implementation to...
(dump_context::dump_printf_va): ...this new member function. Add
the text to any pending optinfo, creating one if need be.
(dump_printf_loc): Move implementation to...
(dump_context::dump_printf_loc_va): ...this new member function.
Start a new optinfo and add the stmt to it.
(dump_dec): Move implementation to...
(dump_context::dump_dec): ...this new member function. Add the
value to any pending optinfo, creating one if need be.
(dump_context::dump_symtab_node): New member function.
(dump_context::get_scope_depth): New member function.
(dump_context::begin_scope): New member function.
(dump_context::end_scope): New member function.
(dump_context::ensure_pending_optinfo): New member function.
(dump_context::begin_next_optinfo): New member function.
(dump_context::end_any_optinfo): New member function.
(dump_context::s_current): New global.
(dump_context::s_default): New global.
(dump_scope_depth): Delete global.
(dumpfile_ensure_any_optinfo_are_flushed): New function.
(dump_symtab_node): New function.
(get_dump_scope_depth): Reimplement in terms of dump_context.
(dump_begin_scope): Likewise.
(dump_end_scope): Likewise.
(selftest::temp_dump_context::temp_dump_context): New ctor.
(selftest::temp_dump_context::~temp_dump_context): New dtor.
(selftest::verify_item): New function.
(ASSERT_IS_TEXT): New macro.
(ASSERT_IS_TREE): New macro.
(ASSERT_IS_GIMPLE): New macro.
(selftest::test_capture_of_dump_calls): New test.
(selftest::dumpfile_c_tests): Call it.
* dumpfile.h (dump_printf, dump_printf_loc, dump_basic_block)
(dump_generic_expr_loc, dump_generic_expr, dump_gimple_stmt_loc)
(dump_gimple_stmt, dump_dec): Gather these related decls and add a
descriptive comment.
(dump_function, print_combine_total_stats, enable_rtl_dump_file)
(dump_node, dump_bb): Move these unrelated decls.
(class dump_manager): Add leading comment.
* optinfo.cc: New file.
* optinfo.h: New file.
From-SVN: r262891
Diffstat (limited to 'gcc/dumpfile.h')
-rw-r--r-- | gcc/dumpfile.h | 84 |
1 files changed, 59 insertions, 25 deletions
diff --git a/gcc/dumpfile.h b/gcc/dumpfile.h index 40e3332..558351d 100644 --- a/gcc/dumpfile.h +++ b/gcc/dumpfile.h @@ -420,6 +420,48 @@ extern FILE *dump_begin (int, dump_flags_t *, int part=-1); extern void dump_end (int, FILE *); extern int opt_info_switch_p (const char *); extern const char *dump_flag_name (int); + +/* Global variables used to communicate with passes. */ +extern FILE *dump_file; +extern dump_flags_t dump_flags; +extern const char *dump_file_name; + +extern bool dumps_are_enabled; + +extern void set_dump_file (FILE *new_dump_file); + +/* Return true if any of the dumps is enabled, false otherwise. */ +static inline bool +dump_enabled_p (void) +{ + return dumps_are_enabled; +} + +/* The following API calls (which *don't* take a "FILE *") + write the output to zero or more locations: + (a) the active dump_file, if any + (b) the -fopt-info destination, if any + (c) to the "optinfo" destinations, if any: + + dump_* (MSG_*) --> dumpfile.c --+--> (a) dump_file + | + +--> (b) alt_dump_file + | + `--> (c) optinfo + `---> optinfo destinations + + For optinfos, the dump_*_loc mark the beginning of an optinfo + instance: all subsequent dump_* calls are consolidated into + that optinfo, until the next dump_*_loc call (or a change in + dump scope, or a call to dumpfile_ensure_any_optinfo_are_flushed). + + A group of dump_* calls should be guarded by: + + if (dump_enabled_p ()) + + to minimize the work done for the common case where dumps + are disabled. */ + extern void dump_printf (dump_flags_t, const char *, ...) ATTRIBUTE_PRINTF_2; extern void dump_printf_loc (dump_flags_t, const dump_location_t &, const char *, ...) ATTRIBUTE_PRINTF_3; @@ -434,37 +476,14 @@ extern void dump_gimple_stmt (dump_flags_t, dump_flags_t, gimple *, int); extern void dump_gimple_expr_loc (dump_flags_t, const dump_location_t &, dump_flags_t, gimple *, int); extern void dump_gimple_expr (dump_flags_t, dump_flags_t, gimple *, int); -extern void print_combine_total_stats (void); -extern bool enable_rtl_dump_file (void); +extern void dump_symtab_node (dump_flags_t, symtab_node *); template<unsigned int N, typename C> void dump_dec (dump_flags_t, const poly_int<N, C> &); extern void dump_dec (dump_flags_t, const poly_wide_int &, signop); extern void dump_hex (dump_flags_t, const poly_wide_int &); -/* In tree-dump.c */ -extern void dump_node (const_tree, dump_flags_t, FILE *); - -/* In combine.c */ -extern void dump_combine_total_stats (FILE *); -/* In cfghooks.c */ -extern void dump_bb (FILE *, basic_block, int, dump_flags_t); - -/* Global variables used to communicate with passes. */ -extern FILE *dump_file; -extern dump_flags_t dump_flags; -extern const char *dump_file_name; - -extern bool dumps_are_enabled; - -extern void set_dump_file (FILE *new_dump_file); - -/* Return true if any of the dumps is enabled, false otherwise. */ -static inline bool -dump_enabled_p (void) -{ - return dumps_are_enabled; -} +extern void dumpfile_ensure_any_optinfo_are_flushed (); /* Managing nested scopes, so that dumps can express the call chain leading to a dump message. */ @@ -505,8 +524,23 @@ class auto_dump_scope #define AUTO_DUMP_SCOPE(NAME, LOC) \ auto_dump_scope scope (NAME, LOC) +extern void dump_function (int phase, tree fn); +extern void print_combine_total_stats (void); +extern bool enable_rtl_dump_file (void); + +/* In tree-dump.c */ +extern void dump_node (const_tree, dump_flags_t, FILE *); + +/* In combine.c */ +extern void dump_combine_total_stats (FILE *); +/* In cfghooks.c */ +extern void dump_bb (FILE *, basic_block, int, dump_flags_t); + namespace gcc { +/* A class for managing all of the various dump files used by the + optimization passes. */ + class dump_manager { public: |