From 31a874e56aa2797072465ccc66068afa84a0bbd8 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 4 Feb 2026 14:41:45 -0500 Subject: [PATCH 14/30] Rename value_range::set_type to value_range::set_range_class value_range::set_type doesn't set the m_type of the underlying vrange; it merely sets m_vrange to use an appropriate vrange subclass for the given type. This confused me. This patch renames it to avoid other people being similarly confused. No functional change intended. gcc/ChangeLog: * data-streamer-in.cc (streamer_read_value_range): Update for renaming of value_range::set_type to value_range::set_range_class. * gimple-range-gori.cc (gori_compute::compute_operand_range): Likewise. (gori_compute::compute_operand1_and_operand2_range): Likewise. (gori_stmt_info::gori_stmt_info): Likewise. (gori_calc_operands): Likewise. (gori_name_helper): Likewise. * ipa-cp.cc (ipcp_vr_lattice::set_to_bottom): Likewise. * ipa-cp.h (ipcp_vr_lattice::init): Likewise. * ipa-fnsummary.cc (evaluate_properties_for_edge): Likewise. * ipa-prop.cc (ipa_vr::get_vrange): Likewise. * range-op.h (range_cast): Likewise. * value-range.h (value_range::set_type): Rename to... (value_range::set_range_class): ...this, and add a note to the leading comment that it doesn't set the type of the underlying vrange. (value_range::init): Add a similar note to the leading comment. gcc/analyzer/ChangeLog: * svalue.cc (unaryop_svalue::maybe_get_value_range): Update for renaming of value_range::set_type to value_range::set_range_class. (binop_svalue::maybe_get_value_range): Likewise. Signed-off-by: David Malcolm --- gcc/analyzer/svalue.cc | 4 ++-- gcc/data-streamer-in.cc | 2 +- gcc/gimple-range-gori.cc | 18 +++++++++--------- gcc/ipa-cp.cc | 2 +- gcc/ipa-cp.h | 2 +- gcc/ipa-fnsummary.cc | 3 ++- gcc/ipa-prop.cc | 2 +- gcc/range-op.h | 2 +- gcc/value-range.h | 12 +++++++----- 9 files changed, 25 insertions(+), 22 deletions(-) diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc index 74c2c0dbd4a..986f4d8a906 100644 --- a/gcc/analyzer/svalue.cc +++ b/gcc/analyzer/svalue.cc @@ -1592,7 +1592,7 @@ unaryop_svalue::maybe_get_value_range_1 (value_range &out) const a VARYING of the unknown value as the 2nd operand. */ value_range varying (type); varying.set_varying (type); - out.set_type (type); + out.set_range_class (type); if (handler.fold_range (out, type, arg_vr, varying)) return true; } @@ -1740,7 +1740,7 @@ binop_svalue::maybe_get_value_range_1 (value_range &out) const range_op_handler handler (m_op); if (handler) { - out.set_type (type); + out.set_range_class (type); if (handler.fold_range (out, get_type (), lhs, rhs)) return true; } diff --git a/gcc/data-streamer-in.cc b/gcc/data-streamer-in.cc index f2294260b5a..a4c2b0b6ba3 100644 --- a/gcc/data-streamer-in.cc +++ b/gcc/data-streamer-in.cc @@ -223,7 +223,7 @@ streamer_read_value_range (class lto_input_block *ib, data_in *data_in, tree type = stream_read_tree (ib, data_in); // Initialize the value_range to the correct type. - vr.set_type (type); + vr.set_range_class (type); if (is_a (vr)) { diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc index 1c0a2b9f797..939798c9d71 100644 --- a/gcc/gimple-range-gori.cc +++ b/gcc/gimple-range-gori.cc @@ -772,7 +772,7 @@ gori_compute::compute_operand_range (vrange &r, gimple *stmt, gimple *src_stmt; if (op1_in_chain) { - vr.set_type (TREE_TYPE (op1)); + vr.set_range_class (TREE_TYPE (op1)); if (!compute_operand1_range (vr, handler, lhs, src, vrel_ptr)) return false; src_stmt = SSA_NAME_DEF_STMT (op1); @@ -780,7 +780,7 @@ gori_compute::compute_operand_range (vrange &r, gimple *stmt, else { gcc_checking_assert (op2_in_chain); - vr.set_type (TREE_TYPE (op2)); + vr.set_range_class (TREE_TYPE (op2)); if (!compute_operand2_range (vr, handler, lhs, src, vrel_ptr)) return false; src_stmt = SSA_NAME_DEF_STMT (op2); @@ -1318,7 +1318,7 @@ gori_compute::compute_operand1_and_operand2_range (vrange &r, return false; // Now get the range thru op1. - vr.set_type (TREE_TYPE (handler.operand1 ())); + vr.set_range_class (TREE_TYPE (handler.operand1 ())); if (!compute_operand1_range (vr, handler, lhs, src, rel)) return false; src_stmt = SSA_NAME_DEF_STMT (handler.operand1 ()); @@ -1592,14 +1592,14 @@ gori_stmt_info::gori_stmt_info (vrange &lhs, gimple *stmt, range_query *q) fur_stmt src (stmt, q); if (op1) { - op1_range.set_type (TREE_TYPE (op1)); + op1_range.set_range_class (TREE_TYPE (op1)); src.get_operand (op1_range, op1); } // And satisfy the second operand for single op satements. if (op2) { - op2_range.set_type (TREE_TYPE (op2)); + op2_range.set_range_class (TREE_TYPE (op2)); src.get_operand (op2_range, op2); } else if (op1) @@ -1625,7 +1625,7 @@ gori_calc_operands (vrange &lhs, gimple *stmt, ssa_cache &r, range_query *q) // If there was already a range, leave it and do no further evaluation. if (si.ssa1 && !r.has_range (si.ssa1)) { - tmp.set_type (TREE_TYPE (si.ssa1)); + tmp.set_range_class (TREE_TYPE (si.ssa1)); if (si.calc_op1 (tmp, lhs, si.op2_range)) si.op1_range.intersect (tmp); if (!si.op1_range.varying_p ()) @@ -1640,7 +1640,7 @@ gori_calc_operands (vrange &lhs, gimple *stmt, ssa_cache &r, range_query *q) if (si.ssa2 && !r.has_range (si.ssa2)) { - tmp.set_type (TREE_TYPE (si.ssa2)); + tmp.set_range_class (TREE_TYPE (si.ssa2)); if (si.calc_op2 (tmp, lhs, si.op1_range)) si.op2_range.intersect (tmp); if (!si.op2_range.varying_p ()) @@ -1697,7 +1697,7 @@ gori_name_helper (vrange &r, tree name, vrange &lhs, gimple *stmt, // If there was already a range, leave it and do no further evaluation. if (si.ssa1) { - tmp.set_type (TREE_TYPE (si.ssa1)); + tmp.set_range_class (TREE_TYPE (si.ssa1)); if (si.calc_op1 (tmp, lhs, si.op2_range)) si.op1_range.intersect (tmp); gimple *src = SSA_NAME_DEF_STMT (si.ssa1); @@ -1709,7 +1709,7 @@ gori_name_helper (vrange &r, tree name, vrange &lhs, gimple *stmt, if (si.ssa2) { - tmp.set_type (TREE_TYPE (si.ssa2)); + tmp.set_range_class (TREE_TYPE (si.ssa2)); if (si.calc_op2 (tmp, lhs, si.op1_range)) si.op2_range.intersect (tmp); gimple *src = SSA_NAME_DEF_STMT (si.ssa2); diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index b4e01a92344..4311fd1fc85 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -891,7 +891,7 @@ ipcp_vr_lattice::set_to_bottom () but nothing else (union, intersect, etc). This allows us to set bottoms on any ranges, and is safe as all users of the lattice check for bottom first. */ - m_vr.set_type (void_type_node); + m_vr.set_range_class (void_type_node); m_vr.set_varying (void_type_node); return true; diff --git a/gcc/ipa-cp.h b/gcc/ipa-cp.h index 45da483e9ab..1f57681f249 100644 --- a/gcc/ipa-cp.h +++ b/gcc/ipa-cp.h @@ -261,7 +261,7 @@ inline void ipcp_vr_lattice::init (tree type) { if (type) - m_vr.set_type (type); + m_vr.set_range_class (type); // Otherwise m_vr will default to unsupported_range. m_recipient_only = false; diff --git a/gcc/ipa-fnsummary.cc b/gcc/ipa-fnsummary.cc index e187231dfb6..ff181113078 100644 --- a/gcc/ipa-fnsummary.cc +++ b/gcc/ipa-fnsummary.cc @@ -693,7 +693,8 @@ evaluate_properties_for_edge (struct cgraph_edge *e, bool inline_p, avals->m_known_value_ranges.safe_grow_cleared (count, true); for (int i = 0; i < count; ++i) - avals->m_known_value_ranges[i].set_type (void_type_node); + avals->m_known_value_ranges[i].set_range_class + (void_type_node); } avals->m_known_value_ranges[i] = vr; } diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc index 385912c3790..5076610d2be 100644 --- a/gcc/ipa-prop.cc +++ b/gcc/ipa-prop.cc @@ -177,7 +177,7 @@ ipa_vr::equal_p (const ipa_vr &o) const void ipa_vr::get_vrange (value_range &r) const { - r.set_type (m_type); + r.set_range_class (m_type); m_storage->get_vrange (r, m_type); } diff --git a/gcc/range-op.h b/gcc/range-op.h index 5b80583e02c..1fd84ca0713 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -370,7 +370,7 @@ range_cast (value_range &r, tree type) varying.set_varying (type); // Ensure we are in the correct mode for the call to fold. - r.set_type (type); + r.set_range_class (type); // Call op_convert, if it fails, the result is varying. if (!range_op_handler (CONVERT_EXPR).fold_range (r, type, tmp, varying)) diff --git a/gcc/value-range.h b/gcc/value-range.h index cb8e7fe2f26..eaf29236d99 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -767,13 +767,13 @@ public: // // Using any of the various constructors initializes the object // appropriately, but the default constructor is uninitialized and -// must be initialized either with set_type() or by assigning into it. +// must be initialized either with set_range_class() or by assigning into it. // // Assigning between incompatible types is allowed. For example if a // temporary holds an irange, you can assign an frange into it, and // all the right things will happen. However, before passing this // object to a function accepting a vrange, the correct type must be -// set. If it isn't, you can do so with set_type(). +// set. If it isn't, you can do so with set_range_class(). class value_range { @@ -784,7 +784,7 @@ public: value_range (tree, tree, value_range_kind kind = VR_RANGE); value_range (const value_range &); ~value_range (); - void set_type (tree type); + void set_range_class (tree type); vrange& operator= (const vrange &); value_range& operator= (const value_range &); bool operator== (const value_range &r) const; @@ -832,7 +832,7 @@ private: }; // The default constructor is uninitialized and must be initialized -// with either set_type() or with an assignment into it. +// with either set_range_class() or with an assignment into it. inline value_range::value_range () @@ -885,9 +885,10 @@ value_range::~value_range () // Initialize object to an UNDEFINED range that can hold ranges of // TYPE. Clean-up memory if there was a previous object. +// Note that this does *not* set the type of the underlying vrange. inline void -value_range::set_type (tree type) +value_range::set_range_class (tree type) { if (m_vrange) m_vrange->~vrange (); @@ -896,6 +897,7 @@ value_range::set_type (tree type) // Initialize object to an UNDEFINED range that can hold ranges of // TYPE. +// Note that this does *not* set the type of the underlying vrange. inline void value_range::init (tree type) -- 2.49.0