* [PATCH] Add GTY support for irange.
@ 2021-04-26 14:27 Aldy Hernandez
2021-04-30 22:38 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: Aldy Hernandez @ 2021-04-26 14:27 UTC (permalink / raw)
To: Andrew MacLeod, GCC patches
Right now we have GTY support for static storage iranges
(int_range<>). However, there's no reason why the base
class can't be used with GC, other than it was an oversight.
For that matter, the base class has a pointer to the sub-range
storage, so we can use the same implementation for both. This
patch does so.
I have also removed the DEFINE_INT_RANGE_GC_STUBS
stuff, and have documented why we need a separate
gt_pch_nx (int_range<1> *&) version. This has to do with
hash-traits.h, which ipa-prop.c is using to store a value_range.
The header file hash-traits.h is defining an extern of
gt_pch_nx (int_range<1> *&) etc, instead of calling the
more generic (int_range<1> *) which is already available.
It seems suspect that has-traits.h has their own externs
for GC functions, and if someone has a better solution, I'd
be glad to hear it.
OK?
gcc/ChangeLog:
* value-range.cc (DEFINE_INT_RANGE_GC_STUBS): Remove.
(gt_pch_nx (int_range<1> *&)): New.
(gt_ggc_mx (int_range<1> *&)): New.
* value-range.h (class irange): Add GTY support for
the base class.
---
gcc/value-range.cc | 35 +++++++++++---------------
gcc/value-range.h | 63 ++++++++++++++++++++++++++++++----------------
2 files changed, 56 insertions(+), 42 deletions(-)
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index 6b0dfb439ba..f987386c91e 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -2050,26 +2050,20 @@ vrp_operand_equal_p (const_tree val1, const_tree val2)
return true;
}
-#define DEFINE_INT_RANGE_GC_STUBS(N) \
- void \
- gt_pch_nx (int_range<N> *&x) \
- { \
- for (unsigned i = 0; i < N; ++i) \
- { \
- gt_pch_nx (x->m_ranges[i * 2]); \
- gt_pch_nx (x->m_ranges[i * 2 + 1]); \
- } \
- } \
- \
- void \
- gt_ggc_mx (int_range<N> *&x) \
- { \
- for (unsigned i = 0; i < N; ++i) \
- { \
- gt_ggc_mx (x->m_ranges[i * 2]); \
- gt_ggc_mx (x->m_ranges[i * 2 + 1]); \
- } \
- }
+// ?? These stubs are for ipa-prop.c which use a value_range in a
+// hash_traits. hash-traits.h defines an extern of gt_ggc_mx (T &)
+// instead of picking up the gt_ggc_mx (T *) version.
+void
+gt_pch_nx (int_range<1> *&x)
+{
+ return gt_pch_nx ((irange *) x);
+}
+
+void
+gt_ggc_mx (int_range<1> *&x)
+{
+ return gt_ggc_mx ((irange *) x);
+}
#define DEFINE_INT_RANGE_INSTANCE(N) \
template int_range<N>::int_range(tree, tree, value_range_kind); \
@@ -2086,7 +2080,6 @@ DEFINE_INT_RANGE_INSTANCE(1)
DEFINE_INT_RANGE_INSTANCE(2)
DEFINE_INT_RANGE_INSTANCE(3)
DEFINE_INT_RANGE_INSTANCE(255)
-DEFINE_INT_RANGE_GC_STUBS(1)
#if CHECKING_P
#include "selftest.h"
diff --git a/gcc/value-range.h b/gcc/value-range.h
index d2c3ce958d3..b2075935a23 100644
--- a/gcc/value-range.h
+++ b/gcc/value-range.h
@@ -41,7 +41,7 @@ enum value_range_kind
//
// This is the base class without any storage.
-class irange
+class GTY((user)) irange
{
friend class irange_allocator;
public:
@@ -126,6 +126,10 @@ protected:
void copy_legacy_to_multi_range (const irange &);
private:
+ friend void gt_ggc_mx (irange *);
+ friend void gt_pch_nx (irange *);
+ friend void gt_pch_nx (irange *, gt_pointer_operator, void *);
+
void irange_set_1bit_anti_range (tree, tree);
bool irange_varying_p () const;
@@ -155,11 +159,10 @@ private:
template <unsigned X> friend void gt_pch_nx (int_range<X> *);
template <unsigned X> friend void gt_pch_nx (int_range<X> *,
gt_pointer_operator, void *);
- // ?? hash-traits.h has its own extern for these, which is causing
- // them to never be picked up by the templates. For now, define
- // elsewhere.
- //template<unsigned X> friend void gt_ggc_mx (int_range<X> *&);
- //template<unsigned X> friend void gt_pch_nx (int_range<X> *&);
+
+ // ?? These stubs are for ipa-prop.c which use a value_range in a
+ // hash_traits. hash-traits.h defines an extern of gt_ggc_mx (T &)
+ // instead of picking up the gt_ggc_mx (T *) version.
friend void gt_ggc_mx (int_range<1> *&);
friend void gt_pch_nx (int_range<1> *&);
@@ -335,39 +338,57 @@ range_includes_zero_p (const irange *vr)
return vr->may_contain_p (build_zero_cst (vr->type ()));
}
-template<unsigned N>
inline void
-gt_ggc_mx (int_range<N> *x)
+gt_ggc_mx (irange *x)
{
- for (unsigned i = 0; i < N; ++i)
+ for (unsigned i = 0; i < x->m_num_ranges; ++i)
{
- gt_ggc_mx (x->m_ranges[i * 2]);
- gt_ggc_mx (x->m_ranges[i * 2 + 1]);
+ gt_ggc_mx (x->m_base[i * 2]);
+ gt_ggc_mx (x->m_base[i * 2 + 1]);
}
}
-template<unsigned N>
inline void
-gt_pch_nx (int_range<N> *x)
+gt_pch_nx (irange *x)
{
- for (unsigned i = 0; i < N; ++i)
+ for (unsigned i = 0; i < x->m_num_ranges; ++i)
{
- gt_pch_nx (x->m_ranges[i * 2]);
- gt_pch_nx (x->m_ranges[i * 2 + 1]);
+ gt_pch_nx (x->m_base[i * 2]);
+ gt_pch_nx (x->m_base[i * 2 + 1]);
}
}
-template<unsigned N>
inline void
-gt_pch_nx (int_range<N> *x, gt_pointer_operator op, void *cookie)
+gt_pch_nx (irange *x, gt_pointer_operator op, void *cookie)
{
- for (unsigned i = 0; i < N; ++i)
+ for (unsigned i = 0; i < x->m_num_ranges; ++i)
{
- op (&x->m_ranges[i * 2], cookie);
- op (&x->m_ranges[i * 2 + 1], cookie);
+ op (&x->m_base[i * 2], cookie);
+ op (&x->m_base[i * 2 + 1], cookie);
}
}
+template<unsigned N>
+inline void
+gt_ggc_mx (int_range<N> *x)
+{
+ gt_ggc_mx ((irange *) x);
+}
+
+template<unsigned N>
+inline void
+gt_pch_nx (int_range<N> *x)
+{
+ gt_pch_nx ((irange *) x);
+}
+
+template<unsigned N>
+inline void
+gt_pch_nx (int_range<N> *x, gt_pointer_operator op, void *cookie)
+{
+ gt_pch_nx ((irange *) x, op, cookie);
+}
+
// Constructors for irange
inline
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Add GTY support for irange.
2021-04-26 14:27 [PATCH] Add GTY support for irange Aldy Hernandez
@ 2021-04-30 22:38 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2021-04-30 22:38 UTC (permalink / raw)
To: Aldy Hernandez, Andrew MacLeod, GCC patches
On 4/26/2021 8:27 AM, Aldy Hernandez via Gcc-patches wrote:
> Right now we have GTY support for static storage iranges
> (int_range<>). However, there's no reason why the base
> class can't be used with GC, other than it was an oversight.
>
> For that matter, the base class has a pointer to the sub-range
> storage, so we can use the same implementation for both. This
> patch does so.
>
> I have also removed the DEFINE_INT_RANGE_GC_STUBS
> stuff, and have documented why we need a separate
> gt_pch_nx (int_range<1> *&) version. This has to do with
> hash-traits.h, which ipa-prop.c is using to store a value_range.
> The header file hash-traits.h is defining an extern of
> gt_pch_nx (int_range<1> *&) etc, instead of calling the
> more generic (int_range<1> *) which is already available.
>
> It seems suspect that has-traits.h has their own externs
> for GC functions, and if someone has a better solution, I'd
> be glad to hear it.
>
> OK?
>
> gcc/ChangeLog:
>
> * value-range.cc (DEFINE_INT_RANGE_GC_STUBS): Remove.
> (gt_pch_nx (int_range<1> *&)): New.
> (gt_ggc_mx (int_range<1> *&)): New.
> * value-range.h (class irange): Add GTY support for
> the base class.
OK
jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-30 22:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-26 14:27 [PATCH] Add GTY support for irange Aldy Hernandez
2021-04-30 22:38 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).