tree-optimization/117355: object size for PHI nodes with negative offsets
When the object size estimate is returned for a PHI node, it is the
maximum possible value, which is fine in isolation. When combined with
negative offsets however, it may sometimes end up in zero size because
the resultant size was larger than the wholesize, leading
size_for_offset to conclude that there's a potential underflow. Fix
this by allowing a non-strict mode to size_for_offset, which
conservatively returns the size (or wholesize) in case of a negative
offset.
gcc/ChangeLog:
PR tree-optimization/117355
* tree-object-size.cc (size_for_offset): New argument STRICT,
return SZ if it is set to false.
(plus_stmt_object_size): Adjust call to SIZE_FOR_OFFSET.
gcc/testsuite/ChangeLog:
PR tree-optimization/117355
* g++.dg/ext/builtin-object-size2.C (test9): New test.
(main): Call it.
* gcc.dg/builtin-object-size-3.c (test10): Adjust expected size.
Signed-off-by:
Siddhesh Poyarekar <siddhesh@gotplt.org>
Showing
- gcc/testsuite/g++.dg/ext/builtin-object-size2.C 27 additions, 0 deletionsgcc/testsuite/g++.dg/ext/builtin-object-size2.C
- gcc/testsuite/gcc.dg/builtin-object-size-3.c 1 addition, 1 deletiongcc/testsuite/gcc.dg/builtin-object-size-3.c
- gcc/tree-object-size.cc 22 additions, 6 deletionsgcc/tree-object-size.cc
Loading
Please register or sign in to comment