]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Allow components to be shared among range-queries.
authorAndrew MacLeod <amacleod@redhat.com>
Fri, 17 May 2024 14:44:27 +0000 (10:44 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Thu, 23 May 2024 20:48:44 +0000 (16:48 -0400)
Ranger and the ranger cache need to share components, this provides a
blessed way to do so.

* gimple-range.cc (gimple_ranger::gimple_ranger): Share the
components from ranger_cache.
(gimple_ranger::~gimple_ranger): Don't clear pointer.
* value-query.cc (range_query::share_query): New.
(range_query::range_query): Clear shared component flag.
(range_query::~range_query): Don't free shared component copies.
* value-query.h (share_query): New prototype.
(m_shared_copy_p): New member.

gcc/gimple-range.cc
gcc/value-query.cc
gcc/value-query.h

index 9664300a80b968e78e7403f892afeab83a28e2ad..4326976fc2ab46bc656e6e4fc331601b87b5393a 100644 (file)
@@ -44,7 +44,7 @@ gimple_ranger::gimple_ranger (bool use_imm_uses) :
        current_bb (NULL)
 {
   // Share the oracle from the cache.
-  m_relation = &m_cache.relation ();
+  share_query (m_cache);
   if (dump_file && (param_ranger_debug & RANGER_DEBUG_TRACE))
     tracer.enable_trace ();
   m_stmt_list.create (0);
@@ -67,8 +67,6 @@ gimple_ranger::gimple_ranger (bool use_imm_uses) :
 
 gimple_ranger::~gimple_ranger ()
 {
-  // Restore the original oracle.
-  m_relation = NULL;
   m_stmt_list.release ();
 }
 
index db64a95a284f793cbbc9bd7f4f95a30507604059..adcc59cadbfcdc72303faf3f67c58208cee1c2df 100644 (file)
@@ -211,13 +211,24 @@ range_query::destroy_relation_oracle ()
     }
 }
 
+void
+range_query::share_query (range_query &q)
+{
+  m_relation = q.m_relation;
+  m_shared_copy_p = true;
+}
+
 range_query::range_query ()
 {
   m_relation = &default_relation_oracle;
+  m_shared_copy_p = false;
 }
 
 range_query::~range_query ()
 {
+  // Do not destroy anything if this is a shared copy.
+  if (m_shared_copy_p)
+    return;
   destroy_relation_oracle ();
 }
 
index a8688a099fac16ade234b3543bffdf0cc1b3789e..a5735902af054782fda653adf8dca88de2baf59a 100644 (file)
@@ -88,6 +88,11 @@ protected:
                             basic_block bbentry, basic_block bbexit);
   bool get_arith_expr_range (vrange &r, tree expr, gimple *stmt);
   relation_oracle *m_relation;
+  // When multiple related range queries wish to share oracles.
+  // This is an internal interface
+  void share_query (range_query &q);
+  bool m_shared_copy_p;
+
 };
 
 // Global ranges for SSA names using SSA_NAME_RANGE_INFO.