Qing Zhao <[email protected]> writes:
> 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");
"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);
"s\n"
> + }
> +}
> +
> +/* Dump the move_history date structure attached to the gimple STMT. */
date -> data
> +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);
> +}
> [...]