[llvm-commits] [llvm] r110458 - in /llvm/trunk: include/llvm/Analysis/AliasAnalysis.h lib/Analysis/AliasAnalysis.cpp test/Analysis/BasicAA/modref.ll
Dan Gohman
gohman at apple.com
Fri Aug 6 11:24:38 PDT 2010
Author: djg
Date: Fri Aug 6 13:24:38 2010
New Revision: 110458
URL: http://llvm.org/viewvc/llvm-project?rev=110458&view=rev
Log:
Implement a proper getModRefInfo for va_arg.
Modified:
llvm/trunk/include/llvm/Analysis/AliasAnalysis.h
llvm/trunk/lib/Analysis/AliasAnalysis.cpp
llvm/trunk/test/Analysis/BasicAA/modref.ll
Modified: llvm/trunk/include/llvm/Analysis/AliasAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/AliasAnalysis.h?rev=110458&r1=110457&r2=110458&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/AliasAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/AliasAnalysis.h Fri Aug 6 13:24:38 2010
@@ -243,6 +243,7 @@
/// Convenience functions...
ModRefResult getModRefInfo(const LoadInst *L, const Value *P, unsigned Size);
ModRefResult getModRefInfo(const StoreInst *S, const Value *P, unsigned Size);
+ ModRefResult getModRefInfo(const VAArgInst* I, const Value* P, unsigned Size);
ModRefResult getModRefInfo(const CallInst *C, const Value *P, unsigned Size) {
return getModRefInfo(ImmutableCallSite(C), P, Size);
}
@@ -250,10 +251,6 @@
const Value *P, unsigned Size) {
return getModRefInfo(ImmutableCallSite(I), P, Size);
}
- ModRefResult getModRefInfo(const VAArgInst* I,
- const Value* P, unsigned Size) {
- return AliasAnalysis::ModRef;
- }
ModRefResult getModRefInfo(const Instruction *I,
const Value *P, unsigned Size) {
switch (I->getOpcode()) {
Modified: llvm/trunk/lib/Analysis/AliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasAnalysis.cpp?rev=110458&r1=110457&r2=110458&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/AliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/AliasAnalysis.cpp Fri Aug 6 13:24:38 2010
@@ -229,6 +229,23 @@
return Mod;
}
+AliasAnalysis::ModRefResult
+AliasAnalysis::getModRefInfo(const VAArgInst *V, const Value *P, unsigned Size) {
+ // If the va_arg address cannot alias the pointer in question, then the
+ // specified memory cannot be accessed by the va_arg.
+ if (!alias(V->getOperand(0), UnknownSize, P, Size))
+ return NoModRef;
+
+ // If the pointer is a pointer to constant memory, then it could not have been
+ // modified by this va_arg.
+ if (pointsToConstantMemory(P))
+ return NoModRef;
+
+ // Otherwise, a va_arg reads and writes.
+ return ModRef;
+}
+
+
AliasAnalysis::ModRefBehavior
AliasAnalysis::getIntrinsicModRefBehavior(unsigned iid) {
#define GET_INTRINSIC_MODREF_BEHAVIOR
Modified: llvm/trunk/test/Analysis/BasicAA/modref.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/modref.ll?rev=110458&r1=110457&r2=110458&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/BasicAA/modref.ll (original)
+++ llvm/trunk/test/Analysis/BasicAA/modref.ll Fri Aug 6 13:24:38 2010
@@ -123,3 +123,14 @@
; CHECK: sub i32 %tmp, %tmp
}
+define i8 @test6(i8* %p, i8* noalias %a) {
+ %x = load i8* %a
+ %t = va_arg i8* %p, float
+ %y = load i8* %a
+ %z = add i8 %x, %y
+ ret i8 %z
+; CHECK: @test6
+; CHECK: load i8* %a
+; CHECK-NOT: load
+; CHECK: ret
+}
More information about the llvm-commits
mailing list