aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2016-05-12 13:05:13 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2016-05-12 13:05:13 +0000
commit763baff6f54ec6070e0ec6497363f5116ab4c874 (patch)
tree84e63fa7e081279f7a68aca414b7f88e4487c667 /gcc
parentcf48d8c4dc0556d165cd369eb5fa4d77fe823e59 (diff)
downloadgcc-763baff6f54ec6070e0ec6497363f5116ab4c874.zip
gcc-763baff6f54ec6070e0ec6497363f5116ab4c874.tar.gz
gcc-763baff6f54ec6070e0ec6497363f5116ab4c874.tar.bz2
re PR middle-end/71062 (r235622 and restrict pointers)
2016-05-12 Richard Biener <rguenther@suse.de> PR tree-optimization/71062 * tree-ssa-alias.h (struct pt_solution): Add vars_contains_restrict field. * tree-ssa-structalias.c (set_uids_in_ptset): Set vars_contains_restrict if the var is a restrict tag. * tree-ssa-alias.c (ptrs_compare_unequal): If vars_contains_restrict do not disambiguate pointers against it. (dump_points_to_solution): Re-structure and adjust for new vars_contains_restrict flag. * gimple-pretty-print.c (pp_points_to_solution): Likewise. * gcc.dg/torture/pr71062.c: New testcase. From-SVN: r236174
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/gimple-pretty-print.c42
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr71062.c20
-rw-r--r--gcc/tree-ssa-alias.c43
-rw-r--r--gcc/tree-ssa-alias.h4
-rw-r--r--gcc/tree-ssa-structalias.c5
7 files changed, 106 insertions, 26 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 40f1b66..ddea24b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
+2016-05-12 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/71062
+ * tree-ssa-alias.h (struct pt_solution): Add vars_contains_restrict
+ field.
+ * tree-ssa-structalias.c (set_uids_in_ptset): Set vars_contains_restrict
+ if the var is a restrict tag.
+ * tree-ssa-alias.c (ptrs_compare_unequal): If vars_contains_restrict
+ do not disambiguate pointers against it.
+ (dump_points_to_solution): Re-structure and adjust for new
+ vars_contains_restrict flag.
+ * gimple-pretty-print.c (pp_points_to_solution): Likewise.
+
2016-05-12 Martin Liska <mliska@suse.cz>
* doc/invoke.texi: Explain connection between -fsanitize-recover=address
diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index e27214f..4b0dc7c 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -632,17 +632,37 @@ pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
}
pp_right_brace (buffer);
if (pt->vars_contains_nonlocal
- && pt->vars_contains_escaped_heap)
- pp_string (buffer, " (nonlocal, escaped heap)");
- else if (pt->vars_contains_nonlocal
- && pt->vars_contains_escaped)
- pp_string (buffer, " (nonlocal, escaped)");
- else if (pt->vars_contains_nonlocal)
- pp_string (buffer, " (nonlocal)");
- else if (pt->vars_contains_escaped_heap)
- pp_string (buffer, " (escaped heap)");
- else if (pt->vars_contains_escaped)
- pp_string (buffer, " (escaped)");
+ || pt->vars_contains_escaped
+ || pt->vars_contains_escaped_heap
+ || pt->vars_contains_restrict)
+ {
+ const char *comma = "";
+ pp_string (buffer, " (");
+ if (pt->vars_contains_nonlocal)
+ {
+ pp_string (buffer, "nonlocal");
+ comma = ", ";
+ }
+ if (pt->vars_contains_escaped)
+ {
+ pp_string (buffer, comma);
+ pp_string (buffer, "escaped");
+ comma = ", ";
+ }
+ if (pt->vars_contains_escaped_heap)
+ {
+ pp_string (buffer, comma);
+ pp_string (buffer, "escaped heap");
+ comma = ", ";
+ }
+ if (pt->vars_contains_restrict)
+ {
+ pp_string (buffer, comma);
+ pp_string (buffer, "restrict");
+ }
+ pp_string (buffer, ")");
+ }
+
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d61bb26..6dca22f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-05-12 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/71062
+ * gcc.dg/torture/pr71062.c: New testcase.
+
2016-05-12 Ilya Enkovich <ilya.enkovich@intel.com>
PR tree-optimization/71006
diff --git a/gcc/testsuite/gcc.dg/torture/pr71062.c b/gcc/testsuite/gcc.dg/torture/pr71062.c
new file mode 100644
index 0000000..cc01dda
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr71062.c
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+
+extern void abort (void);
+
+char bar;
+
+int __attribute__((noinline,noclone))
+foo (char *__restrict p)
+{
+ if (p == &bar)
+ return 1;
+ return 0;
+}
+
+int main()
+{
+ if (foo (&bar) != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 58920e0..b663ddf 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -363,14 +363,17 @@ ptrs_compare_unequal (tree ptr1, tree ptr2)
else if (obj1 && TREE_CODE (ptr2) == SSA_NAME)
{
struct ptr_info_def *pi = SSA_NAME_PTR_INFO (ptr2);
- if (!pi)
+ /* We may not use restrict to optimize pointer comparisons.
+ See PR71062. So we have to assume that restrict-pointed-to
+ may be in fact obj1. */
+ if (!pi || pi->pt.vars_contains_restrict)
return false;
return !pt_solution_includes (&pi->pt, obj1);
}
else if (TREE_CODE (ptr1) == SSA_NAME && obj2)
{
struct ptr_info_def *pi = SSA_NAME_PTR_INFO (ptr1);
- if (!pi)
+ if (!pi || pi->pt.vars_contains_restrict)
return false;
return !pt_solution_includes (&pi->pt, obj2);
}
@@ -521,17 +524,31 @@ dump_points_to_solution (FILE *file, struct pt_solution *pt)
fprintf (file, ", points-to vars: ");
dump_decl_set (file, pt->vars);
if (pt->vars_contains_nonlocal
- && pt->vars_contains_escaped_heap)
- fprintf (file, " (nonlocal, escaped heap)");
- else if (pt->vars_contains_nonlocal
- && pt->vars_contains_escaped)
- fprintf (file, " (nonlocal, escaped)");
- else if (pt->vars_contains_nonlocal)
- fprintf (file, " (nonlocal)");
- else if (pt->vars_contains_escaped_heap)
- fprintf (file, " (escaped heap)");
- else if (pt->vars_contains_escaped)
- fprintf (file, " (escaped)");
+ || pt->vars_contains_escaped
+ || pt->vars_contains_escaped_heap
+ || pt->vars_contains_restrict)
+ {
+ const char *comma = "";
+ fprintf (file, " (");
+ if (pt->vars_contains_nonlocal)
+ {
+ fprintf (file, "nonlocal");
+ comma = ", ";
+ }
+ if (pt->vars_contains_escaped)
+ {
+ fprintf (file, "%sescaped", comma);
+ comma = ", ";
+ }
+ if (pt->vars_contains_escaped_heap)
+ {
+ fprintf (file, "%sescaped heap", comma);
+ comma = ", ";
+ }
+ if (pt->vars_contains_restrict)
+ fprintf (file, "%srestrict", comma);
+ fprintf (file, ")");
+ }
}
}
diff --git a/gcc/tree-ssa-alias.h b/gcc/tree-ssa-alias.h
index 0593b05..6680cc0 100644
--- a/gcc/tree-ssa-alias.h
+++ b/gcc/tree-ssa-alias.h
@@ -47,7 +47,6 @@ struct GTY(()) pt_solution
includes memory at address NULL. */
unsigned int null : 1;
-
/* Nonzero if the vars bitmap includes a variable included in 'nonlocal'. */
unsigned int vars_contains_nonlocal : 1;
/* Nonzero if the vars bitmap includes a variable included in 'escaped'. */
@@ -55,6 +54,9 @@ struct GTY(()) pt_solution
/* Nonzero if the vars bitmap includes a anonymous heap variable that
escaped the function and thus became global. */
unsigned int vars_contains_escaped_heap : 1;
+ /* Nonzero if the vars bitmap includes a anonymous variable used to
+ represent storage pointed to by a restrict qualified pointer. */
+ unsigned int vars_contains_restrict : 1;
/* Set of variables that this pointer may point to. */
bitmap vars;
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 3956efd..5e3c7d0 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -6254,6 +6254,9 @@ set_uids_in_ptset (bitmap into, bitmap from, struct pt_solution *pt,
pt->vars_contains_escaped_heap = vi->is_heap_var;
}
+ if (vi->is_restrict_var)
+ pt->vars_contains_restrict = true;
+
if (TREE_CODE (vi->decl) == VAR_DECL
|| TREE_CODE (vi->decl) == PARM_DECL
|| TREE_CODE (vi->decl) == RESULT_DECL)
@@ -7505,7 +7508,7 @@ make_pass_build_ealias (gcc::context *ctxt)
/* IPA PTA solutions for ESCAPED. */
struct pt_solution ipa_escaped_pt
- = { true, false, false, false, false, false, false, false, NULL };
+ = { true, false, false, false, false, false, false, false, false, NULL };
/* Associate node with varinfo DATA. Worker for
cgraph_for_symbol_thunks_and_aliases. */