[PATCH] D130922: [InstCombine] Add support for stpncpy folding
Martin Sebor via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 1 11:42:08 PDT 2022
msebor created this revision.
msebor added reviewers: efriedma, xbolva00, nikic.
Herald added a subscriber: hiraditya.
Herald added a project: All.
msebor requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
As in the case of `stlcpy`, the middle end support for `stpncpy` also consists solely of transforming calls to `__stpncpy_chk` to the standard function if the buffer overflow checking overhead can be avoided, but nothing else. Continuing in the same vein as D130666 <https://reviews.llvm.org/D130666>, this change extends the support for `stpncpy` to also optimize a subset of calls to it, analogously to `strncpy`. Both functions have the same semantics and differ only in the return value, with `stpncpy` returning a pointer either to the copied nul byte or to the last non-nul byte if the copy isn't a string. In addition, it extends the folding of calls to both functions to nonconstant bounds when the source string is empty.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D130922
Files:
llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/test/Transforms/InstCombine/simplify-libcalls.ll
llvm/test/Transforms/InstCombine/stpncpy-1.ll
llvm/test/Transforms/InstCombine/strcpy-nonzero-as.ll
llvm/test/Transforms/InstCombine/strncpy-1.ll
llvm/test/Transforms/InstCombine/strncpy-4.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130922.449068.patch
Type: text/x-patch
Size: 26500 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220801/a866b368/attachment.bin>
More information about the llvm-commits
mailing list