]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Ensure ssa_name is still valid.
authorAndrew MacLeod <amacleod@redhat.com>
Tue, 26 Sep 2023 13:27:52 +0000 (09:27 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Tue, 26 Sep 2023 18:27:48 +0000 (14:27 -0400)
When the IL changes, an equivalence set may contain ssa_names that no
longer exist.  Ensure names are still valid and not in the free list.

PR tree-optimization/111599
gcc/
* value-relation.cc (relation_oracle::valid_equivs): Ensure
ssa_name is valid.

gcc/testsuite/
* gcc.dg/pr111599.c: New.

gcc/testsuite/gcc.dg/pr111599.c [new file with mode: 0644]
gcc/value-relation.cc

diff --git a/gcc/testsuite/gcc.dg/pr111599.c b/gcc/testsuite/gcc.dg/pr111599.c
new file mode 100644 (file)
index 0000000..25880b7
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fno-inline-functions-called-once -fno-inline-small-functions -fno-tree-dce -fno-tree-forwprop -fno-tree-fre" } */
+
+int h(void);
+void l(int);
+void func_56(int p_57, unsigned p_58) {
+ // p_57 = 0x101BC642L;
+  if (p_57 || h()) {
+    int *l_105[2];
+    l_105[0] = &p_57;
+    l(p_57);
+  }
+}
+void func_31(int p_33) {
+  func_56(0x101BC642L, (p_33));
+}
index f2c668a0193930055b10405ada671ddb069fb536..8fea4aad3458479dab44d5a1fdf7b72c4b51114b 100644 (file)
@@ -274,9 +274,12 @@ relation_oracle::valid_equivs (bitmap b, const_bitmap equivs, basic_block bb)
   EXECUTE_IF_SET_IN_BITMAP (equivs, 0, i, bi)
     {
       tree ssa = ssa_name (i);
-      const_bitmap ssa_equiv = equiv_set (ssa, bb);
-      if (ssa_equiv == equivs)
-       bitmap_set_bit (b, i);
+      if (ssa && !SSA_NAME_IN_FREE_LIST (ssa))
+       {
+         const_bitmap ssa_equiv = equiv_set (ssa, bb);
+         if (ssa_equiv == equivs)
+           bitmap_set_bit (b, i);
+       }
     }
 }