aboutsummaryrefslogtreecommitdiff
path: root/gcc/toplev.c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2018-07-20 15:37:23 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2018-07-20 15:37:23 +0000
commit4a4412b9de23b153481a60cd69abcee71c3e34fb (patch)
treebfca81ed27910bef95adb2304ad0b3e69af27dd2 /gcc/toplev.c
parentbf0086f1c8ff9998fb55a27f6606bccbba873e09 (diff)
downloadgcc-4a4412b9de23b153481a60cd69abcee71c3e34fb.zip
gcc-4a4412b9de23b153481a60cd69abcee71c3e34fb.tar.gz
gcc-4a4412b9de23b153481a60cd69abcee71c3e34fb.tar.bz2
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. From-SVN: r262905
Diffstat (limited to 'gcc/toplev.c')
-rw-r--r--gcc/toplev.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 1fb8fcc..8908105 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -83,6 +83,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree-pass.h"
#include "dumpfile.h"
#include "ipa-fnsummary.h"
+#include "optinfo-emit-json.h"
#if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
#include "dbxout.h"
@@ -487,6 +488,8 @@ compile_file (void)
if (lang_hooks.decls.post_compilation_parsing_cleanups)
lang_hooks.decls.post_compilation_parsing_cleanups ();
+ optimization_records_finish ();
+
if (seen_error ())
return;
@@ -2118,6 +2121,8 @@ do_compile ()
timevar_start (TV_PHASE_SETUP);
+ optimization_records_start ();
+
/* This must be run always, because it is needed to compute the FP
predefined macros, such as __LDBL_MAX__, for targets using non
default FP formats. */