]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Don't save ssa-name pointer in dependency cache.
authorAndrew MacLeod <amacleod@redhat.com>
Tue, 25 Apr 2023 19:33:52 +0000 (15:33 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Wed, 26 Apr 2023 19:17:08 +0000 (15:17 -0400)
If the direct dependence fields point directly to an ssa-name,
its possible that an optimization frees an ssa-name, and the value
pointed to may now be in the free list.   Simply maintain the ssa
version number instead.

PR tree-optimization/109417
* gimple-range-gori.cc (range_def_chain::register_dependency):
Save the ssa version number, not the pointer.
(gori_compute::may_recompute_p): No need to check if a dependency
is in the free list.
* gimple-range-gori.h (class range_def_chain): Change ssa1 and ssa2
fields to be unsigned int instead of trees.
(ange_def_chain::depend1): Adjust.
(ange_def_chain::depend2): Adjust.
* gimple-range.h: Include "ssa.h" to inline ssa_name().

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

index d77e1f51ac20a5347e70b92b632fa1847b2cc483..5bba77c7b7b4eebb1de2b39394ecd9b3c58e1463 100644 (file)
@@ -182,9 +182,9 @@ range_def_chain::register_dependency (tree name, tree dep, basic_block bb)
 
   // Set the direct dependency cache entries.
   if (!src.ssa1)
-    src.ssa1 = dep;
-  else if (!src.ssa2 && src.ssa1 != dep)
-    src.ssa2 = dep;
+    src.ssa1 = SSA_NAME_VERSION (dep);
+  else if (!src.ssa2 && src.ssa1 != SSA_NAME_VERSION (dep))
+    src.ssa2 = SSA_NAME_VERSION (dep);
 
   // Don't calculate imports or export/dep chains if BB is not provided.
   // This is usually the case for when the temporal cache wants the direct
@@ -1316,7 +1316,7 @@ gori_compute::may_recompute_p (tree name, basic_block bb, int depth)
   // If the first dependency is not set, there is no recomputation.
   // Dependencies reflect original IL, not current state.   Check if the
   // SSA_NAME is still valid as well.
-  if (!dep1 || SSA_NAME_IN_FREE_LIST (dep1))
+  if (!dep1)
     return false;
 
   // Don't recalculate PHIs or statements with side_effects.
index 3ea4b45595b5300fee70405f3c87406a90e04486..526edc24b53a14a0f8b232b20f87261dad9910f1 100644 (file)
@@ -46,8 +46,8 @@ protected:
   bitmap_obstack m_bitmaps;
 private:
   struct rdc {
-   tree ssa1;          // First direct dependency
-   tree ssa2;          // Second direct dependency
+   unsigned int ssa1;          // First direct dependency
+   unsigned int ssa2;          // Second direct dependency
    bitmap bm;          // All dependencies
    bitmap m_import;
   };
@@ -66,7 +66,10 @@ range_def_chain::depend1 (tree name) const
   unsigned v = SSA_NAME_VERSION (name);
   if (v >= m_def_chain.length ())
     return NULL_TREE;
-  return m_def_chain[v].ssa1;
+  unsigned v1 = m_def_chain[v].ssa1;
+  if (!v1)
+    return NULL_TREE;
+  return ssa_name (v1);
 }
 
 // Return the second direct dependency for NAME, if there is one.
@@ -77,7 +80,10 @@ range_def_chain::depend2 (tree name) const
   unsigned v = SSA_NAME_VERSION (name);
   if (v >= m_def_chain.length ())
     return NULL_TREE;
-  return m_def_chain[v].ssa2;
+  unsigned v2 = m_def_chain[v].ssa2;
+  if (!v2)
+    return NULL_TREE;
+  return ssa_name (v2);
 }
 
 // GORI_MAP is used to accumulate what SSA names in a block can
index 7ed4d3870b8de22a70ac486e022bf73419b5cac9..b8ddca59d2d40872adf7b211242623a8c7c97272 100644 (file)
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_GIMPLE_RANGE_H
 #define GCC_GIMPLE_RANGE_H
 
+#include "ssa.h"
 #include "range.h"
 #include "value-query.h"
 #include "gimple-range-op.h"