[llvm] r372142 - Reland "[SLC] Preserve attrs for strncpy(x, "", y) -> memset(align 1 x, '\0', y)"

Dávid Bolvanský via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 17 10:47:01 PDT 2019


Reverted: https://reviews.llvm.org/rL372125
But the test failure points to rather other commit -> relanded this commit.

More details: https://reviews.llvm.org/D67658



ut 17. 9. 2019 o 19:33 Roman Lebedev <lebedev.ri at gmail.com> napísal(a):

> On Tue, Sep 17, 2019 at 8:10 PM David Bolvansky via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
> >
> > Author: xbolva00
> > Date: Tue Sep 17 10:12:24 2019
> > New Revision: 372142
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=372142&view=rev
> > Log:
> > Reland "[SLC] Preserve attrs for strncpy(x, "", y) -> memset(align 1 x,
> '\0', y)"
> Commit message does not mention anything about the revert, or why it's
> being recommitted.
>
> > Modified:
> >     llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp
> >     llvm/trunk/test/Transforms/InstCombine/strncpy-1.ll
> >
> > Modified: llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp?rev=372142&r1=372141&r2=372142&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp (original)
> > +++ llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp Tue Sep 17
> 10:12:24 2019
> > @@ -610,7 +610,10 @@ Value *LibCallSimplifier::optimizeStrNCp
> >
> >    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;
> >    }
> >
> >
> > Modified: llvm/trunk/test/Transforms/InstCombine/strncpy-1.ll
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/strncpy-1.ll?rev=372142&r1=372141&r2=372142&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/test/Transforms/InstCombine/strncpy-1.ll (original)
> > +++ llvm/trunk/test/Transforms/InstCombine/strncpy-1.ll Tue Sep 17
> 10:12:24 2019
> > @@ -134,6 +134,16 @@ 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() {
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190917/745be307/attachment.html>


More information about the llvm-commits mailing list