GCC Middle and Back End API Reference
dump_context Class Reference

#include <dump-context.h>

Collaboration diagram for dump_context:

Public Member Functions

 ~dump_context ()
 
void refresh_dumps_are_enabled ()
 
void dump_loc (const dump_metadata_t &metadata, const dump_user_location_t &loc)
 
void dump_loc_immediate (dump_flags_t dump_kind, const dump_user_location_t &loc)
 
void dump_gimple_stmt (const dump_metadata_t &metadata, dump_flags_t extra_dump_flags, gimple *gs, int spc)
 
void dump_gimple_stmt_loc (const dump_metadata_t &metadata, const dump_user_location_t &loc, dump_flags_t extra_dump_flags, gimple *gs, int spc)
 
void dump_gimple_expr (const dump_metadata_t &metadata, dump_flags_t extra_dump_flags, gimple *gs, int spc)
 
void dump_gimple_expr_loc (const dump_metadata_t &metadata, const dump_user_location_t &loc, dump_flags_t extra_dump_flags, gimple *gs, int spc)
 
void dump_generic_expr (const dump_metadata_t &metadata, dump_flags_t extra_dump_flags, tree t)
 
void dump_generic_expr_loc (const dump_metadata_t &metadata, const dump_user_location_t &loc, dump_flags_t extra_dump_flags, tree t)
 
void dump_printf_va (const dump_metadata_t &metadata, const char *format, va_list *ap) ATTRIBUTE_GCC_DUMP_PRINTF(3
 
void void dump_printf_loc_va (const dump_metadata_t &metadata, const dump_user_location_t &loc, const char *format, va_list *ap) ATTRIBUTE_GCC_DUMP_PRINTF(4
 
template<unsigned int N, typename C >
void void void dump_dec (const dump_metadata_t &metadata, const poly_int< N, C > &value)
 
void dump_symtab_node (const dump_metadata_t &metadata, symtab_node *node)
 
unsigned int get_scope_depth () const
 
void begin_scope (const char *name, const dump_user_location_t &user_location, const dump_impl_location_t &impl_location)
 
void end_scope ()
 
bool optinfo_enabled_p () const
 
bool optimization_records_enabled_p () const
 
void set_json_writer (optrecord_json_writer *writer)
 
void finish_any_json_writer ()
 
void end_any_optinfo ()
 
void emit_optinfo (const optinfo *info)
 
void emit_item (optinfo_item *item, dump_flags_t dump_kind)
 
bool apply_dump_filter_p (dump_flags_t dump_kind, dump_flags_t filter) const
 
template<unsigned int N, typename C >
void dump_dec (const dump_metadata_t &metadata, const poly_int< N, C > &value)
 

Static Public Member Functions

static dump_contextget ()
 

Private Member Functions

optinfoensure_pending_optinfo (const dump_metadata_t &metadata)
 
optinfobegin_next_optinfo (const dump_metadata_t &metadata, const dump_user_location_t &loc)
 

Private Attributes

unsigned int m_scope_depth
 
optinfom_pending
 
optrecord_json_writerm_json_writer
 
pretty_printerm_test_pp
 
dump_flags_t m_test_pp_flags
 

Static Private Attributes

static dump_contexts_current = &dump_context::s_default
 
static dump_context s_default
 

Friends

class selftest::temp_dump_context
 
class debug_dump_context
 

Detailed Description

A class for handling the various dump_* calls.

In particular, this class has responsibility for consolidating
the "dump_*" calls into optinfo instances (delimited by "dump_*_loc"
calls), and emitting them.

Putting this in a class (rather than as global state) allows
for selftesting of this code.   

Constructor & Destructor Documentation

◆ ~dump_context()

dump_context::~dump_context ( )
Implementation of dump_context member functions.   
dump_context's dtor.   

References m_pending.

Member Function Documentation

◆ apply_dump_filter_p()

bool dump_context::apply_dump_filter_p ( dump_flags_t dump_kind,
dump_flags_t filter ) const
Determine if a message of kind DUMP_KIND and at the current scope depth
should be printed.

Only show messages that match FILTER both on their kind *and*
their priority.   

References ggc_alloc(), m_scope_depth, MSG_ALL_KINDS, MSG_ALL_PRIORITIES, MSG_PRIORITY_INTERNALS, and MSG_PRIORITY_USER_FACING.

Referenced by begin_scope(), dump_loc_immediate(), and emit_item().

◆ begin_next_optinfo()

optinfo & dump_context::begin_next_optinfo ( const dump_metadata_t & metadata,
const dump_user_location_t & user_loc )
private

◆ begin_scope()

void dump_context::begin_scope ( const char * name,
const dump_user_location_t & user_location,
const dump_impl_location_t & impl_location )
Push a nested dump scope.
Increment the scope depth.
Print "=== NAME ===\n" to the dumpfile, if any, and to the -fopt-info
destination, if any.
Emit a "scope" optinfo if optinfos are enabled.   

References optinfo::add_item(), alt_dump_file, alt_flags, apply_dump_filter_p(), begin_next_optinfo(), dump_file, dump_loc(), emit_item(), end_any_optinfo(), ggc_alloc(), optinfo::m_kind, m_scope_depth, m_test_pp, m_test_pp_flags, MSG_NOTE, optinfo_enabled_p(), OPTINFO_ITEM_KIND_TEXT, OPTINFO_KIND_SCOPE, pflags, pp_formatted_text(), pp_newline(), pp_printf(), and UNKNOWN_LOCATION.

Referenced by dump_begin_scope().

◆ dump_dec() [1/2]

template<unsigned int N, typename C >
void void void dump_context::dump_dec ( const dump_metadata_t & metadata,
const poly_int< N, C > & value )

Referenced by dump_dec().

◆ dump_dec() [2/2]

template<unsigned int N, typename C >
void dump_context::dump_dec ( const dump_metadata_t & metadata,
const poly_int< N, C > & value )

◆ dump_generic_expr()

void dump_context::dump_generic_expr ( const dump_metadata_t & metadata,
dump_flags_t extra_dump_flags,
tree t )
Dump expression tree T using EXTRA_DUMP_FLAGS on dump streams if
DUMP_KIND is enabled.   

References optinfo::add_item(), dump_flags, emit_item(), ensure_pending_optinfo(), dump_metadata_t::get_dump_flags(), ggc_alloc(), make_item_for_dump_generic_expr(), and optinfo_enabled_p().

Referenced by dump_generic_expr(), and dump_generic_expr_loc().

◆ dump_generic_expr_loc()

void dump_context::dump_generic_expr_loc ( const dump_metadata_t & metadata,
const dump_user_location_t & loc,
dump_flags_t extra_dump_flags,
tree t )
Similar to dump_generic_expr, except additionally print the source
location.   

References dump_generic_expr(), dump_loc(), and ggc_alloc().

Referenced by dump_generic_expr_loc().

◆ dump_gimple_expr()

void dump_context::dump_gimple_expr ( const dump_metadata_t & metadata,
dump_flags_t extra_dump_flags,
gimple * gs,
int spc )
Dump gimple statement GS with SPC indentation spaces and
EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled.
Do not terminate with a newline or semicolon.   

References optinfo::add_item(), dump_flags, emit_item(), ensure_pending_optinfo(), dump_metadata_t::get_dump_flags(), ggc_alloc(), make_item_for_dump_gimple_expr(), and optinfo_enabled_p().

Referenced by dump_gimple_expr(), and dump_gimple_expr_loc().

◆ dump_gimple_expr_loc()

void dump_context::dump_gimple_expr_loc ( const dump_metadata_t & metadata,
const dump_user_location_t & loc,
dump_flags_t extra_dump_flags,
gimple * gs,
int spc )
Similar to dump_gimple_expr, except additionally print source location.   

References dump_gimple_expr(), dump_loc(), and ggc_alloc().

Referenced by dump_gimple_expr_loc().

◆ dump_gimple_stmt()

void dump_context::dump_gimple_stmt ( const dump_metadata_t & metadata,
dump_flags_t extra_dump_flags,
gimple * gs,
int spc )
Dump gimple statement GS with SPC indentation spaces and
EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled.   

References optinfo::add_item(), dump_flags, emit_item(), ensure_pending_optinfo(), dump_metadata_t::get_dump_flags(), ggc_alloc(), make_item_for_dump_gimple_stmt(), and optinfo_enabled_p().

Referenced by dump_gimple_stmt(), and dump_gimple_stmt_loc().

◆ dump_gimple_stmt_loc()

void dump_context::dump_gimple_stmt_loc ( const dump_metadata_t & metadata,
const dump_user_location_t & loc,
dump_flags_t extra_dump_flags,
gimple * gs,
int spc )
Similar to dump_gimple_stmt, except additionally print source location.   

References dump_gimple_stmt(), dump_loc(), and ggc_alloc().

Referenced by dump_gimple_stmt_loc().

◆ dump_loc()

void dump_context::dump_loc ( const dump_metadata_t & metadata,
const dump_user_location_t & loc )

◆ dump_loc_immediate()

void dump_context::dump_loc_immediate ( dump_flags_t dump_kind,
const dump_user_location_t & loc )

◆ dump_printf_loc_va()

void dump_context::dump_printf_loc_va ( const dump_metadata_t & metadata,
const dump_user_location_t & loc,
const char * format,
va_list * ap )
Similar to dump_printf, except source location is also printed, and
dump location captured.   

References ap, dump_loc(), and dump_printf_va().

Referenced by dump_printf_loc().

◆ dump_printf_va()

void dump_context::dump_printf_va ( const dump_metadata_t & metadata,
const char * format,
va_list * ap )
Output a formatted message using FORMAT on appropriate dump streams.   

References ap, dump_pretty_printer::emit_items(), ensure_pending_optinfo(), errno, dump_metadata_t::get_dump_flags(), ggc_alloc(), NULL, optinfo_enabled_p(), and pp_format().

Referenced by dump_printf(), and dump_printf_loc_va().

◆ dump_symtab_node()

void dump_context::dump_symtab_node ( const dump_metadata_t & metadata,
symtab_node * node )

◆ emit_item()

void dump_context::emit_item ( optinfo_item * item,
dump_flags_t dump_kind )

◆ emit_optinfo()

void dump_context::emit_optinfo ( const optinfo * info)
Emit the optinfo to all of the "non-immediate" destinations
(emission to "immediate" destinations is done by
dump_context::emit_item).   

References optrecord_json_writer::add_record(), and m_json_writer.

Referenced by optinfo::emit_for_opt_problem(), and end_any_optinfo().

◆ end_any_optinfo()

void dump_context::end_any_optinfo ( )
End any optinfo that has been accumulated within this context; emitting
it to any destinations as appropriate, such as optimization records.   

References emit_optinfo(), m_pending, and NULL.

Referenced by begin_next_optinfo(), begin_scope(), dump_loc(), dumpfile_ensure_any_optinfo_are_flushed(), and end_scope().

◆ end_scope()

void dump_context::end_scope ( )
Pop a nested dump scope.   

References end_any_optinfo(), m_json_writer, m_scope_depth, and optrecord_json_writer::pop_scope().

Referenced by dump_end_scope().

◆ ensure_pending_optinfo()

optinfo & dump_context::ensure_pending_optinfo ( const dump_metadata_t & metadata)
private
Return the optinfo currently being accumulated, creating one if
necessary.   

References begin_next_optinfo(), and m_pending.

Referenced by dump_dec(), dump_generic_expr(), dump_gimple_expr(), dump_gimple_stmt(), dump_printf_va(), and dump_symtab_node().

◆ finish_any_json_writer()

void dump_context::finish_any_json_writer ( )
Perform cleanup activity for -fsave-optimization-record.
Currently, the file is written out here in one go, before cleaning
up.   

References m_json_writer, NULL, and optrecord_json_writer::write().

Referenced by compile_file().

◆ get()

◆ get_scope_depth()

unsigned int dump_context::get_scope_depth ( ) const
Get the current dump scope-nesting depth.
For use by -fopt-info (for showing nesting via indentation).   

References m_scope_depth.

Referenced by get_dump_scope_depth().

◆ optimization_records_enabled_p()

bool dump_context::optimization_records_enabled_p ( ) const
inline

◆ optinfo_enabled_p()

bool dump_context::optinfo_enabled_p ( ) const
Should optinfo instances be created?
All creation of optinfos should be guarded by this predicate.
Return true if any optinfo destinations are active.   

References optimization_records_enabled_p().

Referenced by begin_scope(), dump_dec(), dump_generic_expr(), dump_gimple_expr(), dump_gimple_stmt(), dump_loc(), dump_printf_va(), dump_symtab_node(), and refresh_dumps_are_enabled().

◆ refresh_dumps_are_enabled()

void dump_context::refresh_dumps_are_enabled ( )
Update the "dumps_are_enabled" global; to be called whenever dump_file
or alt_dump_file change, or when changing dump_context in selftests.   

References alt_dump_file, dump_file, dumps_are_enabled, m_test_pp, and optinfo_enabled_p().

Referenced by debug_dump_context::debug_dump_context(), set_alt_dump_file(), set_dump_file(), and debug_dump_context::~debug_dump_context().

◆ set_json_writer()

void dump_context::set_json_writer ( optrecord_json_writer * writer)

References ggc_alloc(), and m_json_writer.

Referenced by do_compile().

Friends And Related Symbol Documentation

◆ debug_dump_context

◆ selftest::temp_dump_context

friend class selftest::temp_dump_context
friend

Field Documentation

◆ m_json_writer

◆ m_pending

optinfo* dump_context::m_pending
private

◆ m_scope_depth

unsigned int dump_context::m_scope_depth
private

◆ m_test_pp

pretty_printer* dump_context::m_test_pp
private

◆ m_test_pp_flags

dump_flags_t dump_context::m_test_pp_flags
private

◆ s_current

dump_context * dump_context::s_current = &dump_context::s_default
staticprivate
The current singleton dump_context, and its default.   

Referenced by debug_dump_context::debug_dump_context(), get(), and debug_dump_context::~debug_dump_context().

◆ s_default

dump_context dump_context::s_default
staticprivate

The documentation for this class was generated from the following files: