OSDN Git Service

2009-11-23 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Nov 2009 10:44:17 +0000 (10:44 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Nov 2009 10:44:17 +0000 (10:44 +0000)
* tree-dfa.c (get_ref_base_and_extent): Adjust maximum access
size for DECL bases.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154433 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/tree-dfa.c

index 9a26636..a00e858 100644 (file)
@@ -1,3 +1,8 @@
+2009-11-23  Richard Guenther  <rguenther@suse.de>
+
+       * tree-dfa.c (get_ref_base_and_extent): Adjust maximum access
+       size for DECL bases.
+
 2009-11-22  Richard Henderson  <rth@redhat.com>
 
        * i386.c (avx_vpermilp_parallel): New function.
index d1f84a2..20bdad2 100644 (file)
@@ -914,13 +914,23 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
      the array.  The simplest way to conservatively deal with this
      is to punt in the case that offset + maxsize reaches the
      base type boundary.  This needs to include possible trailing padding
-     that is there for alignment purposes.  */
+     that is there for alignment purposes.
 
-  if (seen_variable_array_ref
-      && maxsize != -1
-      && (!host_integerp (TYPE_SIZE (TREE_TYPE (exp)), 1)
-         || (bit_offset + maxsize
-             == (signed) TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp))))))
+     That is of course only true if the base object is not a decl.  */
+
+  if (DECL_P (exp))
+    {
+      /* If maxsize is unknown adjust it according to the size of the
+         base decl.  */
+      if (maxsize == -1
+         && host_integerp (DECL_SIZE (exp), 1))
+       maxsize = TREE_INT_CST_LOW (DECL_SIZE (exp)) - bit_offset;
+    }
+  else if (seen_variable_array_ref
+          && maxsize != -1
+          && (!host_integerp (TYPE_SIZE (TREE_TYPE (exp)), 1)
+              || (bit_offset + maxsize
+                  == (signed) TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp))))))
     maxsize = -1;
 
   /* ???  Due to negative offsets in ARRAY_REF we can end up with