]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ssa_lazy_cache takes an optional bitmap_obstack pointer.
authorAndrew MacLeod <amacleod@redhat.com>
Wed, 26 Jun 2024 18:53:54 +0000 (14:53 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Fri, 28 Jun 2024 17:49:25 +0000 (13:49 -0400)
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.

gcc/gimple-range-cache.cc
gcc/gimple-range-cache.h
gcc/gimple-range.cc
gcc/gimple-range.h

index 6979a14cbaaa0177d4a91325b1fd1886663e67f9..0fffd7c16a1c0f9547ee231214c3ebbdf835bd17 100644 (file)
@@ -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
index 0ea34d3f686fd84c53b14e04cb9a61c2cb5ca9e0..539c06753dd533dadf21b26b7c5ad75c88ac6eae 100644 (file)
@@ -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;
 };
 
index 5df649e268c668cc1687a190e131a2d1ad2a08c6..7ba7d464b5eaafe9db41893b5905d85b29abe2c4 100644 (file)
@@ -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
index 911775679470a1b336fc15a7eeced8d3e4544c34..62bd8a8711264eafa4bfa9ec363934740eaff05c 100644 (file)
@@ -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;