[PATCH] D67986: [InstCombine] snprintf (d, size, "%s", s) -> memccpy (d, s, '\0', size - 1), d[size - 1] = 0

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 09:52:00 PDT 2019


lebedev.ri added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:2581
+              B.CreateSub(SizeArg, ConstantInt::get(SizeArg->getType(), 1));
+          emitMemCCpy(Dst, CI->getArgOperand(3), B.getInt32('\0'), DecSize, B,
+                      TLI);
----------------
Where did we ask TLI about the existence of `memccpy`?


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:2583
+                      TLI);
+          Value *DstEnd = B.CreateGEP(B.getInt8Ty(), Dst, DecSize);
+          B.CreateStore(B.getInt8(0), DstEnd);
----------------
It likely should be `CreateInBoundsGEP()`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67986/new/

https://reviews.llvm.org/D67986





More information about the llvm-commits mailing list