Commit c4669594 by Steven Bosscher

basic-block.h (BB_FLAGS_TO_PRESERVE): New define.

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.

From-SVN: r189717
parent a0969677
2012-07-20 Steven Bosscher <steven@gcc.gnu.org>
* 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.
2012-07-20 Richard Guenther <rguenther@suse.de> 2012-07-20 Richard Guenther <rguenther@suse.de>
PR tree-optimization/54031 PR tree-optimization/54031
...@@ -1398,7 +1437,7 @@ ...@@ -1398,7 +1437,7 @@
(flow_nodes_print): Remove. (flow_nodes_print): Remove.
(flow_edge_list_print): Remove. (flow_edge_list_print): Remove.
(inverted_post_order_compute): Use FOR_ALL_BB. (inverted_post_order_compute): Use FOR_ALL_BB.
*cfgrtl.c (dump_flow_info): Moved from cfg.c. * cfgrtl.c (dump_flow_info): Moved from cfg.c.
Do not call dump_reg_info. Do not call dump_reg_info.
(debug_flow_info): Moved from cfg.c (debug_flow_info): Moved from cfg.c
(dump_bb_info): Moved from cfg.c. Take 'verbose' argument (dump_bb_info): Moved from cfg.c. Take 'verbose' argument
......
...@@ -203,9 +203,15 @@ enum cfg_bb_flags ...@@ -203,9 +203,15 @@ enum cfg_bb_flags
}; };
#undef DEF_BASIC_BLOCK_FLAG #undef DEF_BASIC_BLOCK_FLAG
/* Bit mask for all edge flags. */ /* Bit mask for all basic block flags. */
#define BB_ALL_FLAGS ((LAST_CFG_BB_FLAG - 1) * 2 - 1) #define BB_ALL_FLAGS ((LAST_CFG_BB_FLAG - 1) * 2 - 1)
/* Bit mask for all basic block flags that must be preserved. These are
the bit masks that are *not* cleared by clear_bb_flags. */
#define BB_FLAGS_TO_PRESERVE \
(BB_DISABLE_SCHEDULE | BB_RTL | BB_NON_LOCAL_GOTO_TARGET \
| BB_HOT_PARTITION | BB_COLD_PARTITION)
/* Dummy bitmask for convenience in the hot/cold partitioning code. */ /* Dummy bitmask for convenience in the hot/cold partitioning code. */
#define BB_UNPARTITIONED 0 #define BB_UNPARTITIONED 0
...@@ -395,7 +401,7 @@ extern basic_block create_basic_block_structure (rtx, rtx, rtx, basic_block); ...@@ -395,7 +401,7 @@ extern basic_block create_basic_block_structure (rtx, rtx, rtx, basic_block);
extern void clear_bb_flags (void); extern void clear_bb_flags (void);
extern void dump_bb_info (FILE *, basic_block, int, int, bool, bool); extern void dump_bb_info (FILE *, basic_block, int, int, bool, bool);
extern void dump_edge_info (FILE *, edge, int, int); extern void dump_edge_info (FILE *, edge, int, int);
extern void brief_dump_cfg (FILE *); extern void brief_dump_cfg (FILE *, int);
extern void clear_edges (void); extern void clear_edges (void);
extern void scale_bbs_frequencies_int (basic_block *, int, int, int); extern void scale_bbs_frequencies_int (basic_block *, int, int, int);
extern void scale_bbs_frequencies_gcov_type (basic_block *, int, gcov_type, extern void scale_bbs_frequencies_gcov_type (basic_block *, int, gcov_type,
...@@ -816,7 +822,6 @@ unsigned bb_dom_dfs_out (enum cdi_direction, basic_block); ...@@ -816,7 +822,6 @@ unsigned bb_dom_dfs_out (enum cdi_direction, basic_block);
extern edge try_redirect_by_replacing_jump (edge, basic_block, bool); extern edge try_redirect_by_replacing_jump (edge, basic_block, bool);
extern void break_superblocks (void); extern void break_superblocks (void);
extern void relink_block_chain (bool); extern void relink_block_chain (bool);
extern void check_bb_profile (basic_block, FILE *);
extern void update_bb_profile_for_threading (basic_block, int, gcov_type, edge); extern void update_bb_profile_for_threading (basic_block, int, gcov_type, edge);
extern void init_rtl_bb_info (basic_block); extern void init_rtl_bb_info (basic_block);
......
...@@ -90,8 +90,7 @@ DEF_BASIC_BLOCK_FLAG(MODIFIED, 12) ...@@ -90,8 +90,7 @@ DEF_BASIC_BLOCK_FLAG(MODIFIED, 12)
DEF_BASIC_BLOCK_FLAG(VISITED, 13) DEF_BASIC_BLOCK_FLAG(VISITED, 13)
/* Set on blocks that are in a transaction. This is calculated on /* Set on blocks that are in a transaction. This is calculated on
demand, and is available after calling demand, and is available after calling compute_transaction_bits(). */
compute_transaction_bits(). */
DEF_BASIC_BLOCK_FLAG(IN_TRANSACTION, 14) DEF_BASIC_BLOCK_FLAG(IN_TRANSACTION, 14)
#endif #endif
......
...@@ -382,16 +382,14 @@ redirect_edge_pred (edge e, basic_block new_pred) ...@@ -382,16 +382,14 @@ redirect_edge_pred (edge e, basic_block new_pred)
connect_src (e); connect_src (e);
} }
/* Clear all basic block flags, with the exception of partitioning and /* Clear all basic block flags that do not have to be preserved. */
setjmp_target. */
void void
clear_bb_flags (void) clear_bb_flags (void)
{ {
basic_block bb; basic_block bb;
FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb) FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
bb->flags = (BB_PARTITION (bb) bb->flags &= BB_FLAGS_TO_PRESERVE;
| (bb->flags & (BB_DISABLE_SCHEDULE + BB_RTL + BB_NON_LOCAL_GOTO_TARGET)));
} }
/* Check the consistency of profile information. We can't do that /* Check the consistency of profile information. We can't do that
...@@ -399,13 +397,16 @@ clear_bb_flags (void) ...@@ -399,13 +397,16 @@ clear_bb_flags (void)
solved graphs, later eliminating of conditionals or roundoff errors. solved graphs, later eliminating of conditionals or roundoff errors.
It is still practical to have them reported for debugging of simple It is still practical to have them reported for debugging of simple
testcases. */ testcases. */
void static void
check_bb_profile (basic_block bb, FILE * file) check_bb_profile (basic_block bb, FILE * file, int indent, int flags)
{ {
edge e; edge e;
int sum = 0; int sum = 0;
gcov_type lsum; gcov_type lsum;
edge_iterator ei; 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) if (profile_status == PROFILE_ABSENT)
return; return;
...@@ -415,14 +416,16 @@ check_bb_profile (basic_block bb, FILE * file) ...@@ -415,14 +416,16 @@ check_bb_profile (basic_block bb, FILE * file)
FOR_EACH_EDGE (e, ei, bb->succs) FOR_EACH_EDGE (e, ei, bb->succs)
sum += e->probability; sum += e->probability;
if (EDGE_COUNT (bb->succs) && abs (sum - REG_BR_PROB_BASE) > 100) 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); sum * 100.0 / REG_BR_PROB_BASE);
lsum = 0; lsum = 0;
FOR_EACH_EDGE (e, ei, bb->succs) FOR_EACH_EDGE (e, ei, bb->succs)
lsum += e->count; lsum += e->count;
if (EDGE_COUNT (bb->succs) if (EDGE_COUNT (bb->succs)
&& (lsum - bb->count > 100 || lsum - bb->count < -100)) && (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); (int) lsum, (int) bb->count);
} }
if (bb != ENTRY_BLOCK_PTR) if (bb != ENTRY_BLOCK_PTR)
...@@ -432,13 +435,15 @@ check_bb_profile (basic_block bb, FILE * file) ...@@ -432,13 +435,15 @@ check_bb_profile (basic_block bb, FILE * file)
sum += EDGE_FREQUENCY (e); sum += EDGE_FREQUENCY (e);
if (abs (sum - bb->frequency) > 100) if (abs (sum - bb->frequency) > 100)
fprintf (file, 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); sum, bb->frequency);
lsum = 0; lsum = 0;
FOR_EACH_EDGE (e, ei, bb->preds) FOR_EACH_EDGE (e, ei, bb->preds)
lsum += e->count; lsum += e->count;
if (lsum - bb->count > 100 || lsum - bb->count < -100) 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); (int) lsum, (int) bb->count);
} }
} }
...@@ -679,6 +684,7 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, int flags, ...@@ -679,6 +684,7 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, int flags,
#undef DEF_BASIC_BLOCK_FLAG #undef DEF_BASIC_BLOCK_FLAG
}; };
const unsigned n_bitnames = sizeof (bb_bitnames) / sizeof (char *); const unsigned n_bitnames = sizeof (bb_bitnames) / sizeof (char *);
bool first;
char *s_indent = (char *) alloca ((size_t) indent + 1); char *s_indent = (char *) alloca ((size_t) indent + 1);
memset ((void *) s_indent, ' ', (size_t) indent); memset ((void *) s_indent, ' ', (size_t) indent);
s_indent[indent] = '\0'; s_indent[indent] = '\0';
...@@ -691,11 +697,12 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, int flags, ...@@ -691,11 +697,12 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, int flags,
if (flags & TDF_COMMENT) if (flags & TDF_COMMENT)
fputs (";; ", outf); 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) if (flags & TDF_DETAILS)
{ {
fprintf (outf, ", loop depth %d, count " HOST_WIDEST_INT_PRINT_DEC, fprintf (outf, ", count " HOST_WIDEST_INT_PRINT_DEC,
bb->loop_depth, (HOST_WIDEST_INT) bb->count); (HOST_WIDEST_INT) bb->count);
fprintf (outf, ", freq %i", bb->frequency); fprintf (outf, ", freq %i", bb->frequency);
if (maybe_hot_bb_p (bb)) if (maybe_hot_bb_p (bb))
fputs (", maybe hot", outf); fputs (", maybe hot", outf);
...@@ -703,11 +710,11 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, int flags, ...@@ -703,11 +710,11 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, int flags,
fputs (", probably never executed", outf); fputs (", probably never executed", outf);
} }
fputc ('\n', outf); fputc ('\n', outf);
if (TDF_DETAILS)
check_bb_profile (bb, outf, indent, flags);
if (flags & TDF_DETAILS) if (flags & TDF_DETAILS)
{ {
bool first = true;
if (flags & TDF_COMMENT) if (flags & TDF_COMMENT)
fputs (";; ", outf); fputs (";; ", outf);
fprintf (outf, "%s prev block ", s_indent); fprintf (outf, "%s prev block ", s_indent);
...@@ -722,6 +729,7 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, int flags, ...@@ -722,6 +729,7 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, int flags,
fprintf (outf, "(nil)"); fprintf (outf, "(nil)");
fputs (", flags:", outf); fputs (", flags:", outf);
first = true;
for (i = 0; i < n_bitnames; i++) for (i = 0; i < n_bitnames; i++)
if (bb->flags & (1 << i)) if (bb->flags & (1 << i))
{ {
...@@ -734,15 +742,25 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, int flags, ...@@ -734,15 +742,25 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, int flags,
} }
if (!first) if (!first)
fputc (')', outf); fputc (')', outf);
fputc ('\n', outf);
} }
fputc ('\n', outf);
if (flags & TDF_COMMENT) if (flags & TDF_COMMENT)
fputs (";; ", outf); fputs (";; ", outf);
fprintf (outf, "%s pred: ", s_indent); fprintf (outf, "%s pred: ", s_indent);
first = true;
FOR_EACH_EDGE (e, ei, bb->preds) 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) if (do_footer)
...@@ -750,22 +768,34 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, int flags, ...@@ -750,22 +768,34 @@ dump_bb_info (FILE *outf, basic_block bb, int indent, int flags,
if (flags & TDF_COMMENT) if (flags & TDF_COMMENT)
fputs (";; ", outf); fputs (";; ", outf);
fprintf (outf, "%s succ: ", s_indent); fprintf (outf, "%s succ: ", s_indent);
first = true;
FOR_EACH_EDGE (e, ei, bb->succs) 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. */ /* Dumps a brief description of cfg to FILE. */
void void
brief_dump_cfg (FILE *file) brief_dump_cfg (FILE *file, int flags)
{ {
basic_block bb; basic_block bb;
FOR_EACH_BB (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);
} }
} }
......
...@@ -271,9 +271,11 @@ verify_flow_info (void) ...@@ -271,9 +271,11 @@ verify_flow_info (void)
void void
dump_bb (FILE *outf, basic_block bb, int indent, int flags) dump_bb (FILE *outf, basic_block bb, int indent, int flags)
{ {
dump_bb_info (outf, bb, indent, flags | TDF_COMMENT, true, true); dump_bb_info (outf, bb, indent, flags, true, false);
if (cfg_hooks->dump_bb) if (cfg_hooks->dump_bb)
cfg_hooks->dump_bb (outf, bb, indent, flags); cfg_hooks->dump_bb (outf, bb, indent, flags);
dump_bb_info (outf, bb, indent, flags, false, true);
fputc ('\n', outf);
} }
/* Dump the complete CFG to FILE. FLAGS are the TDF_* flags in dumpfile.h. */ /* Dump the complete CFG to FILE. FLAGS are the TDF_* flags in dumpfile.h. */
...@@ -284,10 +286,7 @@ dump_flow_info (FILE *file, int flags) ...@@ -284,10 +286,7 @@ dump_flow_info (FILE *file, int flags)
fprintf (file, "\n%d basic blocks, %d edges.\n", n_basic_blocks, n_edges); fprintf (file, "\n%d basic blocks, %d edges.\n", n_basic_blocks, n_edges);
FOR_ALL_BB (bb) FOR_ALL_BB (bb)
{ dump_bb (file, bb, 0, flags);
dump_bb (file, bb, 0, flags);
check_bb_profile (bb, file);
}
putc ('\n', file); putc ('\n', file);
} }
......
...@@ -1875,8 +1875,9 @@ rtl_dump_bb (FILE *outf, basic_block bb, int indent, int flags) ...@@ -1875,8 +1875,9 @@ rtl_dump_bb (FILE *outf, basic_block bb, int indent, int flags)
} }
/* Like print_rtl, but also print out live information for the start of each /* Like dump_function_to_file, but for RTL. Print out dataflow information
basic block. FLAGS are the flags documented in dumpfile.h. */ for the start of each basic block. FLAGS are the TDF_* masks documented
in dumpfile.h. */
void void
print_rtl_with_bb (FILE *outf, const_rtx rtx_first, int flags) print_rtl_with_bb (FILE *outf, const_rtx rtx_first, int flags)
...@@ -1891,52 +1892,74 @@ print_rtl_with_bb (FILE *outf, const_rtx rtx_first, int flags) ...@@ -1891,52 +1892,74 @@ print_rtl_with_bb (FILE *outf, const_rtx rtx_first, int flags)
basic_block *start = XCNEWVEC (basic_block, max_uid); basic_block *start = XCNEWVEC (basic_block, max_uid);
basic_block *end = XCNEWVEC (basic_block, max_uid); basic_block *end = XCNEWVEC (basic_block, max_uid);
enum bb_state *in_bb_p = XCNEWVEC (enum bb_state, max_uid); enum bb_state *in_bb_p = XCNEWVEC (enum bb_state, max_uid);
basic_block bb; basic_block bb;
/* After freeing the CFG, we still have BLOCK_FOR_INSN set on most
insns, but the CFG is not maintained so the basic block info
is not reliable. Therefore it's omitted from the dumps. */
if (! (cfun->curr_properties & PROP_cfg))
flags &= ~TDF_BLOCKS;
if (df) if (df)
df_dump_start (outf); df_dump_start (outf);
FOR_EACH_BB_REVERSE (bb) if (flags & TDF_BLOCKS)
{ {
rtx x; FOR_EACH_BB_REVERSE (bb)
start[INSN_UID (BB_HEAD (bb))] = bb;
end[INSN_UID (BB_END (bb))] = bb;
for (x = BB_HEAD (bb); x != NULL_RTX; x = NEXT_INSN (x))
{ {
enum bb_state state = IN_MULTIPLE_BB; rtx x;
start[INSN_UID (BB_HEAD (bb))] = bb;
end[INSN_UID (BB_END (bb))] = bb;
for (x = BB_HEAD (bb); x != NULL_RTX; x = NEXT_INSN (x))
{
enum bb_state state = IN_MULTIPLE_BB;
if (in_bb_p[INSN_UID (x)] == NOT_IN_BB) if (in_bb_p[INSN_UID (x)] == NOT_IN_BB)
state = IN_ONE_BB; state = IN_ONE_BB;
in_bb_p[INSN_UID (x)] = state; in_bb_p[INSN_UID (x)] = state;
if (x == BB_END (bb)) if (x == BB_END (bb))
break; break;
}
} }
} }
for (tmp_rtx = rtx_first; NULL != tmp_rtx; tmp_rtx = NEXT_INSN (tmp_rtx)) for (tmp_rtx = rtx_first; NULL != tmp_rtx; tmp_rtx = NEXT_INSN (tmp_rtx))
{ {
bb = start[INSN_UID (tmp_rtx)]; if (flags & TDF_BLOCKS)
if (bb != NULL) {
dump_bb_info (outf, bb, 0, dump_flags | TDF_COMMENT, true, false); bb = start[INSN_UID (tmp_rtx)];
if (bb != NULL)
{
dump_bb_info (outf, bb, 0, dump_flags | TDF_COMMENT, true, false);
if (df && (flags & TDF_DETAILS))
df_dump_top (bb, outf);
}
if (in_bb_p[INSN_UID (tmp_rtx)] == NOT_IN_BB if (in_bb_p[INSN_UID (tmp_rtx)] == NOT_IN_BB
&& !NOTE_P (tmp_rtx) && !NOTE_P (tmp_rtx)
&& !BARRIER_P (tmp_rtx)) && !BARRIER_P (tmp_rtx))
fprintf (outf, ";; Insn is not within a basic block\n"); fprintf (outf, ";; Insn is not within a basic block\n");
else if (in_bb_p[INSN_UID (tmp_rtx)] == IN_MULTIPLE_BB) else if (in_bb_p[INSN_UID (tmp_rtx)] == IN_MULTIPLE_BB)
fprintf (outf, ";; Insn is in multiple basic blocks\n"); fprintf (outf, ";; Insn is in multiple basic blocks\n");
}
if (! (flags & TDF_SLIM)) if (! (flags & TDF_SLIM))
print_rtl_single (outf, tmp_rtx); print_rtl_single (outf, tmp_rtx);
else else
dump_insn_slim (outf, tmp_rtx); dump_insn_slim (outf, tmp_rtx);
bb = end[INSN_UID (tmp_rtx)]; if (flags & TDF_BLOCKS)
if (bb != NULL) {
dump_bb_info (outf, bb, 0, dump_flags | TDF_COMMENT, false, true); bb = end[INSN_UID (tmp_rtx)];
if (bb != NULL)
{
dump_bb_info (outf, bb, 0, dump_flags | TDF_COMMENT, false, true);
if (df && (flags & TDF_DETAILS))
df_dump_bottom (bb, outf);
}
}
putc ('\n', outf); putc ('\n', outf);
} }
......
...@@ -115,7 +115,9 @@ print_gimple_expr (FILE *file, gimple g, int spc, int flags) ...@@ -115,7 +115,9 @@ print_gimple_expr (FILE *file, gimple g, int spc, int flags)
/* Print the GIMPLE sequence SEQ on BUFFER using SPC indentantion /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentantion
spaces and FLAGS as in dump_gimple_stmt. */ spaces and FLAGS as in dump_gimple_stmt.
The caller is responsible for calling pp_flush on BUFFER to finalize
the pretty printer. */
static void static void
dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags) dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
...@@ -1578,8 +1580,9 @@ dump_gimple_asm (pretty_printer *buffer, gimple gs, int spc, int flags) ...@@ -1578,8 +1580,9 @@ dump_gimple_asm (pretty_printer *buffer, gimple gs, int spc, int flags)
} }
/* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in /* Dump a PHI node PHI. BUFFER, SPC and FLAGS are as in dump_gimple_stmt.
dump_gimple_stmt. */ The caller is responsible for calling pp_flush on BUFFER to finalize
pretty printer. */
static void static void
dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, int flags) dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, int flags)
...@@ -1843,7 +1846,8 @@ dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags) ...@@ -1843,7 +1846,8 @@ dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
/* Dump the gimple statement GS on the pretty printer BUFFER, SPC /* Dump the gimple statement GS on the pretty printer BUFFER, SPC
spaces of indent. FLAGS specifies details to show in the dump (see spaces of indent. FLAGS specifies details to show in the dump (see
TDF_* in dumpfile.h). */ TDF_* in dumpfile.h). The caller is responsible for calling
pp_flush on BUFFER to finalize the pretty printer. */
void void
dump_gimple_stmt (pretty_printer *buffer, gimple gs, int spc, int flags) dump_gimple_stmt (pretty_printer *buffer, gimple gs, int spc, int flags)
...@@ -2067,8 +2071,6 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags) ...@@ -2067,8 +2071,6 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
{ {
if (flags & TDF_BLOCKS) if (flags & TDF_BLOCKS)
{ {
dump_bb_info (outf, bb, indent, flags, true, false);
if (flags & TDF_LINENO) if (flags & TDF_LINENO)
{ {
gimple_stmt_iterator gsi; gimple_stmt_iterator gsi;
...@@ -2103,8 +2105,6 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags) ...@@ -2103,8 +2105,6 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
fprintf (outf, "%s<bb %d>:\n", s_indent, bb->index); fprintf (outf, "%s<bb %d>:\n", s_indent, bb->index);
} }
} }
if (cfun)
check_bb_profile (bb, outf);
} }
...@@ -2112,9 +2112,13 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags) ...@@ -2112,9 +2112,13 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
spaces. */ spaces. */
static void static void
dump_gimple_bb_footer (FILE *outf, basic_block bb, int indent, int flags) dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
basic_block bb ATTRIBUTE_UNUSED,
int indent ATTRIBUTE_UNUSED,
int flags ATTRIBUTE_UNUSED)
{ {
dump_bb_info (outf, bb, indent, flags, false, true); /* There is currently no GIMPLE-specific basic block info to dump. */
return;
} }
...@@ -2256,7 +2260,7 @@ gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent, ...@@ -2256,7 +2260,7 @@ gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
INDENT (curr_indent); INDENT (curr_indent);
dump_gimple_stmt (buffer, stmt, curr_indent, flags); dump_gimple_stmt (buffer, stmt, curr_indent, flags);
pp_newline (buffer); pp_flush (buffer);
dump_histograms_for_stmt (cfun, buffer->buffer->stream, stmt); dump_histograms_for_stmt (cfun, buffer->buffer->stream, stmt);
} }
...@@ -2271,8 +2275,10 @@ void ...@@ -2271,8 +2275,10 @@ void
gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags) gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
{ {
dump_gimple_bb_header (file, bb, indent, flags); dump_gimple_bb_header (file, bb, indent, flags);
maybe_init_pretty_print (file); if (bb->index >= NUM_FIXED_BLOCKS)
gimple_dump_bb_buff (&buffer, bb, indent, flags); {
pp_flush (&buffer); maybe_init_pretty_print (file);
gimple_dump_bb_buff (&buffer, bb, indent, flags);
}
dump_gimple_bb_footer (file, bb, indent, flags); dump_gimple_bb_footer (file, bb, indent, flags);
} }
...@@ -1725,11 +1725,7 @@ execute_function_dump (void *data ATTRIBUTE_UNUSED) ...@@ -1725,11 +1725,7 @@ execute_function_dump (void *data ATTRIBUTE_UNUSED)
dump_function_to_file (current_function_decl, dump_file, dump_flags); dump_function_to_file (current_function_decl, dump_file, dump_flags);
else else
{ {
if ((cfun->curr_properties & PROP_cfg) print_rtl_with_bb (dump_file, get_insns (), dump_flags);
&& (dump_flags & TDF_BLOCKS))
print_rtl_with_bb (dump_file, get_insns (), dump_flags);
else
print_rtl (dump_file, get_insns ());
if ((cfun->curr_properties & PROP_cfg) if ((cfun->curr_properties & PROP_cfg)
&& graph_dump_format != no_graph && graph_dump_format != no_graph
......
...@@ -759,6 +759,7 @@ void ...@@ -759,6 +759,7 @@ void
pp_base_newline (pretty_printer *pp) pp_base_newline (pretty_printer *pp)
{ {
obstack_1grow (pp->buffer->obstack, '\n'); obstack_1grow (pp->buffer->obstack, '\n');
pp_needs_newline (pp) = false;
pp->buffer->line_length = 0; pp->buffer->line_length = 0;
} }
......
...@@ -397,7 +397,7 @@ debug_region (int rgn) ...@@ -397,7 +397,7 @@ debug_region (int rgn)
for (bb = 0; bb < rgn_table[rgn].rgn_nr_blocks; bb++) for (bb = 0; bb < rgn_table[rgn].rgn_nr_blocks; bb++)
{ {
dump_bb (stderr, BASIC_BLOCK (rgn_bb_table[current_blocks + bb]), dump_bb (stderr, BASIC_BLOCK (rgn_bb_table[current_blocks + bb]),
0, TDF_SLIM); 0, TDF_SLIM | TDF_BLOCKS);
fprintf (stderr, "\n"); fprintf (stderr, "\n");
} }
......
...@@ -810,7 +810,7 @@ extern void debug_bb_slim (basic_block); ...@@ -810,7 +810,7 @@ extern void debug_bb_slim (basic_block);
DEBUG_FUNCTION void DEBUG_FUNCTION void
debug_bb_slim (basic_block bb) debug_bb_slim (basic_block bb)
{ {
dump_bb (stderr, bb, 0, TDF_SLIM); dump_bb (stderr, bb, 0, TDF_SLIM | TDF_BLOCKS);
} }
extern void debug_bb_n_slim (int); extern void debug_bb_n_slim (int);
......
2012-07-20 Steven Bosscher <steven@gcc.gnu.org>
* 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.
2012-07-20 Jakub Jelinek <jakub@redhat.com> 2012-07-20 Jakub Jelinek <jakub@redhat.com>
PR c++/28656 PR c++/28656
......
/* { dg-options "-O2 -fdump-ipa-profile-blocks -fdump-tree-optimized-blocks" } */ /* { dg-options "-O2 -fdump-ipa-profile-details -fdump-tree-optimized-details" } */
int max = 33333; int max = 33333;
int a[8]; int a[8];
int int
...@@ -14,8 +14,8 @@ main () ...@@ -14,8 +14,8 @@ main ()
/* Loop header copying will peel away the initial conditional, so the loop body /* Loop header copying will peel away the initial conditional, so the loop body
is once reached directly from entry point of function, rest via loopback is once reached directly from entry point of function, rest via loopback
edge. */ edge. */
/* { dg-final-use { scan-ipa-dump "count:33333" "profile"} } */ /* { dg-final-use { scan-ipa-dump "loop depth 1, count 33334" "profile"} } */
/* { dg-final-use { scan-tree-dump "count:33332" "optimized"} } */ /* { dg-final-use { scan-tree-dump "loop depth 1, count 33332" "optimized"} } */
/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ /* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
/* { dg-final-use { cleanup-ipa-dump "profile" } } */ /* { dg-final-use { cleanup-ipa-dump "profile" } } */
/* { dg-final-use { cleanup-tree-dump "optimized" } } */ /* { dg-final-use { cleanup-tree-dump "optimized" } } */
...@@ -17,5 +17,5 @@ int main() ...@@ -17,5 +17,5 @@ int main()
} }
/* We should only store to a.i, not load from it. */ /* We should only store to a.i, not load from it. */
/* { dg-final { scan-tree-dump-times "a.i" 1 "optimized" } } */ /* { dg-final { scan-tree-dump-not "= a.i" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */ /* { dg-final { cleanup-tree-dump "optimized" } } */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-O1 -fdump-tree-optimized-blocks" } */ /* { dg-options "-O1 -fdump-tree-optimized-details" } */
void foo (void) void foo (void)
{ {
...@@ -12,17 +12,17 @@ return; ...@@ -12,17 +12,17 @@ return;
/* The goto &L0 should have been optimized away during CFG /* The goto &L0 should have been optimized away during CFG
cleanups. */ cleanups. */
/* { dg-final { scan-tree-dump-times "goto &L0" 0 "optimized" } } */ /* { dg-final { scan-tree-dump-not "goto &L0" "optimized" } } */
/* There should not be any abnormal edges as DOM removed the /* There should not be any abnormal edges as DOM removed the
computed goto. */ computed goto. */
/* { dg-final { scan-tree-dump-times "ab" 0 "optimized" } } */ /* { dg-final { scan-tree-dump-not "ABNORMAL" "optimized" } } */
/* And verify that we have fixed the fallthru flag as well. /* And verify that we have fixed the fallthru flag as well.
After DOM we will have two fallthru edges (e->0, 0->1), After DOM we will have two fallthru edges (e->0, 0->1),
but in the dump files we mention the 0->1 two times. So but in the dump files we mention the 2->3 two times. So
scan for 3 instances of "fallthru". */ scan for 3 instances of "FALLTHRU". */
/* { dg-final { scan-tree-dump-times "fallthru" 3 "optimized" } } */ /* { dg-final { scan-tree-dump-times "FALLTHRU" 3 "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */ /* { dg-final { cleanup-tree-dump "optimized" } } */
...@@ -17,7 +17,7 @@ float f(vector float a, int b, vector float c) ...@@ -17,7 +17,7 @@ float f(vector float a, int b, vector float c)
} }
/* We should be able to optimize this to just "return 0.0;" */ /* We should be able to optimize this to just "return 0.0;" */
/* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 0 "optimized"} } */ /* { dg-final { scan-tree-dump-not "BIT_FIELD_REF" "optimized"} } */
/* { dg-final { scan-tree-dump-times "0.0" 1 "optimized"} } */ /* { dg-final { scan-tree-dump-times "return 0.0" 1 "optimized"} } */
/* { dg-final { cleanup-tree-dump "optimized" } } */ /* { dg-final { cleanup-tree-dump "optimized" } } */
...@@ -374,7 +374,7 @@ tracer (void) ...@@ -374,7 +374,7 @@ tracer (void)
mark_dfs_back_edges (); mark_dfs_back_edges ();
if (dump_file) if (dump_file)
brief_dump_cfg (dump_file); brief_dump_cfg (dump_file, dump_flags);
/* Trace formation is done on the fly inside tail_duplicate */ /* Trace formation is done on the fly inside tail_duplicate */
changed = tail_duplicate (); changed = tail_duplicate ();
...@@ -382,7 +382,7 @@ tracer (void) ...@@ -382,7 +382,7 @@ tracer (void)
free_dominance_info (CDI_DOMINATORS); free_dominance_info (CDI_DOMINATORS);
if (dump_file) if (dump_file)
brief_dump_cfg (dump_file); brief_dump_cfg (dump_file, dump_flags);
return changed ? TODO_cleanup_cfg : 0; return changed ? TODO_cleanup_cfg : 0;
} }
......
...@@ -1844,7 +1844,7 @@ remove_bb (basic_block bb) ...@@ -1844,7 +1844,7 @@ remove_bb (basic_block bb)
fprintf (dump_file, "Removing basic block %d\n", bb->index); fprintf (dump_file, "Removing basic block %d\n", bb->index);
if (dump_flags & TDF_DETAILS) if (dump_flags & TDF_DETAILS)
{ {
dump_bb (dump_file, bb, 0, 0); dump_bb (dump_file, bb, 0, dump_flags);
fprintf (dump_file, "\n"); fprintf (dump_file, "\n");
} }
} }
...@@ -2063,7 +2063,7 @@ find_case_label_for_value (gimple switch_stmt, tree val) ...@@ -2063,7 +2063,7 @@ find_case_label_for_value (gimple switch_stmt, tree val)
void void
gimple_debug_bb (basic_block bb) gimple_debug_bb (basic_block bb)
{ {
dump_bb (stderr, bb, 0, TDF_VOPS|TDF_MEMSYMS); dump_bb (stderr, bb, 0, TDF_VOPS|TDF_MEMSYMS|TDF_BLOCKS);
} }
...@@ -2103,7 +2103,7 @@ gimple_dump_cfg (FILE *file, int flags) ...@@ -2103,7 +2103,7 @@ gimple_dump_cfg (FILE *file, int flags)
fprintf (file, ";; \n%d basic blocks, %d edges, last basic block %d.\n\n", fprintf (file, ";; \n%d basic blocks, %d edges, last basic block %d.\n\n",
n_basic_blocks, n_edges, last_basic_block); n_basic_blocks, n_edges, last_basic_block);
brief_dump_cfg (file); brief_dump_cfg (file, flags | TDF_COMMENT);
fprintf (file, "\n"); fprintf (file, "\n");
} }
...@@ -6687,7 +6687,6 @@ dump_function_to_file (tree fn, FILE *file, int flags) ...@@ -6687,7 +6687,6 @@ dump_function_to_file (tree fn, FILE *file, int flags)
if (cfun && cfun->decl == fn && cfun->cfg && basic_block_info) if (cfun && cfun->decl == fn && cfun->cfg && basic_block_info)
{ {
/* If the CFG has been built, emit a CFG-based dump. */ /* If the CFG has been built, emit a CFG-based dump. */
check_bb_profile (ENTRY_BLOCK_PTR, file);
if (!ignore_topmost_bind) if (!ignore_topmost_bind)
fprintf (file, "{\n"); fprintf (file, "{\n");
...@@ -6695,10 +6694,9 @@ dump_function_to_file (tree fn, FILE *file, int flags) ...@@ -6695,10 +6694,9 @@ dump_function_to_file (tree fn, FILE *file, int flags)
fprintf (file, "\n"); fprintf (file, "\n");
FOR_EACH_BB (bb) FOR_EACH_BB (bb)
gimple_dump_bb (file, bb, 2, flags); dump_bb (file, bb, 2, flags | TDF_COMMENT);
fprintf (file, "}\n"); fprintf (file, "}\n");
check_bb_profile (EXIT_BLOCK_PTR, file);
} }
else if (DECL_SAVED_TREE (fn) == NULL) else if (DECL_SAVED_TREE (fn) == NULL)
{ {
...@@ -6821,7 +6819,7 @@ print_loops_bb (FILE *file, basic_block bb, int indent, int verbosity) ...@@ -6821,7 +6819,7 @@ print_loops_bb (FILE *file, basic_block bb, int indent, int verbosity)
if (verbosity >= 3) if (verbosity >= 3)
{ {
fprintf (file, "%s {\n", s_indent); fprintf (file, "%s {\n", s_indent);
gimple_dump_bb (file, bb, indent + 4, TDF_VOPS|TDF_MEMSYMS); dump_bb (file, bb, indent + 4, TDF_VOPS|TDF_MEMSYMS);
fprintf (file, "%s }\n", s_indent); fprintf (file, "%s }\n", s_indent);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment