diff options
author | Siddhesh Poyarekar <siddhesh@gotplt.org> | 2022-01-14 08:56:15 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@gotplt.org> | 2022-01-14 11:51:44 +0530 |
commit | 17df585a3a6a852c71883cc2ff40e111a6875149 (patch) | |
tree | 99894075fe2ee96d9f4bc047c4f994bdfd859a86 /gcc/fold-const.c | |
parent | b77e3b4e4589e56c01511fabdbaadb029cd47f5c (diff) | |
download | gcc-17df585a3a6a852c71883cc2ff40e111a6875149.zip gcc-17df585a3a6a852c71883cc2ff40e111a6875149.tar.gz gcc-17df585a3a6a852c71883cc2ff40e111a6875149.tar.bz2 |
tree-optimization/104009: Conservative underflow estimate in object size
Restrict negative offset computation only to dynamic object sizes, where
size expressions are accurate and not a maximum/minimum estimate and in
cases where negative offsets definitely mean an underflow, e.g. in
MEM_REF of the whole object with negative ofset in addr_object_size.
This ends up missing some cases where __builtin_object_size could have
come up with more precise results, so tests have been adjusted to
reflect that.
gcc/ChangeLog:
PR tree-optimization/104009
* tree-object-size.c (compute_builtin_object_size): Bail out on
negative offset.
(plus_stmt_object_size): Return maximum of wholesize and minimum
of 0 for negative offset.
gcc/testsuite/ChangeLog:
PR tree-optimization/104009
* gcc.dg/builtin-object-size-1.c (test10): New test.
* gcc.dg/builtin-object-size-3.c (test10): Likewise.
(test9): Expect zero size for negative offsets.
* gcc.dg/builtin-object-size-4.c (test8): Likewise.
* gcc.dg/builtin-object-size-5.c (test7): Drop test for
__builtin_object_size.
Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
Diffstat (limited to 'gcc/fold-const.c')
0 files changed, 0 insertions, 0 deletions