[PATCH] D47059: [InstCombine] Calloc-ed strings optimizations

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 21 05:52:50 PDT 2018


xbolva00 added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:207
 
+  // strncat("\0", str, len) -> strncpy("\0", str, len))
+  uint64_t DstLen = GetStringLength(Dst, TLI);
----------------
xbolva00 wrote:
> 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?
" memcpy + store null byte: ... Nope, cannot do this. It will copy bytes even after \0. Strncat does not do it.

I removed incorrect transformations for str(n)cat to str(n)cpy. So patch is done.


https://reviews.llvm.org/D47059





More information about the llvm-commits mailing list