[llvm-commits] [llvm] r89665 - in /llvm/trunk/lib/Analysis: AliasAnalysis.cpp BasicAliasAnalysis.cpp
Chris Lattner
sabre at nondot.org
Mon Nov 23 08:46:41 PST 2009
Author: lattner
Date: Mon Nov 23 10:46:41 2009
New Revision: 89665
URL: http://llvm.org/viewvc/llvm-project?rev=89665&view=rev
Log:
use the new isNoAlias method to simplify some code, only do an escaping check if
we have a non-constant pointer. Constant pointers can't be local.
Modified:
llvm/trunk/lib/Analysis/AliasAnalysis.cpp
llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
Modified: llvm/trunk/lib/Analysis/AliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasAnalysis.cpp?rev=89665&r1=89664&r2=89665&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/AliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/AliasAnalysis.cpp Mon Nov 23 10:46:41 2009
@@ -127,17 +127,18 @@
AliasAnalysis::ModRefResult
AliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
- ModRefResult Mask = ModRef;
ModRefBehavior MRB = getModRefBehavior(CS);
if (MRB == DoesNotAccessMemory)
return NoModRef;
- else if (MRB == OnlyReadsMemory)
+
+ ModRefResult Mask = ModRef;
+ if (MRB == OnlyReadsMemory)
Mask = Ref;
else if (MRB == AliasAnalysis::AccessesArguments) {
bool doesAlias = false;
for (CallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end();
AI != AE; ++AI)
- if (alias(*AI, ~0U, P, Size) != NoAlias) {
+ if (!isNoAlias(*AI, ~0U, P, Size)) {
doesAlias = true;
break;
}
Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=89665&r1=89664&r2=89665&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Mon Nov 23 10:46:41 2009
@@ -290,7 +290,8 @@
// If the pointer is to a locally allocated object that does not escape,
// then the call can not mod/ref the pointer unless the call takes the pointer
// as an argument, and itself doesn't capture it.
- if (isNonEscapingLocalObject(Object) && CS.getInstruction() != Object) {
+ if (!isa<Constant>(Object) && CS.getInstruction() != Object &&
+ isNonEscapingLocalObject(Object)) {
bool PassedAsArg = false;
unsigned ArgNo = 0;
for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end();
@@ -304,7 +305,7 @@
// is impossible to alias the pointer we're checking. If not, we have to
// assume that the call could touch the pointer, even though it doesn't
// escape.
- if (alias(cast<Value>(CI), ~0U, P, ~0U) != NoAlias) {
+ if (!isNoAlias(cast<Value>(CI), ~0U, P, ~0U)) {
PassedAsArg = true;
break;
}
@@ -328,18 +329,20 @@
Len = LenCI->getZExtValue();
Value *Dest = II->getOperand(1);
Value *Src = II->getOperand(2);
- if (alias(Dest, Len, P, Size) == NoAlias) {
- if (alias(Src, Len, P, Size) == NoAlias)
+ if (isNoAlias(Dest, Len, P, Size)) {
+ if (isNoAlias(Src, Len, P, Size))
return NoModRef;
return Ref;
}
break;
}
case Intrinsic::memset:
+ // Since memset is 'accesses arguments' only, the AliasAnalysis base class
+ // will handle it for the variable length case.
if (ConstantInt *LenCI = dyn_cast<ConstantInt>(II->getOperand(3))) {
unsigned Len = LenCI->getZExtValue();
Value *Dest = II->getOperand(1);
- if (alias(Dest, Len, P, Size) == NoAlias)
+ if (isNoAlias(Dest, Len, P, Size))
return NoModRef;
}
break;
@@ -358,7 +361,7 @@
if (TD) {
Value *Op1 = II->getOperand(1);
unsigned Op1Size = TD->getTypeStoreSize(Op1->getType());
- if (alias(Op1, Op1Size, P, Size) == NoAlias)
+ if (isNoAlias(Op1, Op1Size, P, Size))
return NoModRef;
}
break;
@@ -366,13 +369,13 @@
case Intrinsic::lifetime_end:
case Intrinsic::invariant_start: {
unsigned PtrSize = cast<ConstantInt>(II->getOperand(1))->getZExtValue();
- if (alias(II->getOperand(2), PtrSize, P, Size) == NoAlias)
+ if (isNoAlias(II->getOperand(2), PtrSize, P, Size))
return NoModRef;
break;
}
case Intrinsic::invariant_end: {
unsigned PtrSize = cast<ConstantInt>(II->getOperand(2))->getZExtValue();
- if (alias(II->getOperand(3), PtrSize, P, Size) == NoAlias)
+ if (isNoAlias(II->getOperand(3), PtrSize, P, Size))
return NoModRef;
break;
}
@@ -701,11 +704,11 @@
// passes true for the StoreCaptures argument to PointerMayBeCaptured).
if (O1 != O2) {
if ((isa<CallInst>(O1) || isa<InvokeInst>(O1) || isa<LoadInst>(O1) ||
- isa<Argument(O1)) &&
+ isa<Argument>(O1)) &&
isNonEscapingLocalObject(O2))
return NoAlias;
if ((isa<CallInst>(O2) || isa<InvokeInst>(O2) || isa<LoadInst>(O2) ||
- isa<Argument(O2)) &&
+ isa<Argument>(O2)) &&
isNonEscapingLocalObject(O1))
return NoAlias;
}
More information about the llvm-commits
mailing list