diff options
author | msebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-09-02 02:14:50 +0000 |
---|---|---|
committer | msebor <msebor@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-09-02 02:14:50 +0000 |
commit | 4e91a07b9010003cb22c22c20c6aa6417a57333b (patch) | |
tree | 8330dbb112ec47bbcf763663d1bd7051721bb3a6 /gcc/builtins.c | |
parent | 5510c0a06dc3ac4fdd7b76a9d10f216f4b26975b (diff) | |
download | gcc-4e91a07b9010003cb22c22c20c6aa6417a57333b.tar.gz |
PR tree-optimization/71831 - __builtin_object_size poor results with no
optimization
gcc/testsuite/ChangeLog:
PR tree-optimization/71831
* gcc.dg/builtin-object-size-16.c: New test.
* gcc.dg/builtin-object-size-17.c: New test.
gcc/ChangeLog:
PR tree-optimization/71831
* tree-object-size.h: Return bool instead of the size and add
argument for the size.
* tree-object-size.c (compute_object_offset): Update signature.
(addr_object_size): Same.
(compute_builtin_object_size): Return bool instead of the size
and add argument for the size. Handle POINTER_PLUS_EXPR when
optimization is disabled.
(expr_object_size): Adjust.
(plus_stmt_object_size): Adjust.
(pass_object_sizes::execute): Adjust.
* builtins.c (fold_builtin_object_size): Adjust.
* doc/extend.texi (Object Size Checking): Update.
* ubsan.c (instrument_object_size): Adjust.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239953 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index b981bcd281a..1073e35b17b 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -9615,7 +9615,7 @@ fold_builtin_object_size (tree ptr, tree ost) if (TREE_CODE (ptr) == ADDR_EXPR) { - bytes = compute_builtin_object_size (ptr, object_size_type); + compute_builtin_object_size (ptr, object_size_type, &bytes); if (wi::fits_to_tree_p (bytes, size_type_node)) return build_int_cstu (size_type_node, bytes); } @@ -9624,9 +9624,8 @@ fold_builtin_object_size (tree ptr, tree ost) /* If object size is not known yet, delay folding until later. Maybe subsequent passes will help determining it. */ - bytes = compute_builtin_object_size (ptr, object_size_type); - if (bytes != (unsigned HOST_WIDE_INT) (object_size_type < 2 ? -1 : 0) - && wi::fits_to_tree_p (bytes, size_type_node)) + if (compute_builtin_object_size (ptr, object_size_type, &bytes) + && wi::fits_to_tree_p (bytes, size_type_node)) return build_int_cstu (size_type_node, bytes); } |