[PATCH] Re: ref_contains_indirect_ref always false?

Richard Guenther rguenther@suse.de
Fri Nov 4 15:16:00 GMT 2005


On Fri, 4 Nov 2005, Diego Novillo wrote:

> On Friday 04 November 2005 09:45, Richard Guenther wrote:
> > On Fri, 4 Nov 2005, Diego Novillo wrote:
> > > On Friday 04 November 2005 08:34, Richard Guenther wrote:
> > > > 	* tree-flow-inline.h (ref_contains_indirect_ref): Deal
> > > > 	with INDIRECT_REF not in handled_component_p.
> > >
> > > If you handle INDIRECT_REF directly, then you are seemingly changing
> > > the semantics of the predicate.  The predicate says that it's
> > > expecting an ARRAY_REF as input.
> > >
> > > Point me to the bug you are trying to fix?  There wasn't enough
> > > context in your message.
> >
> > The bug is that as present, ref_contains_indirect_ref returns always
> > false, regardless of input.  Because handled_component_p returns false
> > for TREE_CODE (arg) == INDIRECT_REF.
> >
> OK.  In that case, let's use Kenner's version and add
> 
> #if defined ENABLE_CHECKING
> 	gcc_assert (handled_component_p (ref))
> #endif
> 
> at the start of both ref_contains_indirect_ref and ref_contains_array_ref.  
> The comment will need fixing, too.  Both predicates are supposed to handle 
> aggregates in general.

This is what I'm currently re-checking.

Richard.


2005-11-04  Richard Guenther  <rguenther@suse.de>

	* tree-flow-inline.h (ref_contains_indirect_ref): Make comment
	match the code and vice-versa.
	(ref_contains_array_ref): Likewise.
	* tree-ssa-structalias.c (find_func_aliases): Remove call to
	ref_contains_indirect_ref.

Index: tree-flow-inline.h
===================================================================
--- tree-flow-inline.h	(revision 106485)
+++ tree-flow-inline.h	(working copy)
@@ -1407,32 +1407,35 @@
   return TREE_READONLY (var) && (TREE_STATIC (var) || DECL_EXTERNAL (var));
 }
 
-/* Return true if REF, an ARRAY_REF, has an INDIRECT_REF somewhere in
-   it.  */
+/* Return true if REF, a handled component reference, has an INDIRECT_REF
+   somewhere in it.  */
 
 static inline bool
 ref_contains_indirect_ref (tree ref)
 {
-  while (handled_component_p (ref))
-    {
-      if (TREE_CODE (ref) == INDIRECT_REF)
-	return true;
-      ref = TREE_OPERAND (ref, 0);
-    }
-  return false;
+  gcc_assert (handled_component_p (ref));
+
+  do {
+    ref = TREE_OPERAND (ref, 0);
+  } while (handled_component_p (ref));
+
+  return TREE_CODE (ref) == INDIRECT_REF;
 }
 
-/* Return true if REF, a COMPONENT_REF, has an ARRAY_REF somewhere in it.  */
+/* Return true if REF, a handled component reference, has an ARRAY_REF
+   somewhere in it.  */
 
 static inline bool
 ref_contains_array_ref (tree ref)
 {
-  while (handled_component_p (ref))
-    {
-      if (TREE_CODE (ref) == ARRAY_REF)
-	return true;
-      ref = TREE_OPERAND (ref, 0);
-    }
+  gcc_assert (handled_component_p (ref));
+
+  do {
+    if (TREE_CODE (ref) == ARRAY_REF)
+      return true;
+    ref = TREE_OPERAND (ref, 0);
+  } while (handled_component_p (ref));
+
   return false;
 }
 
Index: tree-ssa-structalias.c
===================================================================
--- tree-ssa-structalias.c	(revision 106485)
+++ tree-ssa-structalias.c	(working copy)
@@ -2865,7 +2865,6 @@
 	     containing pointers, dereferences, and call expressions.  */
 	  if (POINTER_TYPE_P (TREE_TYPE (lhsop))
 	      || AGGREGATE_TYPE_P (TREE_TYPE (lhsop))
-	      || ref_contains_indirect_ref (lhsop)
 	      || TREE_CODE (rhsop) == CALL_EXPR)
 	    {
 	      lhs = get_constraint_for (lhsop, NULL);



More information about the Gcc-patches mailing list