Add "-fsave-optimization-record"
commit9dcf2a1144cf0a703dc020f4880912ed86e6183b
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 20 Jul 2018 15:37:23 +0000 (20 15:37 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 20 Jul 2018 15:37:23 +0000 (20 15:37 +0000)
treebfca81ed27910bef95adb2304ad0b3e69af27dd2
parent3052e4ec519e4f5456ab63f4954ae098524316ce
Add "-fsave-optimization-record"

This patch implements a -fsave-optimization-record option, which
leads to a JSON file being written out, recording the dump_* calls
made (via the optinfo infrastructure).

The patch includes a minimal version of the JSON patch I posted last
year, with just enough support needed for optimization records (I
removed all of the parser code, leaving just the code for building
in-memory JSON trees and writing them to a pretty_printer).

gcc/ChangeLog:
* Makefile.in (OBJS): Add json.o and optinfo-emit-json.o.
(CFLAGS-optinfo-emit-json.o): Define TARGET_NAME.
* common.opt (fsave-optimization-record): New option.
* coretypes.h (struct kv_pair): Move here from dumpfile.c.
* doc/invoke.texi (-fsave-optimization-record): New option.
* dumpfile.c: Include "optinfo-emit-json.h".
(struct kv_pair): Move to coretypes.h.
(optgroup_options): Make non-static.
(dump_context::end_scope): Call
optimization_records_maybe_pop_dump_scope.
* dumpfile.h (optgroup_options): New decl.
* json.cc: New file.
* json.h: New file.
* optinfo-emit-json.cc: New file.
* optinfo-emit-json.h: New file.
* optinfo.cc: Include "optinfo-emit-json.h".
(optinfo::emit): Call optimization_records_maybe_record_optinfo.
(optinfo_enabled_p): Check optimization_records_enabled_p.
(optinfo_wants_inlining_info_p): Likewise.
* optinfo.h: Update comment.
* profile-count.c (profile_quality_as_string): New function.
* profile-count.h (profile_quality_as_string): New decl.
(profile_count::quality): New accessor.
* selftest-run-tests.c (selftest::run_tests): Call json_cc_tests
and optinfo_emit_json_cc_tests.
* selftest.h (selftest::json_cc_tests): New decl.
(selftest::optinfo_emit_json_cc_tests): New decl.
* toplev.c: Include "optinfo-emit-json.h".
(compile_file): Call optimization_records_finish.
(do_compile): Call optimization_records_start.
* tree-ssa-live.c: Include optinfo.h.
(remove_unused_scope_block_p): Retain inlining information if
optinfo_wants_inlining_info_p returns true.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@262905 138bc75d-0d04-0410-961f-82ee72b054a4
19 files changed:
gcc/ChangeLog
gcc/Makefile.in
gcc/common.opt
gcc/coretypes.h
gcc/doc/invoke.texi
gcc/dumpfile.c
gcc/dumpfile.h
gcc/json.cc [new file with mode: 0644]
gcc/json.h [new file with mode: 0644]
gcc/optinfo-emit-json.cc [new file with mode: 0644]
gcc/optinfo-emit-json.h [new file with mode: 0644]
gcc/optinfo.cc
gcc/optinfo.h
gcc/profile-count.c
gcc/profile-count.h
gcc/selftest-run-tests.c
gcc/selftest.h
gcc/toplev.c
gcc/tree-ssa-live.c