aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2010-10-13 11:31:22 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2010-10-13 11:31:22 +0000
commitcb89b4b090f85ed09291748b898b589c4c4e96ee (patch)
treed167a412f3467bad90305f5fa28608e706da4e32 /gcc
parent72351fa31f66161bd2ce7fa996bc6b4fca3ad2ce (diff)
downloadgcc-cb89b4b090f85ed09291748b898b589c4c4e96ee.zip
gcc-cb89b4b090f85ed09291748b898b589c4c4e96ee.tar.gz
gcc-cb89b4b090f85ed09291748b898b589c4c4e96ee.tar.bz2
re PR tree-optimization/45982 (PTA does not track integers)
2010-10-13 Richard Guenther <rguenther@suse.de> PR tree-optimization/45982 * tree-ssa-structalias.c (make_constraints_to): New function. (make_constraint_to): Implement in terms of make_constraints_to. (find_func_aliases): Properly make return values of pure/const functions escape if they assign to sth that is not a pointer. * gcc.dg/torture/pr45982.c: New testcase. * gcc.dg/tree-ssa/pr24287.c: Adjust. * gcc.dg/tree-ssa/pta-callused.c: Likewise. * gcc.dg/torture/pr39074-2.c: Likewise. From-SVN: r165418
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr39074-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr45982.c27
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr24287.c6
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pta-callused.c4
-rw-r--r--gcc/tree-ssa-structalias.c33
7 files changed, 75 insertions, 13 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6793255..ee15bde 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,13 @@
2010-10-13 Richard Guenther <rguenther@suse.de>
+ PR tree-optimization/45982
+ * tree-ssa-structalias.c (make_constraints_to): New function.
+ (make_constraint_to): Implement in terms of make_constraints_to.
+ (find_func_aliases): Properly make return values of pure/const
+ functions escape if they assign to sth that is not a pointer.
+
+2010-10-13 Richard Guenther <rguenther@suse.de>
+
PR middle-end/45874
* cgraphunit.c (cgraph_redirect_edge_call_stmt_to_callee):
Fixup the CFG when EH was fixed up.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f5687e3..cd16614 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,13 @@
2010-10-13 Richard Guenther <rguenther@suse.de>
+ PR tree-optimization/45982
+ * gcc.dg/torture/pr45982.c: New testcase.
+ * gcc.dg/tree-ssa/pr24287.c: Adjust.
+ * gcc.dg/tree-ssa/pta-callused.c: Likewise.
+ * gcc.dg/torture/pr39074-2.c: Likewise.
+
+2010-10-13 Richard Guenther <rguenther@suse.de>
+
PR middle-end/45874
* g++.dg/torture/pr45874.C: New testcase.
diff --git a/gcc/testsuite/gcc.dg/torture/pr39074-2.c b/gcc/testsuite/gcc.dg/torture/pr39074-2.c
index a90c564..0ca8312 100644
--- a/gcc/testsuite/gcc.dg/torture/pr39074-2.c
+++ b/gcc/testsuite/gcc.dg/torture/pr39074-2.c
@@ -30,5 +30,5 @@ int main()
return 0;
}
-/* { dg-final { scan-tree-dump "y.._., points-to vars: { i }" "alias" } } */
+/* { dg-final { scan-tree-dump "y.._., points-to non-local, points-to escaped, points-to vars: { i }" "alias" } } */
/* { dg-final { cleanup-tree-dump "alias" } } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr45982.c b/gcc/testsuite/gcc.dg/torture/pr45982.c
new file mode 100644
index 0000000..497b0a9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr45982.c
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+
+#include <stdint.h>
+
+extern void abort (void);
+
+uintptr_t __attribute__((pure,noinline,noclone))
+foo (int *a)
+{
+ return (uintptr_t) a;
+}
+
+void __attribute__((noinline,noclone))
+bar (uintptr_t a)
+{
+ int *p = (int *)a;
+ *p = 1;
+}
+
+int main()
+{
+ int t = 0;
+ bar (foo (&t));
+ if (t != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr24287.c b/gcc/testsuite/gcc.dg/tree-ssa/pr24287.c
index 6312045..c264fbc 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr24287.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr24287.c
@@ -9,11 +9,14 @@ void link_error();
int g(void)
{
int t = 0, t1 = 2;
+ /* ??? That's not true. The pointers escape to the integer return
+ value which we do not track in PTA. */
int t2 = h(&t, &t1);
if (t != 0)
link_error ();
if (t1 != 2)
link_error ();
+ /* ??? And it would finally escape here even if we did. */
g1(t2);
if (t != 0)
link_error ();
@@ -21,5 +24,6 @@ int g(void)
link_error ();
return t2 == 2;
}
-/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized" } } */
+/* We are allowed to optimize the first two link_error calls. */
+/* { dg-final { scan-tree-dump-times "link_error" 2 "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pta-callused.c b/gcc/testsuite/gcc.dg/tree-ssa/pta-callused.c
index c2b512a..add5c87 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pta-callused.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pta-callused.c
@@ -5,7 +5,7 @@ struct Foo {
int *p, *q;
};
-int foo (int ***x) __attribute__((pure));
+int *foo (int ***x) __attribute__((pure));
int bar (int b)
{
@@ -19,7 +19,7 @@ int bar (int b)
q = &f.p;
else
q = &f.q;
- return foo (&q);
+ return *foo (&q);
}
/* { dg-final { scan-tree-dump "CALLUSED = { f.* i q }" "alias" } } */
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index c2a82ef..707e31c 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -3563,12 +3563,11 @@ do_structure_copy (tree lhsop, tree rhsop)
VEC_free (ce_s, heap, rhsc);
}
-/* Create a constraint ID = OP. */
+/* Create constraints ID = { rhsc }. */
static void
-make_constraint_to (unsigned id, tree op)
+make_constraints_to (unsigned id, VEC(ce_s, heap) *rhsc)
{
- VEC(ce_s, heap) *rhsc = NULL;
struct constraint_expr *c;
struct constraint_expr includes;
unsigned int j;
@@ -3577,9 +3576,18 @@ make_constraint_to (unsigned id, tree op)
includes.offset = 0;
includes.type = SCALAR;
- get_constraint_for_rhs (op, &rhsc);
FOR_EACH_VEC_ELT (ce_s, rhsc, j, c)
process_constraint (new_constraint (includes, *c));
+}
+
+/* Create a constraint ID = OP. */
+
+static void
+make_constraint_to (unsigned id, tree op)
+{
+ VEC(ce_s, heap) *rhsc = NULL;
+ get_constraint_for_rhs (op, &rhsc);
+ make_constraints_to (id, rhsc);
VEC_free (ce_s, heap, rhsc);
}
@@ -4334,8 +4342,7 @@ find_func_aliases (gimple origt)
of global memory but not of escaped memory. */
if (flags & (ECF_CONST|ECF_NOVOPS))
{
- if (gimple_call_lhs (t)
- && could_have_pointers (gimple_call_lhs (t)))
+ if (gimple_call_lhs (t))
handle_const_call (t, &rhsc);
}
/* Pure functions can return addresses in and of memory
@@ -4345,9 +4352,17 @@ find_func_aliases (gimple origt)
handle_pure_call (t, &rhsc);
else
handle_rhs_call (t, &rhsc);
- if (gimple_call_lhs (t)
- && could_have_pointers (gimple_call_lhs (t)))
- handle_lhs_call (t, gimple_call_lhs (t), flags, rhsc, fndecl);
+ if (gimple_call_lhs (t))
+ {
+ if (could_have_pointers (gimple_call_lhs (t)))
+ handle_lhs_call (t, gimple_call_lhs (t), flags, rhsc, fndecl);
+ /* Similar to conversions a result that is not a pointer
+ is an escape point for any pointer the function might
+ return. */
+ else if (flags & (ECF_CONST|ECF_PURE
+ |ECF_NOVOPS|ECF_LOOPING_CONST_OR_PURE))
+ make_constraints_to (escaped_id, rhsc);
+ }
VEC_free (ce_s, heap, rhsc);
}
else