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

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 10 12:59:07 PDT 2019


nickdesaulniers added a comment.

In D67986#1702901 <https://reviews.llvm.org/D67986#1702901>, @MaskRay wrote:

> This transformation seems to increase code size significantly. Is the snprintf "%s" pattern common enough? I suspect most projects have already used memccpy, stpncpy, strscpy, or strlcpy. For the few that don't, the performance probably does not matter.


Sounds like then maybe this optimization should conditionally occur based on optimization level/goals?  For instance, maybe it's not appropriate at `-Os`, but is at `-O2`?


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

https://reviews.llvm.org/D67986





More information about the llvm-commits mailing list