OSDN Git Service

PR fortran/27553
[pf3gnuchains/gcc-fork.git] / gcc / tree-dfa.c
index 5af9753..9ff2bd5 100644 (file)
@@ -103,7 +103,7 @@ htab_t default_defs;
    various attributes for each variable used by alias analysis and the
    optimizer.  */
 
-static void
+static unsigned int
 find_referenced_vars (void)
 {
   htab_t vars_found;
@@ -123,6 +123,7 @@ find_referenced_vars (void)
       }
 
   htab_delete (vars_found);
+  return 0;
 }
 
 struct tree_opt_pass pass_referenced_vars =
@@ -236,6 +237,10 @@ tree
 make_rename_temp (tree type, const char *prefix)
 {
   tree t = create_tmp_var (type, prefix);
+
+  if (TREE_CODE (type) == COMPLEX_TYPE)
+    DECL_COMPLEX_GIMPLE_REG_P (t) = 1;
+
   if (referenced_vars)
     {
       add_referenced_tmp_var (t);
@@ -340,14 +345,14 @@ dump_variable (FILE *file, tree var)
   fprintf (file, ", ");
   print_generic_expr (file, TREE_TYPE (var), dump_flags);
 
-  if (ann && ann->type_mem_tag)
+  if (ann && ann->symbol_mem_tag)
     {
-      fprintf (file, ", type memory tag: ");
-      print_generic_expr (file, ann->type_mem_tag, dump_flags);
+      fprintf (file, ", symbol memory tag: ");
+      print_generic_expr (file, ann->symbol_mem_tag, dump_flags);
     }
 
-  if (ann && ann->is_alias_tag)
-    fprintf (file, ", is an alias tag");
+  if (ann && ann->is_aliased)
+    fprintf (file, ", is aliased");
 
   if (TREE_ADDRESSABLE (var))
     fprintf (file, ", is addressable");
@@ -359,7 +364,35 @@ dump_variable (FILE *file, tree var)
     fprintf (file, ", is volatile");
 
   if (is_call_clobbered (var))
-    fprintf (file, ", call clobbered");
+    {
+      fprintf (file, ", call clobbered");
+      if (dump_flags & TDF_DETAILS)
+       {
+         var_ann_t va = var_ann (var);
+         unsigned int escape_mask = va->escape_mask;
+         
+         fprintf (file, " (");
+         if (escape_mask & ESCAPE_STORED_IN_GLOBAL)
+           fprintf (file, ", stored in global");
+         if (escape_mask & ESCAPE_TO_ASM)
+           fprintf (file, ", goes through ASM");
+         if (escape_mask & ESCAPE_TO_CALL)
+           fprintf (file, ", passed to call");
+         if (escape_mask & ESCAPE_BAD_CAST)
+           fprintf (file, ", bad cast");
+         if (escape_mask & ESCAPE_TO_RETURN)
+           fprintf (file, ", returned from func");
+         if (escape_mask & ESCAPE_TO_PURE_CONST)
+           fprintf (file, ", passed to pure/const");
+         if (escape_mask & ESCAPE_IS_GLOBAL)
+           fprintf (file, ", is global var");
+         if (escape_mask & ESCAPE_IS_PARM)
+           fprintf (file, ", is incoming pointer");
+         if (escape_mask & ESCAPE_UNKNOWN)
+           fprintf (file, ", unknown escape");
+         fprintf (file, " )");
+       }
+    }
 
   if (default_def (var))
     {
@@ -593,20 +626,6 @@ find_vars_r (tree *tp, int *walk_subtrees, void *data)
 
 
 /* Lookup UID in the referenced_vars hashtable and return the associated
-   variable or NULL if it is not there.  */
-
-tree 
-referenced_var_lookup_if_exists (unsigned int uid)
-{
-  struct int_tree_map *h, in;
-  in.uid = uid;
-  h = (struct int_tree_map *) htab_find_with_hash (referenced_vars, &in, uid);
-  if (h)
-    return h->to;
-  return NULL_TREE;
-}
-
-/* Lookup UID in the referenced_vars hashtable and return the associated
    variable.  */
 
 tree 
@@ -715,15 +734,11 @@ add_referenced_var (tree var, struct walk_state *walk_state)
        *slot = (void *) var;
       
       referenced_var_insert (DECL_UID (var), var);
-
-      /* Global variables are always call-clobbered.  */
-      if (is_global_var (var))
-       mark_call_clobbered (var);
-
+      
       /* Tag's don't have DECL_INITIAL.  */
       if (MTAG_P (var))
        return;
-      
+
       /* Scan DECL_INITIAL for pointer variables as they may contain
         address arithmetic referencing the address of other
         variables.  */
@@ -792,6 +807,7 @@ mark_new_vars_to_rename (tree stmt)
   if (TREE_CODE (stmt) == PHI_NODE)
     return;
 
+  get_stmt_ann (stmt);
   vars_in_vops_to_rename = BITMAP_ALLOC (NULL);
 
   /* Before re-scanning the statement for operands, mark the existing
@@ -884,6 +900,7 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
   HOST_WIDE_INT maxsize = -1;
   tree size_tree = NULL_TREE;
   tree bit_offset = bitsize_zero_node;
+  bool seen_variable_array_ref = false;
 
   gcc_assert (!SSA_VAR_P (exp));
 
@@ -975,6 +992,11 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
                                    fold_convert (bitsizetype, index),
                                    bitsize_unit_node);
                bit_offset = size_binop (PLUS_EXPR, bit_offset, index);
+
+               /* An array ref with a constant index up in the structure
+                  hierarchy will constrain the size of any variable array ref
+                  lower in the access hierarchy.  */
+               seen_variable_array_ref = false;
              }
            else
              {
@@ -990,6 +1012,10 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
                  }
                else
                  maxsize = -1;
+
+               /* Remember that we have seen an array ref with a variable
+                  index.  */
+               seen_variable_array_ref = true;
              }
          }
          break;
@@ -1014,6 +1040,21 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
     }
  done:
 
+  /* We need to deal with variable arrays ending structures such as
+       struct { int length; int a[1]; } x;           x.a[d]
+       struct { struct { int a; int b; } a[1]; } x;  x.a[d].a
+       struct { struct { int a[1]; } a[1]; } x;      x.a[0][d], x.a[d][0]
+     where we do not know maxsize for variable index accesses to
+     the array.  The simplest way to conservatively deal with this
+     is to punt in the case that offset + maxsize reaches the
+     base type boundary.  */
+  if (seen_variable_array_ref
+      && maxsize != -1
+      && host_integerp (TYPE_SIZE (TREE_TYPE (exp)), 1)
+      && TREE_INT_CST_LOW (bit_offset) + maxsize
+        == TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp))))
+    maxsize = -1;
+
   /* ???  Due to negative offsets in ARRAY_REF we can end up with
      negative bit_offset here.  We might want to store a zero offset
      in this case.  */