OSDN Git Service

* c-common.c, c-decl.c, c-format.c, c-typeck.c: Use %D for
[pf3gnuchains/gcc-fork.git] / gcc / alias.c
index e096cbf..a0f77d5 100644 (file)
@@ -1,5 +1,5 @@
 /* Alias analysis for GNU C
-   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
    Contributed by John Carr (jfc@mit.edu).
 
@@ -122,6 +122,7 @@ static int nonlocal_referenced_p (rtx);
 static int nonlocal_set_p_1 (rtx *, void *);
 static int nonlocal_set_p (rtx);
 static void memory_modified_1 (rtx, rtx, void *);
+static void record_alias_subset (HOST_WIDE_INT, HOST_WIDE_INT);
 
 /* Set up all info needed to perform alias analysis on memory references.  */
 
@@ -377,36 +378,51 @@ find_base_decl (tree t)
     }
 }
 
-/* Return 1 if all the nested component references handled by
-   get_inner_reference in T are such that we can address the object in T.  */
+/* Return true if all nested component references handled by
+   get_inner_reference in T are such that we should use the alias set
+   provided by the object at the heart of T.
 
-int
-can_address_p (tree t)
+   This is true for non-addressable components (which don't have their
+   own alias set), as well as components of objects in alias set zero.
+   This later point is a special case wherein we wish to override the
+   alias set used by the component, but we don't have per-FIELD_DECL
+   assignable alias sets.  */
+
+bool
+component_uses_parent_alias_set (tree t)
 {
-  /* If we're at the end, it is vacuously addressable.  */
-  if (! handled_component_p (t))
-    return 1;
+  while (1)
+    {
+      /* If we're at the end, it vacuously uses its own alias set.  */
+      if (!handled_component_p (t))
+       return false;
 
-  /* Bitfields are never addressable.  */
-  else if (TREE_CODE (t) == BIT_FIELD_REF)
-    return 0;
+      switch (TREE_CODE (t))
+       {
+       case COMPONENT_REF:
+         if (DECL_NONADDRESSABLE_P (TREE_OPERAND (t, 1)))
+           return true;
+         break;
 
-  /* Fields are addressable unless they are marked as nonaddressable or
-     the containing type has alias set 0.  */
-  else if (TREE_CODE (t) == COMPONENT_REF
-          && ! DECL_NONADDRESSABLE_P (TREE_OPERAND (t, 1))
-          && get_alias_set (TREE_TYPE (TREE_OPERAND (t, 0))) != 0
-          && can_address_p (TREE_OPERAND (t, 0)))
-    return 1;
+       case ARRAY_REF:
+       case ARRAY_RANGE_REF:
+         if (TYPE_NONALIASED_COMPONENT (TREE_TYPE (TREE_OPERAND (t, 0))))
+           return true;
+         break;
 
-  /* Likewise for arrays.  */
-  else if ((TREE_CODE (t) == ARRAY_REF || TREE_CODE (t) == ARRAY_RANGE_REF)
-          && ! TYPE_NONALIASED_COMPONENT (TREE_TYPE (TREE_OPERAND (t, 0)))
-          && get_alias_set (TREE_TYPE (TREE_OPERAND (t, 0))) != 0
-          && can_address_p (TREE_OPERAND (t, 0)))
-    return 1;
+       case REALPART_EXPR:
+       case IMAGPART_EXPR:
+         break;
 
-  return 0;
+       default:
+         /* Bitfields and casts are never addressable.  */
+         return true;
+       }
+
+      t = TREE_OPERAND (t, 0);
+      if (get_alias_set (TREE_TYPE (t)) == 0)
+       return true;
+    }
 }
 
 /* Return the alias set for T, which may be either a type or an
@@ -450,9 +466,7 @@ get_alias_set (tree t)
        }
 
       /* Check for accesses through restrict-qualified pointers.  */
-      if (TREE_CODE (inner) == INDIRECT_REF
-         || TREE_CODE (inner) == ALIGN_INDIRECT_REF
-         || TREE_CODE (inner) == MISALIGNED_INDIRECT_REF)
+      if (INDIRECT_REF_P (inner))
        {
          tree decl = find_base_decl (TREE_OPERAND (inner, 0));
 
@@ -484,7 +498,7 @@ get_alias_set (tree t)
                       type, then we would believe that other subsets
                       of the pointed-to type (such as fields of that
                       type) do not conflict with the type pointed to
-                      by the restricted pointer.   */
+                      by the restricted pointer.  */
                    DECL_POINTER_ALIAS_SET (decl)
                      = pointed_to_alias_set;
                  else
@@ -510,7 +524,7 @@ get_alias_set (tree t)
 
       /* Otherwise, pick up the outermost object that we could have a pointer
         to, processing conversions as above.  */
-      while (handled_component_p (t) && ! can_address_p (t))
+      while (component_uses_parent_alias_set (t))
        {
          t = TREE_OPERAND (t, 0);
          STRIP_NOPS (t);
@@ -597,7 +611,7 @@ new_alias_set (void)
    It is illegal for SUPERSET to be zero; everything is implicitly a
    subset of alias set zero.  */
 
-void
+static void
 record_alias_subset (HOST_WIDE_INT superset, HOST_WIDE_INT subset)
 {
   alias_set_entry superset_entry;
@@ -1564,7 +1578,7 @@ get_addr (rtx x)
     where SIZE is the size in bytes of the memory reference.  If ADDR
     is not modified by the memory reference then ADDR is returned.  */
 
-rtx
+static rtx
 addr_side_effect_eval (rtx addr, int size, int n_refs)
 {
   int offset = 0;
@@ -1868,7 +1882,7 @@ static int
 aliases_everything_p (rtx mem)
 {
   if (GET_CODE (XEXP (mem, 0)) == AND)
-    /* If the address is an AND, its very hard to know at what it is
+    /* If the address is an AND, it's very hard to know at what it is
        actually pointing.  */
     return 1;
 
@@ -2008,9 +2022,7 @@ nonoverlapping_memrefs_p (rtx x, rtx y)
       moffsetx = adjust_offset_for_component_ref (exprx, moffsetx);
       exprx = t;
     }
-  else if (TREE_CODE (exprx) == INDIRECT_REF
-          || TREE_CODE (exprx) == ALIGN_INDIRECT_REF
-          || TREE_CODE (exprx) == MISALIGNED_INDIRECT_REF)
+  else if (INDIRECT_REF_P (exprx))
     {
       exprx = TREE_OPERAND (exprx, 0);
       if (flag_argument_noalias < 2
@@ -2027,9 +2039,7 @@ nonoverlapping_memrefs_p (rtx x, rtx y)
       moffsety = adjust_offset_for_component_ref (expry, moffsety);
       expry = t;
     }
-  else if (TREE_CODE (expry) == INDIRECT_REF
-           || TREE_CODE (expry) == ALIGN_INDIRECT_REF
-           || TREE_CODE (expry) == MISALIGNED_INDIRECT_REF)
+  else if (INDIRECT_REF_P (expry))
     {
       expry = TREE_OPERAND (expry, 0);
       if (flag_argument_noalias < 2