This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR84803
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 12 Mar 2018 13:31:14 +0100 (CET)
- Subject: [PATCH] Fix PR84803
- Authentication-results: sourceware.org; auth=none
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);
+}