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

Benjamin Kramer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 21 03:43:33 PDT 2018


bkramer 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;
----------------
What if strlen(Src) < Len?


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:207
 
+  // strncat("\0", str, len) -> strncpy("\0", str, len))
+  uint64_t DstLen = GetStringLength(Dst, TLI);
----------------
Is this correct? strncpy fills the rest of the string with null bytes, strncat does not.


https://reviews.llvm.org/D47059





More information about the llvm-commits mailing list