diff options
author | Siddhesh Poyarekar <siddhesh@gotplt.org> | 2022-01-11 16:07:29 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@gotplt.org> | 2022-01-11 20:14:42 +0530 |
commit | 026d44cbbd42653908f9faf6b80773f03e1bb1a0 (patch) | |
tree | b0b0e09370a25323a2e01a4664cc832626af619e /gcc/tree-object-size.c | |
parent | 71b72132011a47a4b39950d95718f18d1218978c (diff) | |
download | gcc-026d44cbbd42653908f9faf6b80773f03e1bb1a0.zip gcc-026d44cbbd42653908f9faf6b80773f03e1bb1a0.tar.gz gcc-026d44cbbd42653908f9faf6b80773f03e1bb1a0.tar.bz2 |
tree-optimization/103961: Never compute offset for -1 size
Never try to compute size for offset when the object size is -1, which
is either unknown maximum or uninitialized minimum irrespective of the
osi->pass number.
gcc/ChangeLog:
PR tree-optimization/103961
* tree-object-size.c (plus_stmt_object_size): Always avoid
computing offset for -1 size.
gcc/testsuite/ChangeLog:
PR tree-optimization/103961
* gcc.dg/pr103961.c: New test case.
Co-authored-by: Jakub Jelinek <jakub@redhat.com>
Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
Diffstat (limited to 'gcc/tree-object-size.c')
-rw-r--r-- | gcc/tree-object-size.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c index fbaf57a..f7cc323 100644 --- a/gcc/tree-object-size.c +++ b/gcc/tree-object-size.c @@ -990,13 +990,10 @@ plus_stmt_object_size (struct object_size_info *osi, tree var, gimple *stmt) addr_object_size (osi, op0, object_size_type, &bytes, &wholesize); } - /* In the first pass, do not compute size for offset if either the - maximum size is unknown or the minimum size is not initialized yet; - the latter indicates a dependency loop and will be resolved in - subsequent passes. We attempt to compute offset for 0 minimum size - too because a negative offset could be within bounds of WHOLESIZE, - giving a non-zero result for VAR. */ - if (osi->pass != 0 || !size_unknown_p (bytes, 0)) + /* size_for_offset doesn't make sense for -1 size, but it does for size 0 + since the wholesize could be non-zero and a negative offset could give + a non-zero size. */ + if (!size_unknown_p (bytes, 0)) bytes = size_for_offset (bytes, op1, wholesize); } else |