From: Aldy Hernandez Date: Tue, 16 May 2023 20:20:54 +0000 (+0200) Subject: Provide support for copying unsupported ranges. X-Git-Tag: basepoints/gcc-15~9205 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=615e3d1e9306dbf27c5af3bc6ebabb697dcc4297;p=thirdparty%2Fgcc.git Provide support for copying unsupported ranges. The unsupported_range class is provided for completness sake. It is a way to set VARYING/UNDEFINED ranges for unsupported ranges (currently anything not float, integer, or pointer). You can't do anything with them, except set_varying, and set_undefined. We will trap on any other operation. This patch provides a way to copy them, just in case they creep in. This could happen in IPA under certain circumstances. gcc/ChangeLog: * value-range.cc (vrange::operator=): Add a stub to copy unsupported ranges. * value-range.h (is_a ): New. (Value_Range::operator=): Support copying unsupported ranges. --- diff --git a/gcc/value-range.cc b/gcc/value-range.cc index 93c44a68365b..45b1e655967a 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -203,7 +203,10 @@ vrange::operator= (const vrange &src) else if (is_a (src)) as_a (*this) = as_a (src); else - gcc_unreachable (); + { + gcc_checking_assert (is_a (src)); + m_kind = src.m_kind; + } return *this; } diff --git a/gcc/value-range.h b/gcc/value-range.h index 0da2a42764a9..ab982d184022 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -460,6 +460,13 @@ is_a (vrange &v) return v.m_discriminator == VR_FRANGE; } +template <> +inline bool +is_a (vrange &v) +{ + return v.m_discriminator == VR_UNKNOWN; +} + // For resizable ranges, resize the range up to HARD_MAX_RANGES if the // NEEDED pairs is greater than the current capacity of the range. @@ -624,6 +631,11 @@ Value_Range::operator= (const vrange &r) m_frange = as_a (r); m_vrange = &m_frange; } + else if (is_a (r)) + { + m_unsupported = as_a (r); + m_vrange = &m_unsupported; + } else gcc_unreachable ();