[llvm] [InstCombine] Support gep nuw in icmp folds (PR #118472)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 19 09:06:39 PST 2024
nikic wrote:
> > > > Could UBSan flag pointer arithmetic overflows?
> > >
> > >
> > > UBSan should already flag this.
> >
> >
> > Oh that's good. I guess we need to run it some more :-)
>
> I believe the sanitizer is `-fsanitize=pointer-overflow`, which we don't currently run, but I agree we should. The problem when I tried to enable it is that it _also_ flags `null + 0` in C, and basically nothing passes that. (Chromium won't even build because some code generating tool in Wayland fails it.) I had meant to go fix and/or add suppressions for those but haven't had time.
>
> Although, given that this [blatant language defect](https://davidben.net/2024/01/15/empty-slices.html) has been [acknowledged as a defect by the standards committee](https://developers.redhat.com/articles/2024/12/11/making-memcpynull-null-0-well-defined), perhaps it would make sense to either remove or recategorize that check in UBSan now.
Yes, I agree that we should change this to align with the newly adopted C semantics, and the change being part of https://www.open-std.org/jtc1/sc22/wg14/www/previous.html should give us the leeway to do this for old standards versions (combined with the fact that we have never used this for optimization in the first place). This should just be a matter of always using the C++ logic in: https://github.com/llvm/llvm-project/blob/2b9abf0db2d106c7208b4372e662ef5df869e6f1/clang/lib/CodeGen/CGExprScalar.cpp#L5869
https://github.com/llvm/llvm-project/pull/118472
More information about the llvm-commits
mailing list