[llvm-commits] [llvm] r120370 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Transforms/DeadStoreElimination/simple.ll
Chris Lattner
sabre at nondot.org
Mon Nov 29 16:43:16 PST 2010
Author: lattner
Date: Mon Nov 29 18:43:16 2010
New Revision: 120370
URL: http://llvm.org/viewvc/llvm-project?rev=120370&view=rev
Log:
enhance basicaa to return "Mod" for a memcpy call when the
queried location doesn't overlap the source, and add a testcase.
Modified:
llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
llvm/trunk/test/Transforms/DeadStoreElimination/simple.ll
Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=120370&r1=120369&r2=120370&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Mon Nov 29 18:43:16 2010
@@ -687,10 +687,15 @@
Len = LenCI->getZExtValue();
Value *Dest = II->getArgOperand(0);
Value *Src = II->getArgOperand(1);
+ // If it can't overlap the source dest, then it doesn't modref the loc.
if (isNoAlias(Location(Dest, Len), Loc)) {
if (isNoAlias(Location(Src, Len), Loc))
return NoModRef;
+ // If it can't overlap the dest, then worst case it reads the loc.
Min = Ref;
+ } else if (isNoAlias(Location(Src, Len), Loc)) {
+ // If it can't overlap the source, then worst case it mutates the loc.
+ Min = Mod;
}
break;
}
Modified: llvm/trunk/test/Transforms/DeadStoreElimination/simple.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/simple.ll?rev=120370&r1=120369&r2=120370&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/DeadStoreElimination/simple.ll (original)
+++ llvm/trunk/test/Transforms/DeadStoreElimination/simple.ll Mon Nov 29 18:43:16 2010
@@ -55,16 +55,27 @@
; CHECK-NEXT: ret void
}
-declare void @llvm.memset.i32(i8*, i8, i32, i32)
+declare void @llvm.memset.i64(i8*, i8, i64, i32)
+declare void @llvm.memcpy.i64(i8*, i8*, i64, i32)
; Should delete store of 10 even though memset is a may-store to P (P and Q may
; alias).
define void @test6(i32 *%p, i8 *%q) {
store i32 10, i32* %p, align 4 ;; dead.
- call void @llvm.memset.i32(i8* %q, i8 42, i32 900, i32 1)
+ call void @llvm.memset.i64(i8* %q, i8 42, i64 900, i32 1)
store i32 30, i32* %p, align 4
ret void
; CHECK: @test6
; CHECK-NEXT: call void @llvm.memset
}
+; Should delete store of 10 even though memcpy is a may-store to P (P and Q may
+; alias).
+define void @test7(i32 *%p, i8 *%q, i8* noalias %r) {
+ store i32 10, i32* %p, align 4 ;; dead.
+ call void @llvm.memcpy.i64(i8* %q, i8* %r, i64 900, i32 1)
+ store i32 30, i32* %p, align 4
+ ret void
+; CHECK: @test7
+; CHECK-NEXT: call void @llvm.memcpy
+}
More information about the llvm-commits
mailing list