diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2021-11-11 18:06:50 +0100 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2021-11-11 22:13:17 +0100 |
commit | 53b3edceab96de49034fa8cea79f3b365c63f3e5 (patch) | |
tree | 009961b5e6e7c9c455d4e7d5024809d28c17cfd6 /gcc/gimple-range-path.cc | |
parent | a7753db4a7c071fef7a4e7fe2650d6c59cc34066 (diff) | |
download | gcc-53b3edceab96de49034fa8cea79f3b365c63f3e5.zip gcc-53b3edceab96de49034fa8cea79f3b365c63f3e5.tar.gz gcc-53b3edceab96de49034fa8cea79f3b365c63f3e5.tar.bz2 |
Make ranger optional in path_range_query.
All users of path_range_query are currently allocating a gimple_ranger
only to pass it to the query object. It's tidier to just do it from
path_range_query if no ranger was passed.
Tested on x86-64 Linux.
gcc/ChangeLog:
* gimple-range-path.cc (path_range_query::path_range_query): New
ctor without a ranger.
(path_range_query::~path_range_query): Free ranger if necessary.
(path_range_query::range_on_path_entry): Adjust m_ranger for pointer.
(path_range_query::ssa_range_in_phi): Same.
(path_range_query::compute_ranges_in_block): Same.
(path_range_query::compute_imports): Same.
(path_range_query::compute_ranges): Same.
(path_range_query::range_of_stmt): Same.
(path_range_query::compute_outgoing_relations): Same.
* gimple-range-path.h (class path_range_query): New ctor.
* tree-ssa-loop-ch.c (ch_base::copy_headers): Remove gimple_ranger
as path_range_query allocates one.
* tree-ssa-threadbackward.c (class back_threader): Remove m_ranger.
(back_threader::~back_threader): Same.
Diffstat (limited to 'gcc/gimple-range-path.cc')
-rw-r--r-- | gcc/gimple-range-path.cc | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc index 4843c13..b9aceaf 100644 --- a/gcc/gimple-range-path.cc +++ b/gcc/gimple-range-path.cc @@ -36,13 +36,24 @@ along with GCC; see the file COPYING3. If not see // Internal construct to help facilitate debugging of solver. #define DEBUG_SOLVER (dump_file && (param_threader_debug == THREADER_DEBUG_ALL)) -path_range_query::path_range_query (gimple_ranger &ranger, bool resolve) - : m_ranger (ranger) +path_range_query::path_range_query (gimple_ranger *ranger, bool resolve) + : m_cache (new ssa_global_cache), + m_has_cache_entry (BITMAP_ALLOC (NULL)), + m_ranger (ranger), + m_resolve (resolve), + m_alloced_ranger (false) { - m_cache = new ssa_global_cache; - m_has_cache_entry = BITMAP_ALLOC (NULL); - m_resolve = resolve; - m_oracle = new path_oracle (ranger.oracle ()); + m_oracle = new path_oracle (ranger->oracle ()); +} + +path_range_query::path_range_query (bool resolve) + : m_cache (new ssa_global_cache), + m_has_cache_entry (BITMAP_ALLOC (NULL)), + m_ranger (new gimple_ranger), + m_resolve (resolve), + m_alloced_ranger (true) +{ + m_oracle = new path_oracle (m_ranger->oracle ()); } path_range_query::~path_range_query () @@ -50,6 +61,8 @@ path_range_query::~path_range_query () BITMAP_FREE (m_has_cache_entry); delete m_cache; delete m_oracle; + if (m_alloced_ranger) + delete m_ranger; } // Mark cache entry for NAME as unused. @@ -140,7 +153,7 @@ path_range_query::range_on_path_entry (irange &r, tree name) gimple *last = last_stmt (entry); if (last) { - if (m_ranger.range_of_expr (r, name, last)) + if (m_ranger->range_of_expr (r, name, last)) return; gcc_unreachable (); } @@ -156,7 +169,7 @@ path_range_query::range_on_path_entry (irange &r, tree name) { edge e = EDGE_PRED (entry, i); if (e->src != ENTRY_BLOCK_PTR_FOR_FN (cfun) - && m_ranger.range_on_edge (tmp, e, name)) + && m_ranger->range_on_edge (tmp, e, name)) { r.union_ (tmp); changed = true; @@ -244,7 +257,7 @@ path_range_query::ssa_range_in_phi (irange &r, gphi *phi) if (at_entry ()) { - if (m_resolve && m_ranger.range_of_expr (r, name, phi)) + if (m_resolve && m_ranger->range_of_expr (r, name, phi)) return; // Try fold just in case we can resolve simple things like PHI <5(99), 6(88)>. @@ -275,7 +288,7 @@ path_range_query::ssa_range_in_phi (irange &r, gphi *phi) range_on_path_entry (r, arg); else r.set_varying (TREE_TYPE (name)); - m_ranger.range_on_edge (tmp, e_in, arg); + m_ranger->range_on_edge (tmp, e_in, arg); r.intersect (tmp); return; } @@ -370,7 +383,7 @@ path_range_query::compute_ranges_in_block (basic_block bb) EXECUTE_IF_SET_IN_BITMAP (m_imports, 0, i, bi) { tree name = ssa_name (i); - gori_compute &g = m_ranger.gori (); + gori_compute &g = m_ranger->gori (); bitmap exports = g.exports (bb); if (bitmap_bit_p (exports, i)) @@ -452,7 +465,7 @@ void path_range_query::compute_imports (bitmap imports, basic_block exit) { // Start with the imports from the exit block... - bitmap r_imports = m_ranger.gori ().imports (exit); + bitmap r_imports = m_ranger->gori ().imports (exit); bitmap_copy (imports, r_imports); auto_vec<tree> worklist (bitmap_count_bits (imports)); @@ -539,7 +552,7 @@ path_range_query::compute_ranges (const vec<basic_block> &path, if (m_resolve) { - gori_compute &gori = m_ranger.gori (); + gori_compute &gori = m_ranger->gori (); tree name; // Exported booleans along the path, may help conditionals. @@ -659,7 +672,7 @@ path_range_query::range_of_stmt (irange &r, gimple *stmt, tree) if (m_resolve) { fold_using_range f; - jt_fur_source src (stmt, this, &m_ranger.gori (), m_path); + jt_fur_source src (stmt, this, &m_ranger->gori (), m_path); if (!f.fold_stmt (r, stmt, src)) r.set_varying (type); } @@ -750,7 +763,7 @@ path_range_query::compute_outgoing_relations (basic_block bb, basic_block next) else gcc_unreachable (); - jt_fur_source src (NULL, this, &m_ranger.gori (), m_path); + jt_fur_source src (NULL, this, &m_ranger->gori (), m_path); src.register_outgoing_edges (cond, r, e0, e1); } } |