This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix pr21584
- From: Diego Novillo <dnovillo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 30 Jun 2005 17:27:02 -0400
- Subject: Fix pr21584
When we assign name tags to pointers, we need to traverse all
pointers, not just the dereferenced ones. This was causing SSA
verification failures because non-dereferenced pointers ended up
with a name tag (which in itself isn't a tragedy, the analyzer is
being a bit anal here).
I'm overhauling all of this in the next few days, but in the
meantime, this should fix the error. Will commit after testing.
* tree-ssa-alias.c (create_name_tags): Also process
non-dereferenced pointers.
testsuite/ChangeLog
* g++.dg/tree-ssa/pr21584-1.C: New test.
* g++.dg/tree-ssa/pr21584-2.C: New test.
Index: tree-ssa-alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-alias.c,v
retrieving revision 2.98
diff -d -u -p -r2.98 tree-ssa-alias.c
--- tree-ssa-alias.c 25 Jun 2005 02:01:32 -0000 2.98
+++ tree-ssa-alias.c 30 Jun 2005 21:22:09 -0000
@@ -782,10 +782,15 @@ create_name_tags (struct alias_info *ai)
{
size_t i;
- for (i = 0; i < VARRAY_ACTIVE_SIZE (ai->processed_ptrs); i++)
+ for (i = 1; i < num_ssa_names; i++)
{
- tree ptr = VARRAY_TREE (ai->processed_ptrs, i);
- struct ptr_info_def *pi = SSA_NAME_PTR_INFO (ptr);
+ tree ptr = ssa_name (i);
+ struct ptr_info_def *pi;
+
+ if (ptr == NULL_TREE || !POINTER_TYPE_P (TREE_TYPE (ptr)))
+ continue;
+
+ pi = SSA_NAME_PTR_INFO (ptr);
if (pi->pt_anything || !pi->is_dereferenced)
{
Index: testsuite/g++.dg/tree-ssa/pr21584-1.C
===================================================================
RCS file: testsuite/g++.dg/tree-ssa/pr21584-1.C
diff -N testsuite/g++.dg/tree-ssa/pr21584-1.C
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/g++.dg/tree-ssa/pr21584-1.C 30 Jun 2005 21:22:10 -0000
@@ -0,0 +1,38 @@
+extern "C" {
+
+extern char *strcpy (char *__restrict __dest, __const char *__restrict __src)
+ throw () __attribute__ ((__nonnull__ (1, 2)));
+
+extern char *foo (char *__restrict __s) throw ();
+}
+
+class cset {
+public:
+ cset();
+ int operator()(unsigned char) const;
+private:
+ char v[(127 * 2 + 1)+1];
+};
+
+inline int cset::operator()(unsigned char c) const
+{
+ return v[c];
+}
+
+extern cset csspace;
+
+void baz()
+{
+ char *vec;
+ char buf[512];
+
+ char *p = buf;
+ while (csspace(*p))
+ p++;
+
+ if (*p != '#' && (p = foo(buf)) != 0) {
+ vec = new char[10+ 1];
+ strcpy(vec, p);
+ }
+}
+
Index: testsuite/g++.dg/tree-ssa/pr21584-2.C
===================================================================
RCS file: testsuite/g++.dg/tree-ssa/pr21584-2.C
diff -N testsuite/g++.dg/tree-ssa/pr21584-2.C
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/g++.dg/tree-ssa/pr21584-2.C 30 Jun 2005 21:22:10 -0000
@@ -0,0 +1,22 @@
+extern char *strcpy (char *__restrict __dest, __const char *__restrict __src);
+
+extern char *foo (void);
+extern void *malloc(__SIZE_TYPE__) __attribute__((malloc));
+
+char v[100];
+
+void baz()
+{
+ char *vec;
+ char buf[512];
+
+ char *p = buf;
+ while (v[(*p)])
+ p++;
+
+ if (*p != '#' && (p = foo()) != 0) {
+ strcpy ((char*)malloc(10), p);
+ }
+}
+
+