[llvm] d878916 - [MemCpyOpt] add noalias metadata on lifetime intrinsic test case for stack-move optimization(NFC)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 22 08:20:10 PDT 2023
Author: khei4
Date: 2023-07-23T00:18:33+09:00
New Revision: d878916c213c9184e0cd5032a246580d8c3b6bea
URL: https://github.com/llvm/llvm-project/commit/d878916c213c9184e0cd5032a246580d8c3b6bea
DIFF: https://github.com/llvm/llvm-project/commit/d878916c213c9184e0cd5032a246580d8c3b6bea.diff
LOG: [MemCpyOpt] add noalias metadata on lifetime intrinsic test case for stack-move optimization(NFC)
Added:
Modified:
llvm/test/Transforms/MemCpyOpt/stack-move.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/MemCpyOpt/stack-move.ll b/llvm/test/Transforms/MemCpyOpt/stack-move.ll
index d67a6fe34d34e7..5e04c9d330493b 100644
--- a/llvm/test/Transforms/MemCpyOpt/stack-move.ll
+++ b/llvm/test/Transforms/MemCpyOpt/stack-move.ll
@@ -321,6 +321,37 @@ define void @remove_alloca_metadata() {
}
; TODO: Merge alloca and remove memcpy.
+; Tests that we remove scoped noalias metadata from a call.
+; And confirm that don't crash on noalias metadata on lifetime markers.
+define void @noalias_on_lifetime() {
+; CHECK-LABEL: define void @noalias_on_lifetime() {
+; CHECK-NEXT: [[SRC:%.*]] = alloca [[STRUCT_FOO:%.*]], align 4
+; CHECK-NEXT: [[DEST:%.*]] = alloca [[STRUCT_FOO]], align 4
+; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 12, ptr nocapture [[SRC]])
+; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 12, ptr nocapture [[DEST]])
+; CHECK-NEXT: store [[STRUCT_FOO]] { i32 10, i32 20, i32 30 }, ptr [[SRC]], align 4
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @use_nocapture(ptr nocapture [[SRC]]), !alias.scope !0
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[DEST]], ptr align 4 [[SRC]], i64 12, i1 false)
+; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 12, ptr nocapture [[SRC]]), !alias.scope !0
+; CHECK-NEXT: [[TMP2:%.*]] = call i32 @use_nocapture(ptr nocapture [[DEST]]), !noalias !0
+; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 12, ptr nocapture [[DEST]]), !noalias !0
+; CHECK-NEXT: ret void
+;
+ %src = alloca %struct.Foo, align 4
+ %dest = alloca %struct.Foo, align 4
+ call void @llvm.lifetime.start.p0(i64 12, ptr nocapture %src)
+ call void @llvm.lifetime.start.p0(i64 12, ptr nocapture %dest)
+ store %struct.Foo { i32 10, i32 20, i32 30 }, ptr %src
+ %1 = call i32 @use_nocapture(ptr nocapture %src), !alias.scope !2
+
+ call void @llvm.memcpy.p0.p0.i64(ptr align 4 %dest, ptr align 4 %src, i64 12, i1 false)
+
+ call void @llvm.lifetime.end.p0(i64 12, ptr nocapture %src), !alias.scope !2
+ %2 = call i32 @use_nocapture(ptr nocapture %dest), !noalias !2
+ call void @llvm.lifetime.end.p0(i64 12, ptr nocapture %dest), !noalias !2
+ ret void
+}
+
; Tests that we can merge alloca if the dest and src has only refs except lifetime intrinsics.
define void @src_ref_dest_ref_after_copy() {
; CHECK-LABEL: define void @src_ref_dest_ref_after_copy() {
More information about the llvm-commits
mailing list