summaryrefslogtreecommitdiff
path: root/test/Transforms/DeadStoreElimination
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-12-06 01:48:06 +0000
committerChris Lattner <sabre@nondot.org>2010-12-06 01:48:06 +0000
commitcc10244d7725f191bdc91cd62befff0c97257c7b (patch)
tree79ce2ec92470d1999df7a3eae7b934c8b9242211 /test/Transforms/DeadStoreElimination
parent72c194a8be83d217360ebc6b1f3ad21c5ffa16a9 (diff)
downloadllvm-cc10244d7725f191bdc91cd62befff0c97257c7b.tar.gz
llvm-cc10244d7725f191bdc91cd62befff0c97257c7b.tar.bz2
llvm-cc10244d7725f191bdc91cd62befff0c97257c7b.tar.xz
Fix PR8728, a miscompilation I recently introduced. When optimizing
memcpy's like: memcpy(A, B) memcpy(A, C) we cannot delete the first memcpy as dead if A and C might be aliases. If so, we actually get: memcpy(A, B) memcpy(A, A) which is not correct to transform into: memcpy(A, A) This patch was heavily influenced by Jakub Staszak's patch in PR8728, thanks Jakub! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120974 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/DeadStoreElimination')
-rw-r--r--test/Transforms/DeadStoreElimination/simple.ll16
1 files changed, 15 insertions, 1 deletions
diff --git a/test/Transforms/DeadStoreElimination/simple.ll b/test/Transforms/DeadStoreElimination/simple.ll
index 203cf37193..a61eac9729 100644
--- a/test/Transforms/DeadStoreElimination/simple.ll
+++ b/test/Transforms/DeadStoreElimination/simple.ll
@@ -203,7 +203,7 @@ define void @test16(i8* %P, i8* %Q) nounwind ssp {
}
;; Overwrite of memset by memcpy.
-define void @test17(i8* %P, i8* %Q) nounwind ssp {
+define void @test17(i8* %P, i8* noalias %Q) nounwind ssp {
tail call void @llvm.memset.i64(i8* %P, i8 42, i64 8, i32 1)
tail call void @llvm.memcpy.i64(i8* %P, i8* %Q, i64 12, i32 1)
ret void
@@ -222,3 +222,17 @@ define void @test17v(i8* %P, i8* %Q) nounwind ssp {
; CHECK-NEXT: call void @llvm.memcpy
; CHECK-NEXT: ret
}
+
+; PR8728
+; Do not delete instruction where possible situation is:
+; A = B
+; A = A
+define void @test18(i8* %P, i8* %Q, i8* %R) nounwind ssp {
+ tail call void @llvm.memcpy.i64(i8* %P, i8* %Q, i64 12, i32 1)
+ tail call void @llvm.memcpy.i64(i8* %P, i8* %R, i64 12, i32 1)
+ ret void
+; CHECK: @test18
+; CHECK-NEXT: call void @llvm.memcpy
+; CHECK-NEXT: call void @llvm.memcpy
+; CHECK-NEXT: ret
+}