[llvm-commits] [llvm] r110393 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/getmodrefinfo-cs-cs.ll
Dan Gohman
gohman at apple.com
Thu Aug 5 16:34:51 PDT 2010
Author: djg
Date: Thu Aug 5 18:34:50 2010
New Revision: 110393
URL: http://llvm.org/viewvc/llvm-project?rev=110393&view=rev
Log:
Implement AccessesArguments checking in the two-callsite form
of BasicAA::getModRefInfo. This allows BasicAA to say that two
memset calls to non-aliasing memory locations don't interfere.
Modified:
llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
llvm/trunk/test/Analysis/BasicAA/getmodrefinfo-cs-cs.ll
Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=110393&r1=110392&r2=110393&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Thu Aug 5 18:34:50 2010
@@ -429,13 +429,43 @@
if (CS1B == OnlyReadsMemory && CS2B == OnlyReadsMemory)
return NoModRef;
+ AliasAnalysis::ModRefResult Mask = ModRef;
+
// If CS1 only reads memory, the only dependence on CS2 can be
// from CS1 reading memory written by CS2.
if (CS1B == OnlyReadsMemory)
- return Ref;
+ Mask = ModRefResult(Mask & Ref);
+ // If CS2 only access memory through arguments, accumulate the mod/ref
+ // information from CS1's references to the memory referenced by
+ // CS2's arguments.
+ if (CS2B == AccessesArguments) {
+ AliasAnalysis::ModRefResult R = NoModRef;
+ for (ImmutableCallSite::arg_iterator
+ I = CS2.arg_begin(), E = CS2.arg_end(); I != E; ++I) {
+ R = ModRefResult((R | getModRefInfo(CS1, *I, UnknownSize)) & Mask);
+ if (R == Mask)
+ break;
+ }
+ return R;
+ }
+
+ // If CS1 only accesses memory through arguments, check if CS2 references
+ // any of the memory referenced by CS1's arguments. If not, return NoModRef.
+ if (CS1B == AccessesArguments) {
+ AliasAnalysis::ModRefResult R = NoModRef;
+ for (ImmutableCallSite::arg_iterator
+ I = CS1.arg_begin(), E = CS1.arg_end(); I != E; ++I)
+ if (getModRefInfo(CS2, *I, UnknownSize) != NoModRef) {
+ R = Mask;
+ break;
+ }
+ if (R == NoModRef)
+ return R;
+ }
+
// Otherwise, fall back to NoAA (mod+ref).
- return NoAA::getModRefInfo(CS1, CS2);
+ return ModRefResult(NoAA::getModRefInfo(CS1, CS2) & Mask);
}
/// GetIndexDifference - Dest and Src are the variable indices from two
Modified: llvm/trunk/test/Analysis/BasicAA/getmodrefinfo-cs-cs.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/getmodrefinfo-cs-cs.ll?rev=110393&r1=110392&r2=110393&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/BasicAA/getmodrefinfo-cs-cs.ll (original)
+++ llvm/trunk/test/Analysis/BasicAA/getmodrefinfo-cs-cs.ll Thu Aug 5 18:34:50 2010
@@ -1,12 +1,26 @@
; RUN: opt < %s -aa-eval -print-all-alias-modref-info -disable-output |& FileCheck %s
+
; CHECK: Just Ref: call void @ro() <-> call void @f0()
declare void @f0()
declare void @ro() readonly
-define void @test() {
+define void @test0() {
call void @f0()
call void @ro()
ret void
}
+
+; CHECK: NoModRef: call void @llvm.memset.p0i8.i64(i8* @A, i8 0, i64 1, i32 1, i1 false) <-> call void @llvm.memset.p0i8.i64(i8* @B, i8 0, i64 1, i32 1, i1 false)
+; CHECK: NoModRef: call void @llvm.memset.p0i8.i64(i8* @B, i8 0, i64 1, i32 1, i1 false) <-> call void @llvm.memset.p0i8.i64(i8* @A, i8 0, i64 1, i32 1, i1 false)
+
+declare void @llvm.memset.i64(i8*, i8, i64, i32)
+
+ at A = external global i8
+ at B = external global i8
+define void @test1() {
+ call void @llvm.memset.i64(i8* @A, i8 0, i64 1, i32 1)
+ call void @llvm.memset.i64(i8* @B, i8 0, i64 1, i32 1)
+ ret void
+}
More information about the llvm-commits
mailing list