From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix PR84803
Date: Mon, 12 Mar 2018 12:31:00 -0000 [thread overview]
Message-ID: <alpine.LSU.2.20.1803121330140.18265@zhemvz.fhfr.qr> (raw)
The following fixes PR84803 where we have a memory reference
data-reference analysis thought it's not worth handling.
This properly guards the access.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard.
2018-03-12 Richard Biener <rguenther@suse.de>
PR tree-optimization/84803
* tree-if-conv.c (ifcvt_memrefs_wont_trap): Don't do anything
for refs DR analysis didn't process.
* gcc.dg/torture/pr84803.c: New testcase.
Index: gcc/tree-if-conv.c
===================================================================
--- gcc/tree-if-conv.c (revision 258445)
+++ gcc/tree-if-conv.c (working copy)
@@ -864,6 +864,11 @@ base_object_writable (tree ref)
static bool
ifcvt_memrefs_wont_trap (gimple *stmt, vec<data_reference_p> drs)
{
+ /* If DR didn't see a reference here we can't use it to tell
+ whether the ref traps or not. */
+ if (gimple_uid (stmt) == 0)
+ return false;
+
data_reference_p *master_dr, *base_master_dr;
data_reference_p a = drs[gimple_uid (stmt) - 1];
Index: gcc/testsuite/gcc.dg/torture/pr84803.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr84803.c (nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr84803.c (working copy)
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+
+long a;
+long *b;
+void c ();
+void d ();
+void
+e (long f)
+{
+ if (a)
+ *b = f;
+}
+void
+g ()
+{
+ c (g, e);
+}
+void
+c (int f, int h ())
+{
+ d (f, h, "");
+}
+void
+d (int f, int h (), char *i, char *k)
+{
+ int j;
+ d (f, h, i + 1, k);
+ while (--j)
+ h (*i);
+}
reply other threads:[~2018-03-12 12:31 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=alpine.LSU.2.20.1803121330140.18265@zhemvz.fhfr.qr \
--to=rguenther@suse.de \
--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).