Add debugging for move history.
PR tree-optimization/109071
PR tree-optimization/85788
PR tree-optimization/88771
PR tree-optimization/106762
PR tree-optimization/108770
PR tree-optimization/115274
PR tree-optimization/117179
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 | 10 ++++-
gcc/tree-ssa-threadupdate.cc | 18 +++++++++
5 files changed, 106 insertions(+), 1 deletion(-)
diff --git a/gcc/diagnostic-move-history.cc b/gcc/diagnostic-move-history.cc
index 83d8a42b577..045b0d3d5d1 100644
--- a/gcc/diagnostic-move-history.cc
+++ b/gcc/diagnostic-move-history.cc
@@ -25,6 +25,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"
@@ -263,3 +264,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 9a58766d544..0c56974119d 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
diff --git a/gcc/gimple-ssa-isolate-paths.cc b/gcc/gimple-ssa-isolate-paths.cc
index a79b512f63b..0a6520ee831 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 b4d9e991573..bc2a6490256 100644
--- a/gcc/tree-ssa-sink.cc
+++ b/gcc/tree-ssa-sink.cc
@@ -765,7 +765,15 @@ sink_code_in_bb (basic_block bb, virtual_operand_live
&vop_live)
auto_vec<edge> edge_chain = get_edge_chain (bb, gsi_bb (togsi));
for (edge entry : edge_chain)
- set_move_history_to_stmt (stmt, entry, true, MOVE_BY_SINK);
+ {
+ 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"
+ " from bb %d to bb %d\n", entry->src->index,
+ entry->dest->index);
+
+ }
}
/* Update virtual operands of statements in the path we
diff --git a/gcc/tree-ssa-threadupdate.cc b/gcc/tree-ssa-threadupdate.cc
index 4f5a878686f..a6bbf2fa9e8 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