[llvm] d7186fe - [MemCpyOpt] Add lifetime may alias test (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 11 08:08:40 PDT 2020


Author: Nikita Popov
Date: 2020-10-11T17:08:28+02:00
New Revision: d7186fe3710828fab03de69f78f01f001d70e1aa

URL: https://github.com/llvm/llvm-project/commit/d7186fe3710828fab03de69f78f01f001d70e1aa
DIFF: https://github.com/llvm/llvm-project/commit/d7186fe3710828fab03de69f78f01f001d70e1aa.diff

LOG: [MemCpyOpt] Add lifetime may alias test (NFC)

Test the case where a lifetime intrinsic may alias the memcpy
source. Other cases test must or no alias.

Added: 
    

Modified: 
    llvm/test/Transforms/MemCpyOpt/memcpy-undef.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/MemCpyOpt/memcpy-undef.ll b/llvm/test/Transforms/MemCpyOpt/memcpy-undef.ll
index e1dd9c92d4e0..38a324efd130 100644
--- a/llvm/test/Transforms/MemCpyOpt/memcpy-undef.ll
+++ b/llvm/test/Transforms/MemCpyOpt/memcpy-undef.ll
@@ -6,6 +6,7 @@ target triple = "x86_64-apple-macosx10.8.0"
 
 %struct.foo = type { i8, [7 x i8], i32 }
 
+; Check that the memcpy is removed.
 define i32 @test1(%struct.foo* nocapture %foobie) nounwind noinline ssp uwtable {
 ; CHECK-LABEL: @test1(
 ; CHECK-NEXT:    [[BLETCH_SROA_1:%.*]] = alloca [7 x i8], align 1
@@ -26,10 +27,9 @@ define i32 @test1(%struct.foo* nocapture %foobie) nounwind noinline ssp uwtable
   %4 = getelementptr inbounds %struct.foo, %struct.foo* %foobie, i64 0, i32 2
   store i32 20, i32* %4, align 4
   ret i32 undef
-
-; Check that the memcpy is removed.
 }
 
+; Check that the memcpy is removed.
 define void @test2(i8* sret noalias nocapture %out, i8* %in) nounwind noinline ssp uwtable {
 ; CHECK-LABEL: @test2(
 ; CHECK-NEXT:    call void @llvm.lifetime.start.p0i8(i64 8, i8* [[IN:%.*]])
@@ -38,10 +38,9 @@ define void @test2(i8* sret noalias nocapture %out, i8* %in) nounwind noinline s
   call void @llvm.lifetime.start.p0i8(i64 8, i8* %in)
   call void @llvm.memcpy.p0i8.p0i8.i64(i8* %out, i8* %in, i64 8, i1 false)
   ret void
-
-; Check that the memcpy is removed.
 }
 
+; Check that the memcpy is not removed.
 define void @test3(i8* sret noalias nocapture %out, i8* %in) nounwind noinline ssp uwtable {
 ; CHECK-LABEL: @test3(
 ; CHECK-NEXT:    call void @llvm.lifetime.start.p0i8(i64 4, i8* [[IN:%.*]])
@@ -51,8 +50,18 @@ define void @test3(i8* sret noalias nocapture %out, i8* %in) nounwind noinline s
   call void @llvm.lifetime.start.p0i8(i64 4, i8* %in)
   call void @llvm.memcpy.p0i8.p0i8.i64(i8* %out, i8* %in, i64 8, i1 false)
   ret void
+}
 
 ; Check that the memcpy is not removed.
+define void @test_lifetime_may_alias(i8* %lifetime, i8* %src, i8* %dst) {
+; CHECK-LABEL: @test_lifetime_may_alias(
+; CHECK-NEXT:    call void @llvm.lifetime.start.p0i8(i64 8, i8* [[LIFETIME:%.*]])
+; CHECK-NEXT:    call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[DST:%.*]], i8* [[SRC:%.*]], i64 8, i1 false)
+; CHECK-NEXT:    ret void
+;
+  call void @llvm.lifetime.start.p0i8(i64 8, i8* %lifetime)
+  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %src, i64 8, i1 false)
+  ret void
 }
 
 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i1) nounwind


        


More information about the llvm-commits mailing list