[PATCH] D89724: [Intrinsics] Added writeonly attribute to the first arg of llvm.memmove
Dávid Bolvanský via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 19 13:14:36 PDT 2020
xbolva00 created this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
xbolva00 requested review of this revision.
Herald added a subscriber: jdoerfert.
D18714 <https://reviews.llvm.org/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.
https://reviews.llvm.org/D89724
Files:
llvm/include/llvm/IR/Intrinsics.td
llvm/test/Bitcode/upgrade-memory-intrinsics.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/memintrinsics.ll
Index: llvm/test/Transforms/DeadStoreElimination/MSSA/memintrinsics.ll
===================================================================
--- llvm/test/Transforms/DeadStoreElimination/MSSA/memintrinsics.ll
+++ llvm/test/Transforms/DeadStoreElimination/MSSA/memintrinsics.ll
@@ -18,10 +18,8 @@
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
;
Index: llvm/test/Bitcode/upgrade-memory-intrinsics.ll
===================================================================
--- llvm/test/Bitcode/upgrade-memory-intrinsics.ll
+++ llvm/test/Bitcode/upgrade-memory-intrinsics.ll
@@ -29,8 +29,8 @@
; 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)
Index: llvm/include/llvm/IR/Intrinsics.td
===================================================================
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -583,7 +583,8 @@
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],
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89724.299132.patch
Type: text/x-patch
Size: 2437 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201019/ea87a73f/attachment.bin>
More information about the llvm-commits
mailing list