[llvm] [InstCombine] Support gep nuw in icmp folds (PR #118472)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 17 04:25:08 PST 2024
nikic wrote:
> I was thinking that ASan could use the shadow memory to detect when one operand is pointing to bad memory which is more than one element past valid memory. That way we could perhaps catch (some) instances of
>
> ```
> if (ptr + idx > end_ptr)
> ```
>
> Not sure if that's really practical though, and it still requires test coverage to catch anything.
This should probably directly operate on the `ptr + idx` rather than the comparison, as the GEP is where the UB is introduced. I also hit a case recently with `ptr - 1` where `ptr` is the base of an allocation, which is also UB but not diagnosed by anything.
It might make sense to experiment with this behind an option, as this probably adds a significant amount of overhead. (Though a separate check can be omitted for GEPs that are followed by an access, which is probably most of them.)
https://github.com/llvm/llvm-project/pull/118472
More information about the llvm-commits
mailing list