aboutsummaryrefslogtreecommitdiff
path: root/gcc/dumpfile.c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2018-11-13 16:10:13 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2018-11-13 16:10:13 +0000
commitbbeeac91f96bdcbc3eb40ec68c1fd8cf5d4a038d (patch)
tree14626efce8213f765013cedf40bc8ad860ab9c9b /gcc/dumpfile.c
parent9228f64cc2ceb54764a302103e3b754c0b6235a2 (diff)
downloadgcc-bbeeac91f96bdcbc3eb40ec68c1fd8cf5d4a038d.zip
gcc-bbeeac91f96bdcbc3eb40ec68c1fd8cf5d4a038d.tar.gz
gcc-bbeeac91f96bdcbc3eb40ec68c1fd8cf5d4a038d.tar.bz2
Ensure that dump calls are guarded with dump_enabled_p
If called when !dump_enabled_p, the dump_* functions effectively do nothing, but as of r263178 this doing "nothing" involves non-trivial work internally. I wasn't sure whether the dump_* functions should assert that dump_enabled_p () is true when they're called, or if they should bail out immediately for this case, so in this patch I implemented both, so that we get an assertion failure, and otherwise bail out for the case where !dump_enabled_p when assertions are disabled. The patch also fixes all of the places I found during testing (on x86_64-pc-linux-gnu) that call into dump_* but which weren't guarded by if (dump_enabled_p ()) gcc/ChangeLog: * dumpfile.c (VERIFY_DUMP_ENABLED_P): New macro. (dump_gimple_stmt): Use it. (dump_gimple_stmt_loc): Likewise. (dump_gimple_expr): Likewise. (dump_gimple_expr_loc): Likewise. (dump_generic_expr): Likewise. (dump_generic_expr_loc): Likewise. (dump_printf): Likewise. (dump_printf_loc): Likewise. (dump_dec): Likewise. (dump_dec): Likewise. (dump_hex): Likewise. (dump_symtab_node): Likewise. gcc/ChangeLog: * gimple-loop-interchange.cc (tree_loop_interchange::interchange): Guard dump call with dump_enabled_p. * graphite-isl-ast-to-gimple.c (graphite_regenerate_ast_isl): Likewise. * graphite-optimize-isl.c (optimize_isl): Likewise. * graphite.c (graphite_transform_loops): Likewise. * tree-loop-distribution.c (pass_loop_distribution::execute): Likewise. * tree-parloops.c (parallelize_loops): Likewise. * tree-ssa-loop-niter.c (number_of_iterations_exit): Likewise. * tree-vect-data-refs.c (vect_analyze_group_access_1): Likewise. (vect_prune_runtime_alias_test_list): Likewise. * tree-vect-loop.c (vect_update_vf_for_slp): Likewise. (vect_estimate_min_profitable_iters): Likewise. * tree-vect-slp.c (vect_record_max_nunits): Likewise. (vect_build_slp_tree_2): Likewise. (vect_supported_load_permutation_p): Likewise. (vect_slp_analyze_operations): Likewise. (vect_slp_analyze_bb_1): Likewise. (vect_slp_bb): Likewise. * tree-vect-stmts.c (vect_analyze_stmt): Likewise. * tree-vectorizer.c (try_vectorize_loop_1): Likewise. (pass_slp_vectorize::execute): Likewise. (increase_alignment): Likewise. From-SVN: r266080
Diffstat (limited to 'gcc/dumpfile.c')
-rw-r--r--gcc/dumpfile.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c
index 09c2490..a1ab205 100644
--- a/gcc/dumpfile.c
+++ b/gcc/dumpfile.c
@@ -1184,6 +1184,19 @@ dump_context dump_context::s_default;
/* Implementation of dump_* API calls, calling into dump_context
member functions. */
+/* Calls to the dump_* functions do non-trivial work, so they ought
+ to be guarded by:
+ if (dump_enabled_p ())
+ Assert that they are guarded, and, if assertions are disabled,
+ bail out if the calls weren't properly guarded. */
+
+#define VERIFY_DUMP_ENABLED_P \
+ do { \
+ gcc_assert (dump_enabled_p ()); \
+ if (!dump_enabled_p ()) \
+ return; \
+ } while (0)
+
/* Dump gimple statement GS with SPC indentation spaces and
EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled. */
@@ -1191,6 +1204,7 @@ void
dump_gimple_stmt (dump_flags_t dump_kind, dump_flags_t extra_dump_flags,
gimple *gs, int spc)
{
+ VERIFY_DUMP_ENABLED_P;
dump_context::get ().dump_gimple_stmt (dump_kind, extra_dump_flags, gs, spc);
}
@@ -1200,6 +1214,7 @@ void
dump_gimple_stmt_loc (dump_flags_t dump_kind, const dump_location_t &loc,
dump_flags_t extra_dump_flags, gimple *gs, int spc)
{
+ VERIFY_DUMP_ENABLED_P;
dump_context::get ().dump_gimple_stmt_loc (dump_kind, loc, extra_dump_flags,
gs, spc);
}
@@ -1212,6 +1227,7 @@ void
dump_gimple_expr (dump_flags_t dump_kind, dump_flags_t extra_dump_flags,
gimple *gs, int spc)
{
+ VERIFY_DUMP_ENABLED_P;
dump_context::get ().dump_gimple_expr (dump_kind, extra_dump_flags, gs, spc);
}
@@ -1221,6 +1237,7 @@ void
dump_gimple_expr_loc (dump_flags_t dump_kind, const dump_location_t &loc,
dump_flags_t extra_dump_flags, gimple *gs, int spc)
{
+ VERIFY_DUMP_ENABLED_P;
dump_context::get ().dump_gimple_expr_loc (dump_kind, loc, extra_dump_flags,
gs, spc);
}
@@ -1232,6 +1249,7 @@ void
dump_generic_expr (dump_flags_t dump_kind, dump_flags_t extra_dump_flags,
tree t)
{
+ VERIFY_DUMP_ENABLED_P;
dump_context::get ().dump_generic_expr (dump_kind, extra_dump_flags, t);
}
@@ -1242,6 +1260,7 @@ void
dump_generic_expr_loc (dump_flags_t dump_kind, const dump_location_t &loc,
dump_flags_t extra_dump_flags, tree t)
{
+ VERIFY_DUMP_ENABLED_P;
dump_context::get ().dump_generic_expr_loc (dump_kind, loc, extra_dump_flags,
t);
}
@@ -1251,6 +1270,7 @@ dump_generic_expr_loc (dump_flags_t dump_kind, const dump_location_t &loc,
void
dump_printf (dump_flags_t dump_kind, const char *format, ...)
{
+ VERIFY_DUMP_ENABLED_P;
va_list ap;
va_start (ap, format);
dump_context::get ().dump_printf_va (dump_kind, format, &ap);
@@ -1264,6 +1284,7 @@ void
dump_printf_loc (dump_flags_t dump_kind, const dump_location_t &loc,
const char *format, ...)
{
+ VERIFY_DUMP_ENABLED_P;
va_list ap;
va_start (ap, format);
dump_context::get ().dump_printf_loc_va (dump_kind, loc, format, &ap);
@@ -1276,6 +1297,7 @@ template<unsigned int N, typename C>
void
dump_dec (dump_flags_t dump_kind, const poly_int<N, C> &value)
{
+ VERIFY_DUMP_ENABLED_P;
dump_context::get ().dump_dec (dump_kind, value);
}
@@ -1288,6 +1310,7 @@ template void dump_dec (dump_flags_t, const poly_widest_int &);
void
dump_dec (dump_flags_t dump_kind, const poly_wide_int &value, signop sgn)
{
+ VERIFY_DUMP_ENABLED_P;
if (dump_file
&& dump_context::get ().apply_dump_filter_p (dump_kind, pflags))
print_dec (value, dump_file, sgn);
@@ -1302,6 +1325,7 @@ dump_dec (dump_flags_t dump_kind, const poly_wide_int &value, signop sgn)
void
dump_hex (dump_flags_t dump_kind, const poly_wide_int &value)
{
+ VERIFY_DUMP_ENABLED_P;
if (dump_file
&& dump_context::get ().apply_dump_filter_p (dump_kind, pflags))
print_hex (value, dump_file);
@@ -1325,6 +1349,7 @@ dumpfile_ensure_any_optinfo_are_flushed ()
void
dump_symtab_node (dump_flags_t dump_kind, symtab_node *node)
{
+ VERIFY_DUMP_ENABLED_P;
dump_context::get ().dump_symtab_node (dump_kind, node);
}