[Intrinsics] Added writeonly attribute to the first arg of llvm.memmove

D18714 introduced writeonly attribute:

"Also start using the attribute for memset, memcpy, and memmove intrinsics,
and remove their special-casing in BasicAliasAnalysis."

But actually, writeonly was not attached to memmove - oversight, it seems.

So let's add it. As we can see, this helps DSE to eliminate redundant stores.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D89724
This commit is contained in:
Dávid Bolvanský 2020-10-19 23:08:27 +02:00
parent 93671fffb5
commit d605a11993
3 changed files with 4 additions and 5 deletions

View File

@ -583,7 +583,8 @@ def int_memmove : Intrinsic<[],
llvm_i1_ty],
[IntrArgMemOnly, IntrWillReturn,
NoCapture<ArgIndex<0>>, NoCapture<ArgIndex<1>>,
ReadOnly<ArgIndex<1>>, ImmArg<ArgIndex<3>>]>;
WriteOnly<ArgIndex<0>>, ReadOnly<ArgIndex<1>>,
ImmArg<ArgIndex<3>>]>;
def int_memset : Intrinsic<[],
[llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty,
llvm_i1_ty],

View File

@ -29,8 +29,8 @@ define void @test2(i8* %p1, i8* %p2, i8* %p3) {
; CHECK: declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg)
; CHECK: declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg)
; CHECK: declare void @llvm.memmove.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i1 immarg)
; CHECK: declare void @llvm.memmove.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i1 immarg)
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i32, i1)
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly , i8* nocapture readonly, i64, i32, i1)
declare void @llvm.memmove.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1)
declare void @llvm.memmove.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1)

View File

@ -18,10 +18,8 @@ define void @test1(i8* noalias %A, i8* noalias %B) {
ret void
}
; FIXME: We should eliminate this dead store.
define void @test2(i8* noalias %A, i8* noalias %B) {
; CHECK-LABEL: @test2(
; CHECK-NEXT: store i8 0, i8* [[A:%.*]], align 1
; CHECK-NEXT: call void @llvm.memmove.p0i8.p0i8.i8(i8* [[A]], i8* [[B:%.*]], i8 12, i1 false)
; CHECK-NEXT: ret void
;