This change implements folding of memrchr calls with constant bounds in excess of the size of the source array to null. This is done in preparation for a subsequent change that assumes the bound is valid.
Depends on D123626.
Differential D123628
[InstCombine] Bail on memrchr calls with an excessive size. msebor on Apr 12 2022, 1:33 PM. Authored by
Details
Diff Detail Event Timeline
Comment Actions Avoid folding memrchr calls with an excessive size to null. I'm open to treating such calls with unreachable if there is broader support for it. In my experience, some users/projects are in favor of it, others prefer the current approach of making the library call, and others still would like to see it replaced with a trap. Providing a compiler option would let each group choose what works best for them.
Comment Actions This patch was committed as part of the next one in the series so I'm abandoning it to keep it from popping up as ready to land. |
While this is correct, I do wonder whether we should be going out of our way to fold this to null, rather than simply bailing out of the transform. In particular, I wonder whether this will end up suppressing an asan/msan warning. It's okay to do that, as these are "best effort", but it's probably better to avoid if it doesn't cost us any additional effort?