diff --git a/lib/Analysis/AliasAnalysis.cpp b/lib/Analysis/AliasAnalysis.cpp index 92fa1df5c95..dee9b535871 100644 --- a/lib/Analysis/AliasAnalysis.cpp +++ b/lib/Analysis/AliasAnalysis.cpp @@ -127,17 +127,18 @@ AliasAnalysis::getModRefBehavior(Function *F, 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; } diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index f80b162ba84..32ca9111c26 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -290,7 +290,8 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) { // 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(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 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) { // 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(CI), ~0U, P, ~0U) != NoAlias) { + if (!isNoAlias(cast(CI), ~0U, P, ~0U)) { PassedAsArg = true; break; } @@ -328,18 +329,20 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) { 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(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 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) { 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 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) { case Intrinsic::lifetime_end: case Intrinsic::invariant_start: { unsigned PtrSize = cast(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(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 @@ BasicAliasAnalysis::aliasCheck(const Value *V1, unsigned V1Size, // passes true for the StoreCaptures argument to PointerMayBeCaptured). if (O1 != O2) { if ((isa(O1) || isa(O1) || isa(O1) || - isa(O1)) && isNonEscapingLocalObject(O2)) return NoAlias; if ((isa(O2) || isa(O2) || isa(O2) || - isa(O2)) && isNonEscapingLocalObject(O1)) return NoAlias; }