From: Krasimir Georgiev Date: Tue, 17 Sep 2019 14:15:23 +0000 (+0000) Subject: Revert "[SLC] Preserve attrs for strncpy(x, "", y) -> memset(align 1 x, '\0', y)" X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d5f8516fb76157042848d5b84d581873c7e5edbc;p=llvm Revert "[SLC] Preserve attrs for strncpy(x, "", y) -> memset(align 1 x, '\0', y)" Summary: This reverts commit r372101. Causes ASAN build bot failures: http://lab.llvm.org:8011/builders/sanitizer-ppc64be-linux/builds/14176 From http://lab.llvm.org:8011/builders/sanitizer-ppc64be-linux/builds/14176/steps/64-bit%20check-asan/logs/stdio: ``` [ RUN ] AddressSanitizer.StrNCatOOBTest /home/buildbots/ppc64be-sanitizer/sanitizer-ppc64be/build/llvm-project/compiler-rt/lib/asan/tests/asan_str_test.cpp:462: Failure Death test: strncat(to - 1, from, 0) Result: failed to die. ``` Subscribers: llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67658 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372125 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Utils/SimplifyLibCalls.cpp b/lib/Transforms/Utils/SimplifyLibCalls.cpp index a5e31f21166..217f929e9ad 100644 --- a/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -610,10 +610,7 @@ Value *LibCallSimplifier::optimizeStrNCpy(CallInst *CI, IRBuilder<> &B) { if (SrcLen == 0) { // strncpy(x, "", y) -> memset(align 1 x, '\0', y) - 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)); + B.CreateMemSet(Dst, B.getInt8('\0'), Size, 1); return Dst; } diff --git a/test/Transforms/InstCombine/strncpy-1.ll b/test/Transforms/InstCombine/strncpy-1.ll index 969358eb4d7..38e8cfedba2 100644 --- a/test/Transforms/InstCombine/strncpy-1.ll +++ b/test/Transforms/InstCombine/strncpy-1.ll @@ -134,16 +134,6 @@ define i8* @test2(i8* %dst) { ret i8* %ret } -define i8* @test3(i8* %dst, i32 %n) { -; CHECK-LABEL: @test3( -; CHECK-NEXT: call void @llvm.memset.p0i8.i32(i8* noalias nonnull align 1 dereferenceable(5) [[DST:%.*]], i8 0, i32 5, i1 false) -; CHECK-NEXT: ret i8* [[DST]] -; - %src = getelementptr [1 x i8], [1 x i8]* @null, i32 0, i32 0 - %ret = call i8* @strncpy(i8* noalias nonnull %dst, i8* nonnull %src, i32 5); - ret i8* %ret -} - ; Check cases that shouldn't be simplified. define void @test_no_simplify1() {