diff options
author | David Bolvansky <david.bolvansky@gmail.com> | 2019-09-17 17:12:24 +0000 |
---|---|---|
committer | David Bolvansky <david.bolvansky@gmail.com> | 2019-09-17 17:12:24 +0000 |
commit | 0c0de794f1affc7460eb90626b8483e4a0cbde6c (patch) | |
tree | 0e1328714d7f42863a740348cd00e954fa3efe94 /llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | |
parent | 5abd6f46ae8ae1a8b0f52b60fb52e1ba444b3d9b (diff) | |
download | bcm5719-llvm-0c0de794f1affc7460eb90626b8483e4a0cbde6c.tar.gz bcm5719-llvm-0c0de794f1affc7460eb90626b8483e4a0cbde6c.zip |
Reland "[SLC] Preserve attrs for strncpy(x, "", y) -> memset(align 1 x, '\0', y)"
llvm-svn: 372142
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp index 217f929e9ad..a5e31f21166 100644 --- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -610,7 +610,10 @@ Value *LibCallSimplifier::optimizeStrNCpy(CallInst *CI, IRBuilder<> &B) { if (SrcLen == 0) { // strncpy(x, "", y) -> memset(align 1 x, '\0', y) - B.CreateMemSet(Dst, B.getInt8('\0'), Size, 1); + CallInst *NewCI = B.CreateMemSet(Dst, B.getInt8('\0'), Size, 1); + AttrBuilder ArgAttrs(CI->getAttributes().getParamAttributes(0)); + NewCI->setAttributes(NewCI->getAttributes().addParamAttributes( + CI->getContext(), 0, ArgAttrs)); return Dst; } |