diff options
author | Ryotaro Kasuga <kasuga.ryotaro@fujitsu.com> | 2025-08-08 10:58:13 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-08 10:58:13 +0900 |
commit | 05dd957cda663273ae0e5739656ffe701404f37c (patch) | |
tree | d892db99e3fe84474e3ed2afe4f7676d2a8a8d86 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 1458eb206fb652358b3ee7e75d95b52f3f4ac333 (diff) | |
download | llvm-05dd957cda663273ae0e5739656ffe701404f37c.zip llvm-05dd957cda663273ae0e5739656ffe701404f37c.tar.gz llvm-05dd957cda663273ae0e5739656ffe701404f37c.tar.bz2 |
[DA] Fix the check between Subscript and Size after delinearization (#151326)
Delinearization provides two values: the size of the array, and the
subscript of the access. DA checks their validity (`0 <= subscript <
size`), with some special handling. In particular, to ensure `subscript
< size`, calculate the maximum value of `subscript - size` and check if
it is negative. There was an issue in its process: when `subscript -
size` is expressed as an affine format like `init + step * i`, the value
in the last iteration (`start + step * (num_iterations - 1)`) was
assumed to be the maximum value. This assumption is incorrect in the
following cases:
- When `step` is negative
- When the AddRec wraps
This patch introduces extra checks to ensure the sign of `step` and
verify the existence of nsw/nuw flags.
Also, `isKnownNonNegative(S - smax(1, Size))` was used as a regular
check, which is incorrect when `Size` is negative. This patch also
replace it with `isKnownNonNegative(S - Size)`, although it's still
unclear whether using `isKnownNonNegative` is appropriate in the first
place.
Fix #150604
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions