This is the mail archive of the gcc-cvs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

r263178 - in /trunk/gcc: ChangeLog dump-context...


Author: dmalcolm
Date: Tue Jul 31 19:22:48 2018
New Revision: 263178

URL: https://gcc.gnu.org/viewcvs?rev=263178&root=gcc&view=rev
Log:
dumpfile.c: eliminate special-casing of dump_file/alt_dump_file

With the addition of optinfo, the various dump_* calls had three parts:
- optionally print to dump_file
- optionally print to alt_dump_file
- optionally make an optinfo_item and add it to the pending optinfo,
  creating it for dump_*_loc calls.

However, this split makes it difficult to implement the formatted dumps
later in patch kit, so as enabling work towards that, this patch removes
the above split, so that all dumping within the dump_* API goes through
optinfo_item.

In order to ensure that the dumps to dump_file and alt_dump_file are
processed immediately (rather than being buffered within the pending
optinfo for consolidation), this patch introduces the idea of "immediate"
optinfo_item destinations vs "non-immediate" destinations.

The patch also adds selftest coverage of what's printed, and of scopes.

This adds two allocations per dump_* call when dumping is enabled.
I'm assuming that this isn't a problem, as dump_enabled_p is normally
false.  There are ways of optimizing it if it is an issue (by making
optinfo_item instances become temporaries that borrow the underlying
buffer), but they require nontrivial changes, so I'd prefer to leave
that for another patch kit, if it becomes necessary.

gcc/ChangeLog:
	* dump-context.h: Include "pretty-print.h".
	(dump_context::refresh_dumps_are_enabled): New decl.
	(dump_context::emit_item): New decl.
	(class dump_context): Add fields "m_test_pp" and
	"m_test_pp_flags".
	(temp_dump_context::temp_dump_context): Add param "test_pp_flags".
	(temp_dump_context::get_dumped_text): New decl.
	(class temp_dump_context): Add field "m_pp".
	* dumpfile.c (refresh_dumps_are_enabled): Convert to...
	(dump_context::refresh_dumps_are_enabled): ...and add a test for
	m_test_pp.
	(set_dump_file): Update for above change.
	(set_alt_dump_file): Likewise.
	(dump_loc): New overload, taking a pretty_printer *.
	(dump_context::dump_loc): Call end_any_optinfo.  Dump the location
	to any test pretty-printer.
	(make_item_for_dump_gimple_stmt): New function, adapted from
	optinfo::add_gimple_stmt.
	(dump_context::dump_gimple_stmt): Call it, and use the result,
	eliminating the direct usage of dump_file and alt_dump_file in
	favor of indirectly using them via emit_item.
	(make_item_for_dump_gimple_expr): New function, adapted from
	optinfo::add_gimple_expr.
	(dump_context::dump_gimple_expr): Call it, and use the result,
	eliminating the direct usage of dump_file and alt_dump_file in
	favor of indirectly using them via emit_item.
	(make_item_for_dump_generic_expr): New function, adapted from
	optinfo::add_tree.
	(dump_context::dump_generic_expr): Call it, and use the result,
	eliminating the direct usage of dump_file and alt_dump_file in
	favor of indirectly using them via emit_item.
	(make_item_for_dump_printf_va): New function, adapted from
	optinfo::add_printf_va.
	(make_item_for_dump_printf): New function.
	(dump_context::dump_printf_va): Call make_item_for_dump_printf_va,
	and use the result, eliminating the direct usage of dump_file and
	alt_dump_file in favor of indirectly using them via emit_item.
	(make_item_for_dump_dec): New function.
	(dump_context::dump_dec): Call it, and use the result,
	eliminating the direct usage of dump_file and alt_dump_file in
	favor of indirectly using them via emit_item.
	(make_item_for_dump_symtab_node): New function, adapted from
	optinfo::add_symtab_node.
	(dump_context::dump_symtab_node): Call it, and use the result,
	eliminating the direct usage of dump_file and alt_dump_file in
	favor of indirectly using them via emit_item.
	(dump_context::begin_scope): Reimplement, avoiding direct usage
	of dump_file and alt_dump_file in favor of indirectly using them
	via emit_item.
	(dump_context::emit_item): New member function.
	(temp_dump_context::temp_dump_context): Add param "test_pp_flags".
	Set up test pretty-printer on the underlying context.  Call
	refresh_dumps_are_enabled.
	(temp_dump_context::~temp_dump_context): Call
	refresh_dumps_are_enabled.
	(temp_dump_context::get_dumped_text): New member function.
	(selftest::verify_dumped_text): New function.
	(ASSERT_DUMPED_TEXT_EQ): New macro.
	(selftest::test_capture_of_dump_calls): Run all tests twice, with
	and then without optinfo enabled.  Add uses of
	ASSERT_DUMPED_TEXT_EQ to all tests.  Add test of nested scopes.
	* dumpfile.h: Update comment for the dump_* API.
	* optinfo-emit-json.cc
	(selftest::test_building_json_from_dump_calls): Update for new
	param for temp_dump_context ctor.
	* optinfo.cc (optinfo_item::optinfo_item): Remove "owned" param
	and "m_owned" field.
	(optinfo_item::~optinfo_item): Likewise.
	(optinfo::add_item): New member function.
	(optinfo::emit): Update comment.
	(optinfo::add_string): Delete.
	(optinfo::add_printf): Delete.
	(optinfo::add_printf_va): Delete.
	(optinfo::add_gimple_stmt): Delete.
	(optinfo::add_gimple_expr): Delete.
	(optinfo::add_tree): Delete.
	(optinfo::add_symtab_node): Delete.
	(optinfo::add_dec): Delete.
	* optinfo.h (class dump_context): New forward decl.
	(optinfo::add_item): New decl.
	(optinfo::add_string): Delete.
	(optinfo::add_printf): Delete.
	(optinfo::add_printf_va): Delete.
	(optinfo::add_gimple_stmt): Delete.
	(optinfo::add_gimple_expr): Delete.
	(optinfo::add_tree): Delete.
	(optinfo::add_symtab_node): Delete.
	(optinfo::add_dec): Delete.
	(optinfo::add_poly_int): Delete.
	(optinfo_item::optinfo_item): Remove "owned" param.
	(class optinfo_item): Remove field "m_owned".


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dump-context.h
    trunk/gcc/dumpfile.c
    trunk/gcc/dumpfile.h
    trunk/gcc/optinfo-emit-json.cc
    trunk/gcc/optinfo.cc
    trunk/gcc/optinfo.h


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]