]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc/
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Nov 2013 11:57:06 +0000 (11:57 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Nov 2013 11:57:06 +0000 (11:57 +0000)
* tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Avoid signed
overflow.  Use tree_to_shwi.

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

gcc/ChangeLog
gcc/tree-ssa-alias.c

index b83dc021ae5d7076660a90c98a8e23656cbfe03f..17c4c2457b1168bc0e70c72a62ad33a65984115a 100644 (file)
@@ -1,3 +1,8 @@
+2013-11-20  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       * tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Avoid signed
+       overflow.  Use tree_to_shwi.
+
 2013-11-20  Richard Sandiford  <rdsandiford@googlemail.com>
 
        * fold-const.c (fold_binary_loc): Use unsigned rather than signed
index ef9fbfecdc9173462f02b7572421bdd1dd3e1a36..a8be8181bd77f47b8692764a88992ee821f59705 100644 (file)
@@ -578,7 +578,7 @@ ao_ref_alias_set (ao_ref *ref)
 void
 ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size)
 {
-  HOST_WIDE_INT t, extra_offset = 0;
+  HOST_WIDE_INT t, size_hwi, extra_offset = 0;
   ref->ref = NULL_TREE;
   if (TREE_CODE (ptr) == SSA_NAME)
     {
@@ -617,9 +617,8 @@ ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size)
   ref->offset += extra_offset;
   if (size
       && tree_fits_shwi_p (size)
-      && TREE_INT_CST_LOW (size) * BITS_PER_UNIT / BITS_PER_UNIT
-        == TREE_INT_CST_LOW (size))
-    ref->max_size = ref->size = TREE_INT_CST_LOW (size) * BITS_PER_UNIT;
+      && (size_hwi = tree_to_shwi (size)) <= HOST_WIDE_INT_MAX / BITS_PER_UNIT)
+    ref->max_size = ref->size = size_hwi * BITS_PER_UNIT;
   else
     ref->max_size = ref->size = -1;
   ref->ref_alias_set = 0;