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

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 3 16:45:10 PDT 2019


xbolva00 added a comment.

>> I'm not sure this optimisation should be done for freestanding mode though.

I said it above, -ffreestanding disables this transformation too.

>> I'd make the argument that it should be strlcpy if present. That covers a lot of existing systems too.

strlcpy is good idea and it is faster than memccpy. but.. I need to link with -lbsd on Ubuntu.

I dont use BSD systems, so I am not gonna to do your suggested transformation since I cant test it. But patches are welcome, I will be happy to look at it if you send one here.


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

https://reviews.llvm.org/D67986





More information about the llvm-commits mailing list