[PATCH] D130922: [InstCombine] Add support for stpncpy folding
Martin Sebor via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 10 16:37:01 PDT 2022
msebor planned changes to this revision.
msebor added inline comments.
================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:699
Value *Size = CI->getArgOperand(2);
annotateNonNullNoUndefBasedOnAccess(CI, 0);
if (isKnownNonZero(Size, DL))
----------------
Both `stpncpy` and `strncpy` access the destination only when `Size` is nonzero but not otherwise. (Annotating the argument unconditionally is a pre-existing bug in the code.)
================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:784
+
+ Value *Off = B.getInt64(SrcLen);
+ return B.CreateInBoundsGEP(B.getInt8Ty(), Dst, Off, "endptr");
----------------
`stpncpy(D, S, N)` returns `D + min(strlen(S), N)` as documented but not correctly verified in the new `stpcpy-1.ll` test.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130922/new/
https://reviews.llvm.org/D130922
More information about the llvm-commits
mailing list