gcc/ChangeLog: * diagnostic-move-history.cc (dump_move_history): New routine. (dump_move_history_for): Likewise. (debug_mv_h): Likewise. * diagnostic-move-history.h (dump_move_history): New prototype. (dump_move_history_for): Likewise. * gimple-ssa-isolate-paths.cc (isolate_path): Add debugging message when setting move history for statements. * tree-ssa-sink.cc (sink_code_in_bb): Likewise. * tree-ssa-threadupdate.cc (ssa_redirect_edges): Likewise. (back_jt_path_registry::duplicate_thread_path): Likewise. --- gcc/diagnostic-move-history.cc | 67 +++++++++++++++++++++++++++++++++ gcc/diagnostic-move-history.h | 2 + gcc/gimple-ssa-isolate-paths.cc | 10 +++++ gcc/tree-ssa-sink.cc | 3 ++ gcc/tree-ssa-threadupdate.cc | 18 +++++++++ 5 files changed, 100 insertions(+)
diff --git a/gcc/diagnostic-move-history.cc b/gcc/diagnostic-move-history.cc index b0e8308dbf6b..e4c471ab50f3 100644 --- a/gcc/diagnostic-move-history.cc +++ b/gcc/diagnostic-move-history.cc @@ -24,6 +24,7 @@ #include "backend.h" #include "tree.h" #include "gimple.h" +#include "tree-pretty-print.h" #include "gimple-iterator.h" #include "cfganal.h" #include "diagnostic-move-history.h" @@ -262,3 +263,69 @@ set_move_history_to_stmts_in_bb (basic_block bb, edge entry, return true; } + +/* Dump the move_history data structure MV_HISTORY. */ + +void +dump_move_history (FILE *file, move_history_t mv_history) +{ + fprintf (file, "The move history is: \n"); + if (!mv_history) + { + fprintf (file, "No move history.\n"); + return; + } + + for (move_history_t cur_ch = mv_history; cur_ch; + cur_ch = cur_ch->prev_move) + { + expanded_location exploc_cond = expand_location (cur_ch->condition); + + if (exploc_cond.file) + fprintf (file, "[%s:", exploc_cond.file); + fprintf (file, "%d, ", exploc_cond.line); + fprintf (file, "%d] ", exploc_cond.column); + + fprintf (file, "%s ", cur_ch->is_true_path ? "true" : "false"); + const char *reason = NULL; + switch (cur_ch->reason) + { + case COPY_BY_THREAD_JUMP: + reason = "copy_by_thread_jump"; + break; + case COPY_BY_ISOLATE_PATH: + reason = "copy_by_isolate_path"; + break; + case MOVE_BY_SINK: + reason = "move_by_sink"; + break; + default: + reason = "UNKNOWN"; + break; + } + fprintf (file, "%s \n", reason); + } +} + +/* Dump the move_history date structure attached to the gimple STMT. */ +void +dump_move_history_for (FILE *file, const gimple *stmt) +{ + move_history_t mv_history = get_move_history (stmt); + if (!mv_history) + fprintf (file, "No move history.\n"); + else + dump_move_history (file, mv_history); +} + +DEBUG_FUNCTION void +debug_mv_h (const move_history_t mv_history) +{ + dump_move_history (stderr, mv_history); +} + +DEBUG_FUNCTION void +debug_mv_h (const gimple * stmt) +{ + dump_move_history_for (stderr, stmt); +} diff --git a/gcc/diagnostic-move-history.h b/gcc/diagnostic-move-history.h index cac9cb1e2675..0133f379dbbd 100644 --- a/gcc/diagnostic-move-history.h +++ b/gcc/diagnostic-move-history.h @@ -88,5 +88,7 @@ extern bool set_move_history_to_stmt (gimple *, edge, of the entry edge. */ extern bool set_move_history_to_stmts_in_bb (basic_block, edge, bool, enum move_reason); +extern void dump_move_history (FILE *, move_history_t); +extern void dump_move_history_for (FILE *, const gimple *); #endif // DIAGNOSTIC_MOVE_HISTORY_H_INCLUDED diff --git a/gcc/gimple-ssa-isolate-paths.cc b/gcc/gimple-ssa-isolate-paths.cc index a79b512f63bd..0a6520ee8311 100644 --- a/gcc/gimple-ssa-isolate-paths.cc +++ b/gcc/gimple-ssa-isolate-paths.cc @@ -176,6 +176,16 @@ isolate_path (basic_block bb, basic_block duplicate, incoming edge. */ if (flag_diagnostics_details) { + if (dump_file) + { + fprintf (dump_file, "Set move history for stmts of B[%d]" + " as not on the destination of the edge\n", + bb->index); + fprintf (dump_file, "Set move history for stmts of B[%d]" + " as on the destination of the edge\n", + duplicate->index); + } + set_move_history_to_stmts_in_bb (bb, e, false, COPY_BY_ISOLATE_PATH); set_move_history_to_stmts_in_bb (duplicate, e, true, COPY_BY_ISOLATE_PATH); diff --git a/gcc/tree-ssa-sink.cc b/gcc/tree-ssa-sink.cc index 2fddb1a63268..e7ee445feb69 100644 --- a/gcc/tree-ssa-sink.cc +++ b/gcc/tree-ssa-sink.cc @@ -718,6 +718,9 @@ sink_code_in_bb (basic_block bb, virtual_operand_live &vop_live) { edge entry = find_edge (bb, gsi_bb (togsi)); set_move_history_to_stmt (stmt, entry, true, MOVE_BY_SINK); + if (dump_file) + fprintf (dump_file, " Set move history for the stmt" + " as on the destination of the edge\n"); } /* Update virtual operands of statements in the path we diff --git a/gcc/tree-ssa-threadupdate.cc b/gcc/tree-ssa-threadupdate.cc index 4f5a878686f1..a6bbf2fa9e86 100644 --- a/gcc/tree-ssa-threadupdate.cc +++ b/gcc/tree-ssa-threadupdate.cc @@ -1348,6 +1348,15 @@ ssa_redirect_edges (struct redirection_data **slot, incoming edge. */ if (flag_diagnostics_details) { + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, "Set move history for stmts of B[%d]" + " as not on the destination of the edge\n", + e->dest->index); + fprintf (dump_file, "Set move history for stmts of B[%d]" + " as on the destination of the edge\n", + rd->dup_blocks[0]->index); + } set_move_history_to_stmts_in_bb (e->dest, e, false, COPY_BY_THREAD_JUMP); set_move_history_to_stmts_in_bb (rd->dup_blocks[0], e, @@ -2438,6 +2447,15 @@ back_jt_path_registry::duplicate_thread_path (edge entry, for (i = 0; i < n_region; i++) if (flag_diagnostics_details) { + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, "Set move history for stmts of B[%d]" + " as not on the destination of the edge\n", + region[i]->index); + fprintf (dump_file, "Set move history for stmts of B[%d]" + " as on the destination of the edge\n", + region_copy[i]->index); + } set_move_history_to_stmts_in_bb (region[i], entry, false, COPY_BY_THREAD_JUMP); set_move_history_to_stmts_in_bb (region_copy[i], entry, -- 2.31.1