[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 14:34:53 PDT 2020
efriedma added a comment.
LGTM
================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:2507
+ } else if (Value *V = emitStpCpy(CI->getArgOperand(0), CI->getArgOperand(2),
+ B, TLI)) {
+ // sprintf(dest, "%s", str) -> stpcpy(dest, str) - dest
----------------
This is basically the first place we're generating stpcpy "from scratch". That's probably okay, since gcc does it, but we should watch out for bug reports.
================
Comment at: llvm/test/Transforms/InstCombine/sprintf-1.ll:169
+define i32 @test_no_simplify3(i8* %dst, i8* %str) minsize {
+; CHECK-IPRINTF-LABEL: @test_no_simplify3(
+; CHECK-IPRINTF-NEXT: [[STPCPY:%.*]] = call i8* @stpcpy(i8* [[DST:%.*]], i8* [[STR:%.*]])
----------------
xbolva00 wrote:
> Should we do this under minsize or not?
>
> Extra sub in asm should be ok, but IR has sub and 2x ptrtoints now.
>
The ptrtoints are free at the assembly level; the total number of IR instructions isn't important.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85963/new/
https://reviews.llvm.org/D85963
More information about the llvm-commits
mailing list