GCC Middle and Back End API Reference
|
#include <optinfo-emit-json.h>
Public Member Functions | |
optrecord_json_writer () | |
~optrecord_json_writer () | |
void | write () const |
void | add_record (const optinfo *optinfo) |
void | pop_scope () |
void | add_record (json::object *obj) |
json::object * | impl_location_to_json (dump_impl_location_t loc) |
json::object * | location_to_json (location_t loc) |
json::object * | profile_count_to_json (profile_count count) |
json::string * | get_id_value_for_pass (opt_pass *pass) |
json::object * | pass_to_json (opt_pass *pass) |
json::value * | inlining_chain_to_json (location_t loc) |
json::object * | optinfo_to_json (const optinfo *optinfo) |
void | add_pass_list (json::array *arr, opt_pass *pass) |
Private Attributes | |
json::array * | m_root_tuple |
auto_vec< json::array * > | m_scopes |
A class for writing out optimization records in JSON format.
optrecord_json_writer::optrecord_json_writer | ( | ) |
Emit optimization information as JSON files. Copyright (C) 2018-2025 Free Software Foundation, Inc. Contributed by David Malcolm <dmalcolm@redhat.com>. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
optrecord_json_writer's ctor. Populate the top-level parts of the in-memory JSON representation.
References GCC_PASS_LISTS, m_root_tuple, m_scopes, lang_hooks::name, NULL, json::object::set(), and json::object::set_string().
optrecord_json_writer::~optrecord_json_writer | ( | ) |
optrecord_json_writer's ctor. Delete the in-memory JSON representation.
References m_root_tuple.
void optrecord_json_writer::add_pass_list | ( | json::array * | arr, |
opt_pass * | pass ) |
Add a json description of PASS and its siblings to ARR, recursing into child passes (adding their descriptions within a "children" array).
References add_pass_list(), json::array::append(), opt_pass::next, pass_to_json(), json::object::set(), and opt_pass::sub.
Referenced by add_pass_list().
void optrecord_json_writer::add_record | ( | const optinfo * | optinfo | ) |
Add a record for OPTINFO to the queue of records to be written.
References add_record(), optinfo::get_kind(), m_scopes, OPTINFO_KIND_SCOPE, optinfo_to_json(), and json::object::set().
Referenced by add_record().
void optrecord_json_writer::add_record | ( | json::object * | obj | ) |
Private methods of optrecord_json_writer.
Add record OBJ to the innermost scope.
References gcc_assert, and m_scopes.
json::string * optrecord_json_writer::get_id_value_for_pass | ( | opt_pass * | pass | ) |
Get a string for use when referring to PASS in the saved optimization records.
References pp_formatted_text(), and pp_pointer.
Referenced by optinfo_to_json(), and pass_to_json().
json::object * optrecord_json_writer::impl_location_to_json | ( | dump_impl_location_t | loc | ) |
Create a JSON object representing LOC.
References dump_impl_location_t::m_file, dump_impl_location_t::m_function, dump_impl_location_t::m_line, json::object::set_integer(), and json::object::set_string().
Referenced by optinfo_to_json().
json::value * optrecord_json_writer::inlining_chain_to_json | ( | location_t | loc | ) |
Create a JSON array for LOC representing the chain of inlining locations. Compare with lhd_print_error_function and cp_print_error_function.
References json::array::append(), BLOCK_ABSTRACT_ORIGIN, BLOCK_SOURCE_LOCATION, BLOCK_SUPERCONTEXT, lang_hooks::decl_printable_name, LOCATION_BLOCK, LOCATION_LOCUS, location_to_json(), NULL, json::object::set(), json::object::set_string(), TREE_CODE, and UNKNOWN_LOCATION.
Referenced by optinfo_to_json().
json::object * optrecord_json_writer::location_to_json | ( | location_t | loc | ) |
Create a JSON object representing LOC.
References expand_location(), gcc_assert, LOCATION_LOCUS, json::object::set_integer(), json::object::set_string(), and UNKNOWN_LOCATION.
Referenced by inlining_chain_to_json(), and optinfo_to_json().
json::object * optrecord_json_writer::optinfo_to_json | ( | const optinfo * | optinfo | ) |
Create a JSON object representing OPTINFO.
References json::array::append(), json::array::append_string(), count, current_function_decl, DECL_ASSEMBLER_NAME, gcc_unreachable, optinfo::get_count(), get_id_value_for_pass(), optinfo::get_impl_location(), optinfo::get_item(), optinfo::get_kind(), optinfo_item::get_kind(), optinfo_item::get_location(), optinfo::get_location_t(), optinfo::get_pass(), get_pure_location(), optinfo_item::get_text(), i, IDENTIFIER_POINTER, impl_location_to_json(), inlining_chain_to_json(), line_table, LOCATION_LOCUS, location_to_json(), optinfo::num_items(), OPTINFO_ITEM_KIND_GIMPLE, OPTINFO_ITEM_KIND_SYMTAB_NODE, OPTINFO_ITEM_KIND_TEXT, OPTINFO_ITEM_KIND_TREE, optinfo_kind_to_string(), profile_count_to_json(), json::object::set(), json::object::set_string(), and UNKNOWN_LOCATION.
Referenced by add_record().
json::object * optrecord_json_writer::pass_to_json | ( | opt_pass * | pass | ) |
Create a JSON object representing PASS.
References json::array::append_string(), gcc_unreachable, get_id_value_for_pass(), GIMPLE_PASS, IPA_PASS, pass_data::name, NULL, OPTGROUP_ALL, optgroup_options, pass_data::optinfo_flags, RTL_PASS, json::object::set(), json::object::set_integer(), json::object::set_string(), SIMPLE_IPA_PASS, opt_pass::static_pass_number, and pass_data::type.
Referenced by add_pass_list().
void optrecord_json_writer::pop_scope | ( | ) |
Pop the innermost scope.
References gcc_assert, and m_scopes.
json::object * optrecord_json_writer::profile_count_to_json | ( | profile_count | count | ) |
Create a JSON object representing COUNT.
References count, profile_quality_as_string(), json::object::set_integer(), and json::object::set_string().
Referenced by optinfo_to_json().
void optrecord_json_writer::write | ( | ) | const |
Choose an appropriate filename, and write the saved records to it.
References error_at(), free(), m_root_tuple, NULL, pp_formatted_text(), and UNKNOWN_LOCATION.
|
private |
Referenced by optrecord_json_writer(), write(), and ~optrecord_json_writer().
|
private |
Referenced by add_record(), add_record(), optrecord_json_writer(), and pop_scope().