diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2021-06-14 11:39:33 +0200 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2021-06-17 10:29:28 +0200 |
commit | 3f3ee13959f852de432fa7761a8e50ddee6d6e1b (patch) | |
tree | bb0623ca0151d68f6f7d8831e1735948fa3f68ab /gcc | |
parent | 3dfa4fe9f1a089b2b3906c83e22a1b39c49d937c (diff) | |
download | gcc-3f3ee13959f852de432fa7761a8e50ddee6d6e1b.zip gcc-3f3ee13959f852de432fa7761a8e50ddee6d6e1b.tar.gz gcc-3f3ee13959f852de432fa7761a8e50ddee6d6e1b.tar.bz2 |
Add debugging helpers for ranger.
These are debugging aids for help in debugging ranger based passes.
gcc/ChangeLog:
* gimple-range.cc (debug_seed_ranger): New.
(dump_ranger): New.
(debug_ranger): New.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/gimple-range.cc | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index efb919f..5810970 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -1662,4 +1662,83 @@ disable_ranger (struct function *fun) fun->x_range_query = &global_ranges; } +// ========================================= +// Debugging helpers. +// ========================================= + +// Query all statements in the IL to precalculate computable ranges in RANGER. + +static DEBUG_FUNCTION void +debug_seed_ranger (gimple_ranger &ranger) +{ + // Recalculate SCEV to make sure the dump lists everything. + if (scev_initialized_p ()) + { + scev_finalize (); + scev_initialize (); + } + + basic_block bb; + int_range_max r; + gimple_stmt_iterator gsi; + FOR_EACH_BB_FN (bb, cfun) + for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + { + gimple *stmt = gsi_stmt (gsi); + + if (is_gimple_debug (stmt)) + continue; + + ranger.range_of_stmt (r, stmt); + } +} + +// Dump all that ranger knows for the current function. + +DEBUG_FUNCTION void +dump_ranger (FILE *out) +{ + gimple_ranger ranger; + debug_seed_ranger (ranger); + ranger.dump (out); +} + +DEBUG_FUNCTION void +debug_ranger () +{ + dump_ranger (stderr); +} + +// Dump all that ranger knows on a path of BBs. +// +// Note that the blocks are in reverse order, thus the exit block is +// path[0]. + +DEBUG_FUNCTION void +dump_ranger (FILE *dump_file, const vec<basic_block> &path) +{ + if (path.length () == 0) + { + fprintf (dump_file, "empty\n"); + return; + } + + gimple_ranger ranger; + debug_seed_ranger (ranger); + + unsigned i = path.length (); + do + { + i--; + ranger.dump_bb (dump_file, path[i]); + } + while (i > 0); +} + +DEBUG_FUNCTION void +debug_ranger (const vec<basic_block> &path) +{ + dump_ranger (stderr, path); +} + #include "gimple-range-tests.cc" |