X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAnalysis%2FBasicAliasAnalysis.cpp;h=fe71f04098b13061a0b04c4dcf2a99bc3fd7f9dd;hb=ef4cfc749a61d0d0252196c957697436ba7ec068;hp=1002868e84cbb72240ef4f6419eec13a1e39ea24;hpb=3311a1f8f0d8a2c6d940802bbb95eba0b801a615;p=oota-llvm.git diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 1002868e84c..fe71f04098b 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -64,30 +64,6 @@ static const Value *GetGEPOperands(const Value *V, return V; } -/// isNoAliasCall - Return true if this pointer is returned by a noalias -/// function. -static bool isNoAliasCall(const Value *V) { - if (isa(V) || isa(V)) - return CallSite(const_cast(cast(V))) - .paramHasAttr(0, Attribute::NoAlias); - return false; -} - -/// isIdentifiedObject - Return true if this pointer refers to a distinct and -/// identifiable object. This returns true for: -/// Global Variables and Functions -/// Allocas and Mallocs -/// ByVal and NoAlias Arguments -/// NoAlias returns -/// -bool llvm::isIdentifiedObject(const Value *V) { - if (isa(V) || isa(V) || isNoAliasCall(V)) - return true; - if (const Argument *A = dyn_cast(V)) - return A->hasNoAliasAttr() || A->hasByValAttr(); - return false; -} - /// isKnownNonNull - Return true if we know that the specified value is never /// null. static bool isKnownNonNull(const Value *V) { @@ -179,11 +155,6 @@ namespace { return MayAlias; } - virtual ModRefBehavior getModRefBehavior(Function *F, CallSite CS, - std::vector *Info) { - return UnknownModRefBehavior; - } - virtual void getArgumentAccesses(Function *F, CallSite CS, std::vector &Info) { assert(0 && "This method may not be called on this function!"); @@ -230,7 +201,7 @@ namespace { ModRefResult getModRefInfo(CallSite CS, Value *P, unsigned Size); ModRefResult getModRefInfo(CallSite CS1, CallSite CS2); - + /// hasNoModRefInfoForCalls - We can provide mod/ref information against /// non-escaping allocations. virtual bool hasNoModRefInfoForCalls() const { return false; } @@ -273,6 +244,7 @@ bool BasicAliasAnalysis::pointsToConstantMemory(const Value *P) { return false; } + // getModRefInfo - Check to see if the specified callsite can clobber the // specified memory object. Since we only look at local properties of this // function, we really can't say much about this query. We do, however, use @@ -296,7 +268,7 @@ 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 // argument without capturing it. - if (isNonEscapingLocalObject(Object)) { + if (isNonEscapingLocalObject(Object) && CS.getInstruction() != Object) { bool passedAsArg = false; // TODO: Eventually only check 'nocapture' arguments. for (CallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end(); @@ -391,10 +363,10 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size, // non-escaping local object, then we know the object couldn't escape to a // point where the call could return it. if ((isa(O1) || isa(O1)) && - isNonEscapingLocalObject(O2)) + isNonEscapingLocalObject(O2) && O1 != O2) return NoAlias; if ((isa(O2) || isa(O2)) && - isNonEscapingLocalObject(O1)) + isNonEscapingLocalObject(O1) && O1 != O2) return NoAlias; // If we have two gep instructions with must-alias'ing base pointers, figure