From: David Malcolm <dmalcolm@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: David Malcolm <dmalcolm@redhat.com>
Subject: [committed] analyzer: fix ICE with equiv_class constant (PR 93649)
Date: Tue, 11 Feb 2020 18:41:00 -0000 [thread overview]
Message-ID: <20200211184128.5109-1-dmalcolm@redhat.com> (raw)
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to master as r10-6580-gcd28b75921354c64fd4c8a1c238991e522abc38e.
gcc/analyzer/ChangeLog:
PR analyzer/93649
* constraint-manager.cc (constraint_manager::add_constraint): When
merging equivalence classes and updating m_constant, also update
m_cst_sid.
(constraint_manager::validate): If m_constant is non-NULL assert
that m_cst_sid is non-null and is valid.
gcc/testsuite/ChangeLog:
PR analyzer/93649
* gcc.dg/analyzer/torture/pr93649.c: New test.
---
gcc/analyzer/constraint-manager.cc | 8 ++-
.../gcc.dg/analyzer/torture/pr93649.c | 66 +++++++++++++++++++
2 files changed, 72 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/analyzer/torture/pr93649.c
diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-manager.cc
index d5a6939e714..a6235435681 100644
--- a/gcc/analyzer/constraint-manager.cc
+++ b/gcc/analyzer/constraint-manager.cc
@@ -686,8 +686,8 @@ constraint_manager::add_constraint (equiv_class_id lhs_ec_id,
if (rhs_ec_obj.m_constant)
{
- //gcc_assert (lhs_ec_obj.m_constant == NULL);
lhs_ec_obj.m_constant = rhs_ec_obj.m_constant;
+ lhs_ec_obj.m_cst_sid = rhs_ec_obj.m_cst_sid;
}
/* Drop rhs equivalence class, overwriting it with the
@@ -1516,7 +1516,11 @@ constraint_manager::validate () const
gcc_assert (sid->as_int () < get_num_svalues ());
}
if (ec->m_constant)
- gcc_assert (CONSTANT_CLASS_P (ec->m_constant));
+ {
+ gcc_assert (CONSTANT_CLASS_P (ec->m_constant));
+ gcc_assert (!ec->m_cst_sid.null_p ());
+ gcc_assert (ec->m_cst_sid.as_int () < get_num_svalues ());
+ }
#if 0
else
gcc_assert (ec->m_vars.length () > 0);
diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/pr93649.c b/gcc/testsuite/gcc.dg/analyzer/torture/pr93649.c
new file mode 100644
index 00000000000..9d929395bb4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/torture/pr93649.c
@@ -0,0 +1,66 @@
+/* { dg-additional-options "-Wno-incompatible-pointer-types -Wno-analyzer-too-complex" } */
+/* TODO: ideally we shouldn't have -Wno-analyzer-too-complex above; it
+ appears to be needed due to the recursion. */
+
+struct tz {
+ int qc;
+};
+
+struct wp {
+ struct tz *p2;
+} *ov;
+
+struct dz {
+ struct wp *r5;
+};
+
+void
+za (void);
+
+void
+h5 (struct dz *);
+
+int
+e7 (struct wp *f2)
+{
+ return f2 == ov;
+}
+
+void
+wr (struct wp *sw)
+{
+ if (sw != 0)
+ za ();
+}
+
+void
+m6 (const struct dz *gq)
+{
+ wr (gq->r5);
+
+ asm ("" : "+m" (gq));
+
+ if (0)
+ {
+ asm ("" : "+m" (gq->r5->p2->qc));
+ asm ("" : "+m" (gq->r5->p2->qc));
+ }
+
+ asm ("" : "+m" (gq->r5->p2->qc));
+
+ if (e7 (gq->r5))
+ za ();
+}
+
+void
+ts (struct dz *cx)
+{
+ struct dz nt;
+
+ if (nt.r5)
+ {
+ m6 (cx);
+ h5 (cx);
+ ts (&cx);
+ }
+}
--
2.21.0
reply other threads:[~2020-02-11 18:41 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=20200211184128.5109-1-dmalcolm@redhat.com \
--to=dmalcolm@redhat.com \
--cc=gcc-patches@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).