public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Andrew Macleod <amacleod@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-4283] Ensure ssa_name is still valid.
Date: Tue, 26 Sep 2023 18:29:19 +0000 (GMT)	[thread overview]
Message-ID: <20230926182919.0437F3858C66@sourceware.org> (raw)

https://gcc.gnu.org/g:c9dbace008e60255b10891f0c966b44a0225d7ab

commit r14-4283-gc9dbace008e60255b10891f0c966b44a0225d7ab
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Tue Sep 26 09:27:52 2023 -0400

    Ensure ssa_name is still valid.
    
    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.

Diff:
---
 gcc/testsuite/gcc.dg/pr111599.c | 16 ++++++++++++++++
 gcc/value-relation.cc           |  9 ++++++---
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/pr111599.c b/gcc/testsuite/gcc.dg/pr111599.c
new file mode 100644
index 00000000000..25880b759f7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr111599.c
@@ -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));
+}
diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc
index f2c668a0193..8fea4aad345 100644
--- a/gcc/value-relation.cc
+++ b/gcc/value-relation.cc
@@ -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);
+	}
     }
 }

                 reply	other threads:[~2023-09-26 18:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230926182919.0437F3858C66@sourceware.org \
    --to=amacleod@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).