[PATCH] D85963: [SLC] sprintf(dst, "%s", str) -> strcpy(dst, str)

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 14 08:12:12 PDT 2020


efriedma added a comment.

In the case where we need the return value, there are a couple possible modifications:

1. Maybe worth checking if the length of the string is a known constant.
2. We could consider using stpcpy on targets where it's available.



================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:2501
+                      llvm::shouldOptimizeForSize(CI->getParent(), PSI, BFI,
+                                                  PGSOQueryType::IRPass);
+    if (OptForSize)
----------------
I don't think I've seen this `hasOptSize() || shouldOptimizeForSize()` pattern before; is there documentation anywhere?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85963



More information about the llvm-commits mailing list