diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2021-05-26 08:25:36 +0200 |
---|---|---|
committer | Aldy Hernandez <aldyh@redhat.com> | 2021-05-27 10:37:49 +0200 |
commit | 13dbaefefbab04d5137e718262d4b81cb9035784 (patch) | |
tree | 10bd8974fbd0de0e2d24809141685d726fa2aae1 /gcc/gimple-range.cc | |
parent | 95bef94c6c6c6cb7bf640068aea77c209bca7c65 (diff) | |
download | gcc-13dbaefefbab04d5137e718262d4b81cb9035784.zip gcc-13dbaefefbab04d5137e718262d4b81cb9035784.tar.gz gcc-13dbaefefbab04d5137e718262d4b81cb9035784.tar.bz2 |
Move global range code to value-query.cc.
This patch moves all the global range code from gimple-range.cc into
value-query.cc. It also moves get_range_info and get_ptr_nonnull from
tree-ssanames.c into their only uses, and removes external access to them.
gcc/ChangeLog:
* gimple-range.cc (get_range_global): Move to value-query.cc.
(gimple_range_global): Same.
(get_global_range_query): Same.
(global_range_query::range_of_expr): Same.
* gimple-range.h (class global_range_query): Move to
value-query.h.
(gimple_range_global): Same.
* tree-ssanames.c (get_range_info): Move to value-query.cc.
(get_ptr_nonnull): Same.
* tree-ssanames.h (get_range_info): Remove.
(get_ptr_nonnull): Remove.
* value-query.cc (get_ssa_name_range_info): Move from
tree-ssanames.c.
(get_ssa_name_ptr_info_nonnull): Same.
(get_range_global): Move from gimple-range.cc.
(gimple_range_global): Same.
(get_global_range_query): Same.
(global_range_query::range_of_expr): Same.
* value-query.h (class global_range_query): Move from
gimple-range.h.
(gimple_range_global): Same.
Diffstat (limited to 'gcc/gimple-range.cc')
-rw-r--r-- | gcc/gimple-range.cc | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index e351a84..b4dfaa9 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -1441,109 +1441,6 @@ trace_ranger::range_of_expr (irange &r, tree name, gimple *s) return trailer (idx, "range_of_expr", res, name, r); } -// Return the legacy global range for NAME if it has one, otherwise -// return VARYING. - -static void -get_range_global (irange &r, tree name) -{ - tree type = TREE_TYPE (name); - - if (SSA_NAME_IS_DEFAULT_DEF (name)) - { - tree sym = SSA_NAME_VAR (name); - // Adapted from vr_values::get_lattice_entry(). - // Use a range from an SSA_NAME's available range. - if (TREE_CODE (sym) == PARM_DECL) - { - // Try to use the "nonnull" attribute to create ~[0, 0] - // anti-ranges for pointers. Note that this is only valid with - // default definitions of PARM_DECLs. - if (POINTER_TYPE_P (type) - && ((cfun && nonnull_arg_p (sym)) || get_ptr_nonnull (name))) - r.set_nonzero (type); - else if (INTEGRAL_TYPE_P (type)) - { - get_range_info (name, r); - if (r.undefined_p ()) - r.set_varying (type); - } - else - r.set_varying (type); - } - // If this is a local automatic with no definition, use undefined. - else if (TREE_CODE (sym) != RESULT_DECL) - r.set_undefined (); - else - r.set_varying (type); - } - else if (!POINTER_TYPE_P (type) && SSA_NAME_RANGE_INFO (name)) - { - get_range_info (name, r); - if (r.undefined_p ()) - r.set_varying (type); - } - else if (POINTER_TYPE_P (type) && SSA_NAME_PTR_INFO (name)) - { - if (get_ptr_nonnull (name)) - r.set_nonzero (type); - else - r.set_varying (type); - } - else - r.set_varying (type); -} - -// ?? Like above, but only for default definitions of NAME. This is -// so VRP passes using ranger do not start with known ranges, -// otherwise we'd eliminate builtin_unreachables too early because of -// inlining. -// -// Without this restriction, the test in g++.dg/tree-ssa/pr61034.C has -// all of its unreachable calls removed too early. We should -// investigate whether we should just adjust the test above. - -value_range -gimple_range_global (tree name) -{ - gcc_checking_assert (gimple_range_ssa_p (name)); - tree type = TREE_TYPE (name); - - if (SSA_NAME_IS_DEFAULT_DEF (name)) - { - value_range vr; - get_range_global (vr, name); - return vr; - } - return value_range (type); -} - -// ---------------------------------------------- -// global_range_query implementation. - -global_range_query global_ranges; - -// Like get_range_query, but for accessing global ranges. - -range_query * -get_global_range_query () -{ - return &global_ranges; -} - -bool -global_range_query::range_of_expr (irange &r, tree expr, gimple *) -{ - tree type = TREE_TYPE (expr); - - if (!irange::supports_type_p (type) || !gimple_range_ssa_p (expr)) - return get_tree_range (r, expr); - - get_range_global (r, expr); - - return true; -} - gimple_ranger * enable_ranger (struct function *fun) { |