summaryrefslogtreecommitdiff
path: root/gcc/cfghooks.c
diff options
context:
space:
mode:
authorSteven Bosscher <steven@gcc.gnu.org>2012-07-17 23:17:20 +0000
committerSteven Bosscher <steven@gcc.gnu.org>2012-07-17 23:17:20 +0000
commita315c44ce0e466407809e4cb1c1f921aa08726b4 (patch)
tree9d5c1ea84c526379245c9986d831f4ce16757d79 /gcc/cfghooks.c
parent9717f7a145b447c2c3dd00601de66be20d86261e (diff)
downloadgcc-a315c44ce0e466407809e4cb1c1f921aa08726b4.tar.gz
dumpfile.h (TDF_COMMENT): New define.
* dumpfile.h (TDF_COMMENT): New define. * basic-block.h (EDGE_FALLTHRU, EDGE_ABNORMAL, EDGE_ABNORMAL_CALL, EDGE_EH, EDGE_FAKE, EDGE_DFS_BACK, EDGE_CAN_FALLTHRU, EDGE_IRREDUCIBLE_LOOP, EDGE_SIBCALL, EDGE_LOOP_EXIT, EDGE_TRUE_VALUE, EDGE_FALSE_VALUE, EDGE_EXECUTABLE, EDGE_CROSSING, EDGE_PRESERVE): Move to new file cfg-flags.h. (enum cfg_edge_flags): New enum, using cfg-flags.h. (EDGE_ALL_FLAGS): Compute value automatically. (BB_NEW, BB_REACHABLE, BB_IRREDUCIBLE_LOOP, BB_SUPERBLOCK, BB_DISABLE_SCHEDULE, BB_HOT_PARTITION, BB_COLD_PARTITION, BB_DUPLICATED, BB_NON_LOCAL_GOTO_TARGET, BB_RTL, BB_FORWARDER_BLOCK, BB_NONTHREADABLE_BLOCK, BB_MODIFIED, BB_VISITED, BB_IN_TRANSACTION): Move to new file cfg-flags.h. (enum bb_flags): Rename to cfg_bb_flags. Use cfg-flags.h. (BB_ALL_FLAGS): New, compute value automatically. (dump_bb_info): Update prototype. (dump_edge_info): Update prototype. * cfg-flags.h: New file. * cfg.c (dump_edge_info): Take flags argument. Be verbose only if TDF_DETAILS and not TDF_SLIM. Include cfg-flags.h for bitnames. Check that the edge flags are within the range of EDGE_ALL_FLAGS. (debug_bb): Update dump_bb call. (dump_cfg_bb_info): Remove. (dump_bb_info): New function. Use cfg-flags.h for bitnames. Adjust verbosity using TDF_* flags. Check that the basic block flags are within the range of BB_ALL_FLAGS. (brief_dump_cfg): Use dump_bb_info instead of dump_cfg_bb_info. * cfghooks.h (struct cfghooks): Update dump_bb hook, take a FILE first for consistency with other dump functions. (dump_bb): Update prototype accordingly. * cfghooks.c: Include dumpfile.h. (verify_flow_info): Update dump_edge_info calls. (dump_bb): Take a flags argument and pass it around. Use dump_bb_info to dump common information about a basic block. (dump_flow_info): Moved here from cfgrtl.c. Make IL agnostic. (debug_flow_info): Moved here from cfgrtl.c. * profile.c (is_edge_inconsistent): Update dump_bb calls. * loop-invariant.c (find_defs): Update print_rtl_with_bb call. * rtl.h (debug_bb_n_slim, debug_bb_slim, print_rtl_slim, print_rtl_slim_with_bb): Remove prototypes. (dump_insn_slim): Adjust prototype to take a const_rtx. (print_rtl_with_bb): Adjust prototype. * sched-rgn.c (debug_region): Use dump_bb instead of debug_bb_n_slim. * sched-vis.c (dump_insn_slim): Take a const_rtx. (debug_insn_slim): Prototype here near DEBUG_FUNCTION marker. (print_rtl_slim_with_bb): Remove. (print_rtl_slim): Rename to debug_rtl_slim. Print only insn info, not basic block info (print_rtl_with_bb with TDF_SLIM should be used for that. Prototype here near DEBUG_FUNCTION marker. (debug_bb_slim): Prototype here near DEBUG_FUNCTION marker. Use dump_bb. (debug_bb_n_slim): Prototype here near DEBUG_FUNCTION marker. * tree-cfg.c (gimple_can_merge_blocks_p): Use EDGE_COMPLEX. (remove_bb): Update dump_bb call. (gimple_debug_bb): Use dump_bb. (dump_function_to_file): Update gimple_dump_bb call. (print_loops_bb): Likewise. * tree-flow.h (gimple_dump_bb): Update prototype. * gimple-pretty-print.c (dump_bb_header): Rename to dump_gimple_bb_header. Write to a stream instead of a pretty printer. Use dump_bb_info to dump basic block info. (dump_bb_end): Rename to dump_gimple_bb_footer. Write to a stream instead of a pretty printer. Use dump_bb_info. (gimple_dump_bb_buff): Do not call dump_bb_header and dump_bb_end. (gimple_dump_bb): Do it here with dump_gimple_bb_header and dump_gimple_bb_footer. * cfgrtl.c (rtl_dump_bb): Update prototype. Only dump DF if the dump flags have TDF_DETAILS. Use dump_insn_slim if TDF_SLIM. (print_rtl_with_bb): Take a flags argument and pass it around. Use dump_insn_slim if TDF_SLIM. (dump_bb_info): Removed and re-incarnated in cfg.c. (dump_flow_info): Moved to cfghooks.c. (debug_flow_info): Moved to cfghooks.c. * passes.c (execute_function_dump): Unconditionally use print_rtl_with_bb for RTL dumps, now that it understands TDF_SLIM. * final.c (dump_basic_block_info): Update dump_edge_info calls. * tree-vrp.c (dump_asserts_for): Likewise. * ifcvt.c (if_convert): Unconditionally use print_rtl_with_bb. * tree-if-conv.c (if_convertible_bb_p): Don't look at EDGE_ABNORMAL_CALL, it has no meaning in the GIMPLE world. * trans-mem.c (make_tm_edge): Don't set EDGE_ABNORMAL_CALL, for the same reason. * config/rl78/rl78.c (rl78_reorg): Update print_rtl_with_bb calls. From-SVN: r189590
Diffstat (limited to 'gcc/cfghooks.c')
-rw-r--r--gcc/cfghooks.c80
1 files changed, 37 insertions, 43 deletions
diff --git a/gcc/cfghooks.c b/gcc/cfghooks.c
index 07cbad6462f..69655390102 100644
--- a/gcc/cfghooks.c
+++ b/gcc/cfghooks.c
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3. If not see
#include "config.h"
#include "system.h"
#include "coretypes.h"
+#include "dumpfile.h"
#include "tm.h"
#include "tree.h"
#include "rtl.h"
@@ -183,9 +184,9 @@ verify_flow_info (void)
error ("verify_flow_info: Basic block %d succ edge is corrupted",
bb->index);
fprintf (stderr, "Predecessor: ");
- dump_edge_info (stderr, e, 0);
+ dump_edge_info (stderr, e, TDF_DETAILS, 0);
fprintf (stderr, "\nSuccessor: ");
- dump_edge_info (stderr, e, 1);
+ dump_edge_info (stderr, e, TDF_DETAILS, 1);
fprintf (stderr, "\n");
err = 1;
}
@@ -204,9 +205,9 @@ verify_flow_info (void)
{
error ("basic block %d pred edge is corrupted", bb->index);
fputs ("Predecessor: ", stderr);
- dump_edge_info (stderr, e, 0);
+ dump_edge_info (stderr, e, TDF_DETAILS, 0);
fputs ("\nSuccessor: ", stderr);
- dump_edge_info (stderr, e, 1);
+ dump_edge_info (stderr, e, TDF_DETAILS, 1);
fputc ('\n', stderr);
err = 1;
}
@@ -217,9 +218,9 @@ verify_flow_info (void)
error ("its dest_idx should be %d, not %d",
ei.index, e->dest_idx);
fputs ("Predecessor: ", stderr);
- dump_edge_info (stderr, e, 0);
+ dump_edge_info (stderr, e, TDF_DETAILS, 0);
fputs ("\nSuccessor: ", stderr);
- dump_edge_info (stderr, e, 1);
+ dump_edge_info (stderr, e, TDF_DETAILS, 1);
fputc ('\n', stderr);
err = 1;
}
@@ -260,50 +261,43 @@ verify_flow_info (void)
timevar_pop (TV_CFG_VERIFY);
}
-/* Print out one basic block. This function takes care of the purely
- graph related information. The cfg hook for the active representation
- should dump representation-specific information. */
+/* Print out one basic block BB to file OUTF. INDENT is printed at the
+ start of each new line. FLAGS are the TDF_* flags in dumpfile.h.
+
+ This function takes care of the purely graph related information.
+ The cfg hook for the active representation should dump
+ representation-specific information. */
void
-dump_bb (basic_block bb, FILE *outf, int indent)
+dump_bb (FILE *outf, basic_block bb, int indent, int flags)
{
- edge e;
- edge_iterator ei;
- char *s_indent;
-
- s_indent = (char *) alloca ((size_t) indent + 1);
- memset (s_indent, ' ', (size_t) indent);
- s_indent[indent] = '\0';
-
- fprintf (outf, ";;%s basic block %d, loop depth %d, count ",
- s_indent, bb->index, bb->loop_depth);
- fprintf (outf, HOST_WIDEST_INT_PRINT_DEC, (HOST_WIDEST_INT) bb->count);
- putc ('\n', outf);
+ dump_bb_info (outf, bb, indent, flags | TDF_COMMENT, true, true);
+ if (cfg_hooks->dump_bb)
+ cfg_hooks->dump_bb (outf, bb, indent, flags);
+}
- fprintf (outf, ";;%s prev block ", s_indent);
- if (bb->prev_bb)
- fprintf (outf, "%d, ", bb->prev_bb->index);
- else
- fprintf (outf, "(nil), ");
- fprintf (outf, "next block ");
- if (bb->next_bb)
- fprintf (outf, "%d", bb->next_bb->index);
- else
- fprintf (outf, "(nil)");
- putc ('\n', outf);
+/* Dump the complete CFG to FILE. FLAGS are the TDF_* flags in dumpfile.h. */
+void
+dump_flow_info (FILE *file, int flags)
+{
+ basic_block bb;
- fprintf (outf, ";;%s pred: ", s_indent);
- FOR_EACH_EDGE (e, ei, bb->preds)
- dump_edge_info (outf, e, 0);
- putc ('\n', outf);
+ fprintf (file, "\n%d basic blocks, %d edges.\n", n_basic_blocks, n_edges);
+ FOR_ALL_BB (bb)
+ {
+ dump_bb (file, bb, 0, flags);
+ check_bb_profile (bb, file);
+ }
- fprintf (outf, ";;%s succ: ", s_indent);
- FOR_EACH_EDGE (e, ei, bb->succs)
- dump_edge_info (outf, e, 1);
- putc ('\n', outf);
+ putc ('\n', file);
+}
- if (cfg_hooks->dump_bb)
- cfg_hooks->dump_bb (bb, outf, indent, 0);
+/* Like above, but dump to stderr. To be called from debuggers. */
+void debug_flow_info (void);
+DEBUG_FUNCTION void
+debug_flow_info (void)
+{
+ dump_flow_info (stderr, TDF_DETAILS);
}
/* Redirect edge E to the given basic block DEST and update underlying program