With points-to about to be introduced, prange will now have a tree in the range storage object. This has not been the case until now, so there have been no GTY markers.

This patch adds a discriminator field to vrange and introduces the required GTY markers.

Bootstrapped on aarch64-unknown-linux-gnu  and x86_64-pc-linux-gnu  with no regressions.  Committed.

Andrew

From decdf14cc17dd62abc9c91707d06490a8da87b64 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <[email protected]>
Date: Fri, 29 May 2026 14:24:04 -0400
Subject: [PATCH 04/12] Add GTY to range_storage.

In preparation for a points to tree in prange, this patch adds GTY
markers to the vrange_storage classes.

	* value-range-storage.cc (irange_storage::irange_storage):
	Explicitly initialize vrange_storage.
	(prange_storage::prange_storage): Likewise.
	* value-range-storage.h (vrange_storage): Add GTY marker and
	discriminator field.
	(irange_storage): Add GTY marker.
	(prange_storage): Add GTY marker and friend GTY functions.
	(frange_storage): Add GTY marker and explcitly initialize
	vrange_storage.
---
 gcc/value-range-storage.cc |  4 ++--
 gcc/value-range-storage.h  | 21 ++++++++++++++-------
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/gcc/value-range-storage.cc b/gcc/value-range-storage.cc
index 58d4a3ba21a..b2b3e445590 100644
--- a/gcc/value-range-storage.cc
+++ b/gcc/value-range-storage.cc
@@ -296,7 +296,7 @@ irange_storage::alloc (vrange_internal_alloc &allocator, const irange &r)
 // Initialize the storage with R.
 
 irange_storage::irange_storage (const irange &r)
-  : m_max_ranges (r.num_pairs ())
+  : vrange_storage (VR_IRANGE), m_max_ranges (r.num_pairs ())
 {
   m_num_ranges = m_max_ranges;
   set_irange (r);
@@ -611,7 +611,7 @@ prange_storage::alloc (vrange_internal_alloc &allocator, const prange &r)
 
 // Initialize the storage with R.
 
-prange_storage::prange_storage (const prange &r)
+prange_storage::prange_storage (const prange &r) : vrange_storage (VR_PRANGE)
 {
   unsigned num_words;
   enum prange_kind kind = prange_format (r, num_words);
diff --git a/gcc/value-range-storage.h b/gcc/value-range-storage.h
index ebc2f6fda79..280aa65fe2d 100644
--- a/gcc/value-range-storage.h
+++ b/gcc/value-range-storage.h
@@ -46,7 +46,7 @@ private:
 // ggc_test_and_set_mark calls.  We ignore the derived classes, since
 // they don't contain any pointers.
 
-class GTY(()) vrange_storage
+class GTY((desc ("%h.m_discriminator"), tag("VR_UNKNOWN"))) vrange_storage
 {
 public:
   static vrange_storage *alloc (vrange_internal_alloc &, const vrange &);
@@ -54,14 +54,15 @@ public:
   void set_vrange (const vrange &r);
   bool fits_p (const vrange &r) const;
   bool equal_p (const vrange &r) const;
-protected:
+
   // Stack initialization disallowed.
-  vrange_storage () { }
+  vrange_storage (enum value_range_discriminator d) : m_discriminator (d) { }
+  const ENUM_BITFIELD(value_range_discriminator) m_discriminator : 4;
 };
 
 // Efficient memory storage for an irange.
 
-class irange_storage : public vrange_storage
+class GTY((tag ("VR_IRANGE"))) irange_storage: public vrange_storage
 {
 public:
   static irange_storage *alloc (vrange_internal_alloc &, const irange &);
@@ -113,15 +114,20 @@ enum prange_kind { PR_UNDEFINED,	// VR_UNDEFINED
 const unsigned int PRANGE_STORAGE_NINTS = 4;
 
 // Efficient memory storage for a prange.
-class prange_storage : public vrange_storage
+class GTY((tag ("VR_PRANGE"))) prange_storage : public vrange_storage
 {
 public:
+  friend void gt_ggc_mx_vrange_storage(void *);
+  friend void gt_pch_nx_vrange_storage(void *);
+  friend void gt_pch_p_14vrange_storage(void *, void *, gt_pointer_operator,
+					void *);
   static prange_storage *alloc (vrange_internal_alloc &, const prange &);
   void set_prange (const prange &r);
   void get_prange (prange &r, tree type) const;
   bool equal_p (const prange &r) const;
   bool fits_p (const prange &r) const;
   void dump () const;
+
 private:
   DISABLE_COPY_AND_ASSIGN (prange_storage);
   prange_storage (const prange &r);
@@ -143,7 +149,7 @@ private:
 
 // Efficient memory storage for an frange.
 
-class frange_storage : public vrange_storage
+class GTY((tag ("VR_FRANGE"))) frange_storage : public vrange_storage
 {
  public:
   static frange_storage *alloc (vrange_internal_alloc &, const frange &r);
@@ -152,7 +158,8 @@ class frange_storage : public vrange_storage
   bool equal_p (const frange &r) const;
   bool fits_p (const frange &) const;
  private:
-  frange_storage (const frange &r) { set_frange (r); }
+  frange_storage (const frange &r) : vrange_storage (VR_FRANGE)
+    { set_frange (r); }
   DISABLE_COPY_AND_ASSIGN (frange_storage);
 
   enum value_range_kind m_kind;
-- 
2.45.0

Reply via email to