aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2013-11-26 09:04:44 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2013-11-26 09:04:44 +0000
commite8e9e1cda43a2b56618172896acb62103cd6bab8 (patch)
tree875e2f1eb7d55bcfe34f90de766d02a788628b6a
parent65f5c720ad1356836df93ddd76b42051a7c96257 (diff)
downloadgcc-e8e9e1cda43a2b56618172896acb62103cd6bab8.zip
gcc-e8e9e1cda43a2b56618172896acb62103cd6bab8.tar.gz
gcc-e8e9e1cda43a2b56618172896acb62103cd6bab8.tar.bz2
re PR tree-optimization/59287 (points-to analysis confused by union accesses)
2013-11-26 Richard Biener <rguenther@suse.de> PR tree-optimization/59287 * tree-ssa-structalias.c (get_constraint_for_component_ref): Remove no longer necessary special-casing of union accesses. * gcc.dg/tree-ssa/alias-29.c: New testcase. From-SVN: r205380
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/alias-29.c27
-rw-r--r--gcc/tree-ssa-structalias.c23
4 files changed, 38 insertions, 23 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 17fafa1..9a820b5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2013-11-26 Richard Biener <rguenther@suse.de>
+ PR tree-optimization/59287
+ * tree-ssa-structalias.c (get_constraint_for_component_ref):
+ Remove no longer necessary special-casing of union accesses.
+
+2013-11-26 Richard Biener <rguenther@suse.de>
+
* pretty-print.c (output_buffer::~output_buffer): Really
free the obstacks.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2e9ff15..25d8873 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2013-11-26 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/59287
+ * gcc.dg/tree-ssa/alias-29.c: New testcase.
+
2013-11-25 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54485
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/alias-29.c b/gcc/testsuite/gcc.dg/tree-ssa/alias-29.c
new file mode 100644
index 0000000..4d57ca8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/alias-29.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized" } */
+
+union X {
+ int i;
+ void *p;
+};
+void bar (int);
+
+int * __attribute__((noinline,noclone))
+baz (int *p) { return p; }
+
+void foo (union X *x)
+{
+ struct Y { int i; } ystruct = {};
+ ystruct.i = * baz (&ystruct.i);
+ bar (x->i);
+}
+
+/* DSE and then DCE should be able to remove all uses of ystruct.
+ Formerly the union access for the parameter to bar let 'anything'
+ escape which made the call to bar possibly use ystruct and thus
+ prevent the store to ystruct.i from being eliminated. The call to
+ baz makes sure that ystruct has its address taken. */
+
+/* { dg-final { scan-tree-dump-not "ystruct" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 2851eae..6482e68 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -3163,29 +3163,6 @@ get_constraint_for_component_ref (tree t, vec<ce_s> *results,
return;
}
- /* Handle type-punning through unions. If we are extracting a pointer
- from a union via a possibly type-punning access that pointer
- points to anything, similar to a conversion of an integer to
- a pointer. */
- if (!lhs_p)
- {
- tree u;
- for (u = t;
- TREE_CODE (u) == COMPONENT_REF || TREE_CODE (u) == ARRAY_REF;
- u = TREE_OPERAND (u, 0))
- if (TREE_CODE (u) == COMPONENT_REF
- && TREE_CODE (TREE_TYPE (TREE_OPERAND (u, 0))) == UNION_TYPE)
- {
- struct constraint_expr temp;
-
- temp.offset = 0;
- temp.var = anything_id;
- temp.type = ADDRESSOF;
- results->safe_push (temp);
- return;
- }
- }
-
t = get_ref_base_and_extent (t, &bitpos, &bitsize, &bitmaxsize);
/* Pretend to take the address of the base, we'll take care of