------- Comment #5 from ian at airs dot com  2008-05-06 14:23 -------
I introduced DECL_BASED_ON_RESTRICT_P because the conversion to SSA discarded
almost all information about restrict qualifiers.  The compiler was tracking
restrict qualifiers on the original variable, but not on the GIMPLE variables. 
The main use of restrict qualifiers at the RTL level is in the scheduler, and I
didn't realize that it would be possible to write a machine-independent test
case.

DECL_BASED_ON_RESTRICT_P is meant to indicate that the temporary has the same
restrict qualifiers as the DECL_GET_RESTRICT_BASE.  It's not meant to be a
general implementation of "based on" as defined by the standard.  It's only
meant to say "this GIMPLE temporary has the same restrict qualifiers as this
user variable."

This patch fixes the problem, although I haven't tested it.

Index: gimplify.c
===================================================================
--- gimplify.c  (revision 134283)
+++ gimplify.c  (working copy)
@@ -391,6 +391,13 @@ find_single_pointer_decl_1 (tree *tp, in
 {
   tree *pdecl = (tree *) data;

+  /* We are only looking for pointers at the same level as the
+     original tree; we must not look through any indirections.
+     Returning anything other than NULL_TREE will cause the caller to
+     not find a base.  */
+  if (REFERENCE_CLASS_P (*tp))
+    return *tp;
+
   if (DECL_P (*tp) && POINTER_TYPE_P (TREE_TYPE (*tp)))
     {
       if (*pdecl)
@@ -406,8 +413,9 @@ find_single_pointer_decl_1 (tree *tp, in
   return NULL_TREE;
 }

-/* Find the single DECL of pointer type in the tree T and return it.
-   If there are zero or more than one such DECLs, return NULL.  */
+/* Find the single DECL of pointer type in the tree T, used directly
+   rather than via an indirection, and return it.  If there are zero
+   or more than one such DECLs, return NULL.  */

 static tree
 find_single_pointer_decl (tree t)
@@ -418,7 +426,8 @@ find_single_pointer_decl (tree t)
     {
       /* find_single_pointer_decl_1 returns a nonzero value, causing
         walk_tree to return a nonzero value, to indicate that it
-        found more than one pointer DECL.  */
+        found more than one pointer DECL or that it found an
+        indirection.  */
       return NULL_TREE;
     }



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36013

Reply via email to