diff options
author | Andrew MacLeod <amacleod@redhat.com> | 2024-06-26 14:53:54 -0400 |
---|---|---|
committer | Andrew MacLeod <amacleod@redhat.com> | 2024-06-28 13:49:25 -0400 |
commit | 5612541834c063dd4126fb059e59c5dc8d5f2f8e (patch) | |
tree | 751069bb7bb4941006374d9a8bbdb2d791161527 | |
parent | 7419b4fe48b48e44b27e2dadc9ff870f5e049077 (diff) | |
download | gcc-5612541834c063dd4126fb059e59c5dc8d5f2f8e.zip gcc-5612541834c063dd4126fb059e59c5dc8d5f2f8e.tar.gz gcc-5612541834c063dd4126fb059e59c5dc8d5f2f8e.tar.bz2 |
ssa_lazy_cache takes an optional bitmap_obstack pointer.
Allow ssa_lazy cache to allocate bitmaps from a client provided obstack
if so desired.
* gimple-range-cache.cc (ssa_lazy_cache::ssa_lazy_cache): Relocate here.
Check for provided obstack.
(ssa_lazy_cache::~ssa_lazy_cache): Relocate here. Free bitmap or obstack.
* gimple-range-cache.h (ssa_lazy_cache::ssa_lazy_cache): Move.
(ssa_lazy_cache::~ssa_lazy_cache): Move.
(ssa_lazy_cache::m_ob): New.
* gimple-range.cc (dom_ranger::dom_ranger): Iniitialize obstack.
(dom_ranger::~dom_ranger): Release obstack.
(dom_ranger::pre_bb): Create ssa_lazy_cache using obstack.
* gimple-range.h (m_bitmaps): New.
-rw-r--r-- | gcc/gimple-range-cache.cc | 26 | ||||
-rw-r--r-- | gcc/gimple-range-cache.h | 9 | ||||
-rw-r--r-- | gcc/gimple-range.cc | 4 | ||||
-rw-r--r-- | gcc/gimple-range.h | 1 |
4 files changed, 33 insertions, 7 deletions
diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index 6979a14..0fffd7c 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -683,6 +683,32 @@ ssa_cache::dump (FILE *f) } +// Construct an ssa_lazy_cache. If OB is specified, us it, otherwise use +// a local bitmap obstack. + +ssa_lazy_cache::ssa_lazy_cache (bitmap_obstack *ob) +{ + if (!ob) + { + bitmap_obstack_initialize (&m_bitmaps); + m_ob = &m_bitmaps; + } + else + m_ob = ob; + active_p = BITMAP_ALLOC (m_ob); +} + +// Destruct an sa_lazy_cache. Free the bitmap if it came from a different +// obstack, or release the obstack if it was a local one. + +ssa_lazy_cache::~ssa_lazy_cache () +{ + if (m_ob == &m_bitmaps) + bitmap_obstack_release (&m_bitmaps); + else + BITMAP_FREE (active_p); +} + // Return true if NAME has an active range in the cache. bool diff --git a/gcc/gimple-range-cache.h b/gcc/gimple-range-cache.h index 0ea34d3..539c067 100644 --- a/gcc/gimple-range-cache.h +++ b/gcc/gimple-range-cache.h @@ -78,12 +78,8 @@ protected: class ssa_lazy_cache : public ssa_cache { public: - inline ssa_lazy_cache () - { - bitmap_obstack_initialize (&m_bitmaps); - active_p = BITMAP_ALLOC (&m_bitmaps); - } - inline ~ssa_lazy_cache () { bitmap_obstack_release (&m_bitmaps); } + ssa_lazy_cache (bitmap_obstack *ob = NULL); + ~ssa_lazy_cache (); inline bool empty_p () const { return bitmap_empty_p (active_p); } virtual bool has_range (tree name) const; virtual bool set_range (tree name, const vrange &r); @@ -94,6 +90,7 @@ public: void merge (const ssa_lazy_cache &); protected: bitmap_obstack m_bitmaps; + bitmap_obstack *m_ob; bitmap active_p; }; diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc index 5df649e..7ba7d46 100644 --- a/gcc/gimple-range.cc +++ b/gcc/gimple-range.cc @@ -908,6 +908,7 @@ assume_query::dump (FILE *f) dom_ranger::dom_ranger () : m_global () { + bitmap_obstack_initialize (&m_bitmaps); m_freelist.create (0); m_freelist.truncate (0); m_bb.create (0); @@ -928,6 +929,7 @@ dom_ranger::~dom_ranger () } m_bb.release (); m_freelist.release (); + bitmap_obstack_release (&m_bitmaps); } // Implement range of EXPR on stmt S, and return it in R. @@ -1071,7 +1073,7 @@ dom_ranger::pre_bb (basic_block bb) if (!m_freelist.is_empty ()) e_cache = m_freelist.pop (); else - e_cache = new ssa_lazy_cache; + e_cache = new ssa_lazy_cache (&m_bitmaps); gcc_checking_assert (e_cache->empty_p ()); // If there is a single pred, check if there are any ranges on diff --git a/gcc/gimple-range.h b/gcc/gimple-range.h index 9117756..62bd8a8 100644 --- a/gcc/gimple-range.h +++ b/gcc/gimple-range.h @@ -116,6 +116,7 @@ public: void pre_bb (basic_block bb); void post_bb (basic_block bb); protected: + bitmap_obstack m_bitmaps; void range_in_bb (vrange &r, basic_block bb, tree name); DISABLE_COPY_AND_ASSIGN (dom_ranger); ssa_cache m_global; |