[llvm] d605a11 - [Intrinsics] Added writeonly attribute to the first arg of llvm.memmove
Dávid Bolvanský via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 19 14:09:55 PDT 2020
Author: Dávid Bolvanský
Date: 2020-10-19T23:09:41+02:00
New Revision: d605a119939a91477c0eb223d3a5d7d912825daa
URL: https://github.com/llvm/llvm-project/commit/d605a119939a91477c0eb223d3a5d7d912825daa
DIFF: https://github.com/llvm/llvm-project/commit/d605a119939a91477c0eb223d3a5d7d912825daa.diff
LOG: [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
Added:
Modified:
llvm/include/llvm/IR/Intrinsics.td
llvm/test/Bitcode/upgrade-memory-intrinsics.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/memintrinsics.ll
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td
index 8e8bb0b35bce..acd8596fae7b 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -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],
diff --git a/llvm/test/Bitcode/upgrade-memory-intrinsics.ll b/llvm/test/Bitcode/upgrade-memory-intrinsics.ll
index c534313170ff..21b5efd66bdd 100644
--- a/llvm/test/Bitcode/upgrade-memory-intrinsics.ll
+++ b/llvm/test/Bitcode/upgrade-memory-intrinsics.ll
@@ -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)
diff --git a/llvm/test/Transforms/DeadStoreElimination/MSSA/memintrinsics.ll b/llvm/test/Transforms/DeadStoreElimination/MSSA/memintrinsics.ll
index 3b92bc2850ff..02f555a061ed 100644
--- a/llvm/test/Transforms/DeadStoreElimination/MSSA/memintrinsics.ll
+++ b/llvm/test/Transforms/DeadStoreElimination/MSSA/memintrinsics.ll
@@ -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
;
More information about the llvm-commits
mailing list