[PATCH] D130666: [InstCombine] Add support for strlcpy folding
Martin Sebor via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 16 13:45:58 PDT 2022
msebor added inline comments.
================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:699
+ annotateNonNullNoUndefBasedOnAccess(CI, 0);
+ annotateNonNullNoUndefBasedOnAccess(CI, 1);
+ }
----------------
efriedma wrote:
> strlcpy accesses the second argument no matter what the size is (so it can compute the return value).
You're absolutely right, thanks!
================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:726
+ bool NulTerm = false;
+ if (NBytes > SrcLen + 1) {
+ NBytes = SrcLen + 1;
----------------
efriedma wrote:
> `>=`?
That would work; at the same time, I was uneasy about `GetStringLength` not differentiating between an unterminated array and a string of the same length. I'd prefer to avoid assuming the source array is nul terminated, even though it's required to be. So I've replaced the call to `GetStringLength` with `getConstantStringInfo` and handled that case.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130666/new/
https://reviews.llvm.org/D130666
More information about the llvm-commits
mailing list