tree-chkp.c (chkp_get_hard_register_var_fake_base_address): Rewritten to avoid overfl...
authorJakub Jelinek <jakub@redhat.com>
Tue, 20 Jun 2017 07:22:31 +0000 (09:22 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 20 Jun 2017 07:22:31 +0000 (09:22 +0200)
* tree-chkp.c (chkp_get_hard_register_var_fake_base_address):
Rewritten to avoid overflow for > 32-bit pointers.

From-SVN: r249398

gcc/ChangeLog
gcc/tree-chkp.c

index 331e1a49e680c20e946eedf2c9c35bc17a95c423..d46daf3d93e5bf1de1acc8bddfeeaba0befc0efe 100644 (file)
@@ -1,4 +1,7 @@
-2017-06-20  Jakub Jelinek  <jakub@redhat.com>
+2017-07-20  Jakub Jelinek  <jakub@redhat.com>
+
+       * tree-chkp.c (chkp_get_hard_register_var_fake_base_address):
+       Rewritten to avoid overflow for > 32-bit pointers.
 
        PR sanitizer/81125
        * ubsan.h (ubsan_encode_value): Workaround buggy clang++ parser
index ecac901d52b86e8f414b579018ff1530456a4be6..e241f50f308413c0d4ab5b6b8367cded7099c332 100644 (file)
@@ -690,9 +690,8 @@ chkp_erase_completed_bounds (void)
 static tree
 chkp_get_hard_register_var_fake_base_address ()
 {
-  tree base = fold_convert (ptr_type_node, integer_zero_node);
-  unsigned HOST_WIDE_INT offset = 1 << (TYPE_PRECISION (ptr_type_node) - 1);
-  return fold_build_pointer_plus_hwi (base, offset);
+  int prec = TYPE_PRECISION (ptr_type_node);
+  return wide_int_to_tree (ptr_type_node, wi::min_value (prec, SIGNED));
 }
 
 /* If we check bounds for a hard register variable, we cannot