[PATCH] D123628: [InstCombine] Fold memrchr calls with an excessive size to null.
Martin Sebor via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 13 09:09:22 PDT 2022
msebor added inline comments.
================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:903
+ // Fold out-of-bounds accesses to null.
+ return Constant::getNullValue(CI->getType());
+ }
----------------
nikic wrote:
> 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?
I don't yet know what the LLVM policy is for dealing with provably undefined code. I chose this because it seems like the lesser of the two evils (e.g., when passing in a negative/very large size). But I'm aware that some other handlers punt invalid calls to the library and I'm fine with that if it helps sanitizers detect the problem.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123628/new/
https://reviews.llvm.org/D123628
More information about the llvm-commits
mailing list