diff options
author | steven <steven@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-07-20 12:25:55 +0000 |
---|---|---|
committer | steven <steven@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-07-20 12:25:55 +0000 |
commit | bec2cf98763e9ec1a4d41bd1db78a74ca8fefbd9 (patch) | |
tree | 303d907b5ee72aaa7b209fd1bcaf4f0ab16f41b1 /gcc/cfg.c | |
parent | 59da1bcd780c2c76748b6dac277e146bb80db858 (diff) | |
download | gcc-bec2cf98763e9ec1a4d41bd1db78a74ca8fefbd9.tar.gz |
gcc/
* basic-block.h (BB_FLAGS_TO_PRESERVE): New define.
(brief_dump_cfg): Update prototype to take flags argument.
(check_bb_profile): Remove prototype.
* tracer.c (tracer): Update brief_dump_cfg calls.
* cfghooks.c (dump_bb): Do not pass TDF_COMMENT to dump_bb_info.
Call dump_bb_info before and after the cfghook dump_bb. Terminate
the dump with a newline.
(dump_flow_info): Do not call check_bb_profile.
* cfg.c (clear_bb_flags): Update using BB_FLAGS_TO_PRESERVE.
(check_bb_profile): Make static. Take indent and flags arguments.
(dump_bb_info): Always dump loop depth. With TDF_DETAILS, call
check_bb_profile. Print one edge per line.
(brief_dump_cfg): Take a flags argument, and filter out
TDF_COMMENT and TDF_DETAILS.
* pretty-print.c (pp_base_newline): Set pp_needs_newline to false.
* gimple-pretty-print.c (dump_gimple_bb_header): Do not use dump_bb_info
here, it is already called from dump_bb. Idem for check_bb_profile.
(dump_gimple_bb_footer): Likewise.
(gimple_dump_bb_buff): Call pp_flush after dump_gimple_stmt to
avoid broken dumps for statement histograms.
(gimple_dump_bb): Handle ENTRY_BLOCK and EXIT_BLOCK. Do
not call pp_flush here, the buffer should be empty.
* sched-rgn.c (debug_region): Pass TDF_BLOCKS to dump_bb.
* sched-vis.c (debug_bb_slim): Likewise.
* tree-cfg.c (remove_bb): Pass dump_flags to dump_bb.
(gimple_debug_bb): Pass TDF_BLOCKS to dump_bb.
(gimple_dump_cfg): Do brief_dump_cfg with TDF_COMMENT.
(dump_function_to_file): Do not call check_bb_profile on
ENTRY_BLOCK and EXIT_BLOCK, check_bb_profile doesn't handle them.
Use dump_bb instead of gimple_dump_bb.
(print_loops_bb): Use dump_bb instead of gimple_dump_bb.
* passes.c (execute_function_dump): Always call print_rtl_with_bb
for RTL dumps.
* cfgrtl.c (print_rtl_with_bb): Handle printing without an up-to-date
CFG. With TDF_BLOCKS and TDF_DETAILS, do DF dumps at the top and bottom
of each basic block.
testsuite/
* gcc.dg/tree-prof/update-loopch.c: Look for counts on the dumps of
the basic block and check loop depth.
* gcc.dg/tree-ssa/pr18133-1.c: Dump details, not blocks. Update
matching patterns and comments.
* gcc.dg/tree-ssa/20031021-1.c: Fix check patterns.
* gcc.dg/tree-ssa/vector-2.c: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@189717 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfg.c')
-rw-r--r-- | gcc/cfg.c | 74 |
1 files changed, 52 insertions, 22 deletions
diff --git a/gcc/cfg.c b/gcc/cfg.c index 66458e337de..f8614074ff6 100644 --- a/gcc/cfg.c +++ b/gcc/cfg.c @@ -382,16 +382,14 @@ redirect_edge_pred (edge e, basic_block new_pred) connect_src (e); } -/* Clear all basic block flags, with the exception of partitioning and - setjmp_target. */ +/* Clear all basic block flags that do not have to be preserved. */ void clear_bb_flags (void) { basic_block bb; FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb) - bb->flags = (BB_PARTITION (bb) - | (bb->flags & (BB_DISABLE_SCHEDULE + BB_RTL + BB_NON_LOCAL_GOTO_TARGET))); + bb->flags &= BB_FLAGS_TO_PRESERVE; } /* Check the consistency of profile information. We can't do that @@ -399,13 +397,16 @@ clear_bb_flags (void) solved graphs, later eliminating of conditionals or roundoff errors. It is still practical to have them reported for debugging of simple testcases. */ -void -check_bb_profile (basic_block bb, FILE * file) +static void +check_bb_profile (basic_block bb, FILE * file, int indent, int flags) { edge e; int sum = 0; gcov_type lsum; edge_iterator ei; + char *s_indent = (char *) alloca ((size_t) indent + 1); + memset ((void *) s_indent, ' ', (size_t) indent); + s_indent[indent] = '\0'; if (profile_status == PROFILE_ABSENT) return; @@ -415,14 +416,16 @@ check_bb_profile (basic_block bb, FILE * file) FOR_EACH_EDGE (e, ei, bb->succs) sum += e->probability; if (EDGE_COUNT (bb->succs) && abs (sum - REG_BR_PROB_BASE) > 100) - fprintf (file, "Invalid sum of outgoing probabilities %.1f%%\n", + fprintf (file, "%s%sInvalid sum of outgoing probabilities %.1f%%\n", + (flags & TDF_COMMENT) ? ";; " : "", s_indent, sum * 100.0 / REG_BR_PROB_BASE); lsum = 0; FOR_EACH_EDGE (e, ei, bb->succs) lsum += e->count; if (EDGE_COUNT (bb->succs) && (lsum - bb->count > 100 || lsum - bb->count < -100)) - fprintf (file, "Invalid sum of outgoing counts %i, should be %i\n", + fprintf (file, "%s%sInvalid sum of outgoing counts %i, should be %i\n", + (flags & TDF_COMMENT) ? ";; " : "", s_indent, (int) lsum, (int) bb->count); } if (bb != ENTRY_BLOCK_PTR) @@ -432,13 +435,15 @@ check_bb_profile (basic_block bb, FILE * file) sum += EDGE_FREQUENCY (e); if (abs (sum - bb->frequency) > 100) fprintf (file, - "Invalid sum of incoming frequencies %i, should be %i\n", + "%s%sInvalid sum of incoming frequencies %i, should be %i\n", + (flags & TDF_COMMENT) ? ";; " : "", s_indent, sum, bb->frequency); lsum = 0; FOR_EACH_EDGE (e, ei, bb->preds) lsum += e->count; if (lsum - bb->count > 100 || lsum - bb->count < -100) - fprintf (file, "Invalid sum of incoming counts %i, should be %i\n", + fprintf (file, "%s%sInvalid sum of incoming counts %i, should be %i\n", + (flags & TDF_COMMENT) ? ";; " : "", s_indent, (int) lsum, (int) bb->count); } } @@ -679,6 +684,7 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, int flags, #undef DEF_BASIC_BLOCK_FLAG }; const unsigned n_bitnames = sizeof (bb_bitnames) / sizeof (char *); + bool first; char *s_indent = (char *) alloca ((size_t) indent + 1); memset ((void *) s_indent, ' ', (size_t) indent); s_indent[indent] = '\0'; @@ -691,11 +697,12 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, int flags, if (flags & TDF_COMMENT) fputs (";; ", outf); - fprintf (outf, "%sbasic block %d", s_indent, bb->index); + fprintf (outf, "%sbasic block %d, loop depth %d", + s_indent, bb->index, bb->loop_depth); if (flags & TDF_DETAILS) { - fprintf (outf, ", loop depth %d, count " HOST_WIDEST_INT_PRINT_DEC, - bb->loop_depth, (HOST_WIDEST_INT) bb->count); + fprintf (outf, ", count " HOST_WIDEST_INT_PRINT_DEC, + (HOST_WIDEST_INT) bb->count); fprintf (outf, ", freq %i", bb->frequency); if (maybe_hot_bb_p (bb)) fputs (", maybe hot", outf); @@ -703,11 +710,11 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, int flags, fputs (", probably never executed", outf); } fputc ('\n', outf); + if (TDF_DETAILS) + check_bb_profile (bb, outf, indent, flags); if (flags & TDF_DETAILS) { - bool first = true; - if (flags & TDF_COMMENT) fputs (";; ", outf); fprintf (outf, "%s prev block ", s_indent); @@ -722,6 +729,7 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, int flags, fprintf (outf, "(nil)"); fputs (", flags:", outf); + first = true; for (i = 0; i < n_bitnames; i++) if (bb->flags & (1 << i)) { @@ -734,15 +742,25 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, int flags, } if (!first) fputc (')', outf); + fputc ('\n', outf); } - fputc ('\n', outf); if (flags & TDF_COMMENT) fputs (";; ", outf); fprintf (outf, "%s pred: ", s_indent); + first = true; FOR_EACH_EDGE (e, ei, bb->preds) - dump_edge_info (outf, e, flags, 0); - fputc ('\n', outf); + { + if (! first) + { + if (flags & TDF_COMMENT) + fputs (";; ", outf); + fprintf (outf, "%s ", s_indent); + } + first = false; + dump_edge_info (outf, e, flags, 0); + fputc ('\n', outf); + } } if (do_footer) @@ -750,22 +768,34 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, int flags, if (flags & TDF_COMMENT) fputs (";; ", outf); fprintf (outf, "%s succ: ", s_indent); + first = true; FOR_EACH_EDGE (e, ei, bb->succs) - dump_edge_info (outf, e, flags, 1); - fputs ("\n\n", outf); + { + if (! first) + { + if (flags & TDF_COMMENT) + fputs (";; ", outf); + fprintf (outf, "%s ", s_indent); + } + first = false; + dump_edge_info (outf, e, flags, 1); + fputc ('\n', outf); + } } } /* Dumps a brief description of cfg to FILE. */ void -brief_dump_cfg (FILE *file) +brief_dump_cfg (FILE *file, int flags) { basic_block bb; FOR_EACH_BB (bb) { - dump_bb_info (file, bb, 0, 0, true, true); + dump_bb_info (file, bb, 0, + flags & (TDF_COMMENT | TDF_DETAILS), + true, true); } } |