aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-object-size.cc
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@gotplt.org>2024-09-17 18:32:52 -0400
committerSiddhesh Poyarekar <siddhesh@gotplt.org>2024-10-16 17:43:12 -0400
commit72ae35bbc90fea3bb0084187896b783c1451fd22 (patch)
tree8edf6692021e8f949466f120c22c52beaf3dd2cb /gcc/tree-object-size.cc
parent74caf97572d84c7c4503d10773e0f8e8544c50d9 (diff)
downloadgcc-72ae35bbc90fea3bb0084187896b783c1451fd22.zip
gcc-72ae35bbc90fea3bb0084187896b783c1451fd22.tar.gz
gcc-72ae35bbc90fea3bb0084187896b783c1451fd22.tar.bz2
tree-object-size: use size_for_offset in more cases
When wholesize != size, there is a reasonable opportunity for static object sizes also to be computed using size_for_offset, so use that. gcc/ChangeLog: * tree-object-size.cc (plus_stmt_object_size): Call SIZE_FOR_OFFSET for some negative offset cases. gcc/testsuite/ChangeLog: * gcc.dg/builtin-object-size-3.c (test9): Adjust test. * gcc.dg/builtin-object-size-4.c (test8): Likewise. Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
Diffstat (limited to 'gcc/tree-object-size.cc')
-rw-r--r--gcc/tree-object-size.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/tree-object-size.cc b/gcc/tree-object-size.cc
index 6544730..78faae7 100644
--- a/gcc/tree-object-size.cc
+++ b/gcc/tree-object-size.cc
@@ -1527,6 +1527,7 @@ plus_stmt_object_size (struct object_size_info *osi, tree var, gimple *stmt)
if (size_unknown_p (bytes, 0))
;
else if ((object_size_type & OST_DYNAMIC)
+ || bytes != wholesize
|| compare_tree_int (op1, offset_limit) <= 0)
bytes = size_for_offset (bytes, op1, wholesize);
/* In the static case, with a negative offset, the best estimate for