[PATCH] D47059: [InstCombine] Calloc-ed strings optimizations
Dávid Bolvanský via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 21 03:53:54 PDT 2018
xbolva00 added inline comments.
================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:215
+ B.CreateMemCpy(Dst, 1, Src, 1,
+ ConstantInt::get(DL.getIntPtrType(CI->getContext()), Len));
+ return Dst;
----------------
bkramer wrote:
> What if strlen(Src) < Len?
That is ok
Len < SrcLen case is handled below...
and then we return emitStrLenMemCpy(Src, Dst, SrcLen, B);
================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:207
+ // strncat("\0", str, len) -> strncpy("\0", str, len))
+ uint64_t DstLen = GetStringLength(Dst, TLI);
----------------
bkramer wrote:
> Is this correct? strncpy fills the rest of the string with null bytes, strncat does not.
Good point. So we can do nothing at all in this case? or use memcpy + store null byte?
https://reviews.llvm.org/D47059
More information about the llvm-commits
mailing list