LLVM  mainline
AliasAnalysis.cpp
Go to the documentation of this file.
00001 //===- AliasAnalysis.cpp - Generic Alias Analysis Interface Implementation -==//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file implements the generic AliasAnalysis interface which is used as the
00011 // common interface used by all clients and implementations of alias analysis.
00012 //
00013 // This file also implements the default version of the AliasAnalysis interface
00014 // that is to be used when no other implementation is specified.  This does some
00015 // simple tests that detect obvious cases: two different global pointers cannot
00016 // alias, a global cannot alias a malloc, two different mallocs cannot alias,
00017 // etc.
00018 //
00019 // This alias analysis implementation really isn't very good for anything, but
00020 // it is very fast, and makes a nice clean default implementation.  Because it
00021 // handles lots of little corner cases, other, more complex, alias analysis
00022 // implementations may choose to rely on this pass to resolve these simple and
00023 // easy cases.
00024 //
00025 //===----------------------------------------------------------------------===//
00026 
00027 #include "llvm/Analysis/AliasAnalysis.h"
00028 #include "llvm/Analysis/CFG.h"
00029 #include "llvm/Analysis/CaptureTracking.h"
00030 #include "llvm/Analysis/TargetLibraryInfo.h"
00031 #include "llvm/Analysis/ValueTracking.h"
00032 #include "llvm/IR/BasicBlock.h"
00033 #include "llvm/IR/DataLayout.h"
00034 #include "llvm/IR/Dominators.h"
00035 #include "llvm/IR/Function.h"
00036 #include "llvm/IR/Instructions.h"
00037 #include "llvm/IR/IntrinsicInst.h"
00038 #include "llvm/IR/LLVMContext.h"
00039 #include "llvm/IR/Type.h"
00040 #include "llvm/Pass.h"
00041 using namespace llvm;
00042 
00043 // Register the AliasAnalysis interface, providing a nice name to refer to.
00044 INITIALIZE_ANALYSIS_GROUP(AliasAnalysis, "Alias Analysis", NoAA)
00045 char AliasAnalysis::ID = 0;
00046 
00047 //===----------------------------------------------------------------------===//
00048 // Default chaining methods
00049 //===----------------------------------------------------------------------===//
00050 
00051 AliasAnalysis::AliasResult
00052 AliasAnalysis::alias(const Location &LocA, const Location &LocB) {
00053   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
00054   return AA->alias(LocA, LocB);
00055 }
00056 
00057 bool AliasAnalysis::pointsToConstantMemory(const Location &Loc,
00058                                            bool OrLocal) {
00059   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
00060   return AA->pointsToConstantMemory(Loc, OrLocal);
00061 }
00062 
00063 AliasAnalysis::Location
00064 AliasAnalysis::getArgLocation(ImmutableCallSite CS, unsigned ArgIdx,
00065                               AliasAnalysis::ModRefResult &Mask) {
00066   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
00067   return AA->getArgLocation(CS, ArgIdx, Mask);
00068 }
00069 
00070 void AliasAnalysis::deleteValue(Value *V) {
00071   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
00072   AA->deleteValue(V);
00073 }
00074 
00075 void AliasAnalysis::copyValue(Value *From, Value *To) {
00076   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
00077   AA->copyValue(From, To);
00078 }
00079 
00080 void AliasAnalysis::addEscapingUse(Use &U) {
00081   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
00082   AA->addEscapingUse(U);
00083 }
00084 
00085 AliasAnalysis::ModRefResult
00086 AliasAnalysis::getModRefInfo(Instruction *I, ImmutableCallSite Call) {
00087   // We may have two calls
00088   if (auto CS = ImmutableCallSite(I)) {
00089     // Check if the two calls modify the same memory
00090     return getModRefInfo(Call, CS);
00091   } else {
00092     // Otherwise, check if the call modifies or references the
00093     // location this memory access defines.  The best we can say
00094     // is that if the call references what this instruction
00095     // defines, it must be clobbered by this location.
00096     const AliasAnalysis::Location DefLoc = AA->getLocation(I);
00097     if (getModRefInfo(Call, DefLoc) != AliasAnalysis::NoModRef)
00098       return AliasAnalysis::ModRef;
00099   }
00100   return AliasAnalysis::NoModRef;
00101 }
00102 
00103 AliasAnalysis::ModRefResult
00104 AliasAnalysis::getModRefInfo(ImmutableCallSite CS,
00105                              const Location &Loc) {
00106   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
00107 
00108   ModRefBehavior MRB = getModRefBehavior(CS);
00109   if (MRB == DoesNotAccessMemory)
00110     return NoModRef;
00111 
00112   ModRefResult Mask = ModRef;
00113   if (onlyReadsMemory(MRB))
00114     Mask = Ref;
00115 
00116   if (onlyAccessesArgPointees(MRB)) {
00117     bool doesAlias = false;
00118     ModRefResult AllArgsMask = NoModRef;
00119     if (doesAccessArgPointees(MRB)) {
00120       for (ImmutableCallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end();
00121            AI != AE; ++AI) {
00122         const Value *Arg = *AI;
00123         if (!Arg->getType()->isPointerTy())
00124           continue;
00125         ModRefResult ArgMask;
00126         Location CSLoc =
00127           getArgLocation(CS, (unsigned) std::distance(CS.arg_begin(), AI),
00128                          ArgMask);
00129         if (!isNoAlias(CSLoc, Loc)) {
00130           doesAlias = true;
00131           AllArgsMask = ModRefResult(AllArgsMask | ArgMask);
00132         }
00133       }
00134     }
00135     if (!doesAlias)
00136       return NoModRef;
00137     Mask = ModRefResult(Mask & AllArgsMask);
00138   }
00139 
00140   // If Loc is a constant memory location, the call definitely could not
00141   // modify the memory location.
00142   if ((Mask & Mod) && pointsToConstantMemory(Loc))
00143     Mask = ModRefResult(Mask & ~Mod);
00144 
00145   // If this is the end of the chain, don't forward.
00146   if (!AA) return Mask;
00147 
00148   // Otherwise, fall back to the next AA in the chain. But we can merge
00149   // in any mask we've managed to compute.
00150   return ModRefResult(AA->getModRefInfo(CS, Loc) & Mask);
00151 }
00152 
00153 AliasAnalysis::ModRefResult
00154 AliasAnalysis::getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2) {
00155   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
00156 
00157   // If CS1 or CS2 are readnone, they don't interact.
00158   ModRefBehavior CS1B = getModRefBehavior(CS1);
00159   if (CS1B == DoesNotAccessMemory) return NoModRef;
00160 
00161   ModRefBehavior CS2B = getModRefBehavior(CS2);
00162   if (CS2B == DoesNotAccessMemory) return NoModRef;
00163 
00164   // If they both only read from memory, there is no dependence.
00165   if (onlyReadsMemory(CS1B) && onlyReadsMemory(CS2B))
00166     return NoModRef;
00167 
00168   AliasAnalysis::ModRefResult Mask = ModRef;
00169 
00170   // If CS1 only reads memory, the only dependence on CS2 can be
00171   // from CS1 reading memory written by CS2.
00172   if (onlyReadsMemory(CS1B))
00173     Mask = ModRefResult(Mask & Ref);
00174 
00175   // If CS2 only access memory through arguments, accumulate the mod/ref
00176   // information from CS1's references to the memory referenced by
00177   // CS2's arguments.
00178   if (onlyAccessesArgPointees(CS2B)) {
00179     AliasAnalysis::ModRefResult R = NoModRef;
00180     if (doesAccessArgPointees(CS2B)) {
00181       for (ImmutableCallSite::arg_iterator
00182            I = CS2.arg_begin(), E = CS2.arg_end(); I != E; ++I) {
00183         const Value *Arg = *I;
00184         if (!Arg->getType()->isPointerTy())
00185           continue;
00186         ModRefResult ArgMask;
00187         Location CS2Loc =
00188           getArgLocation(CS2, (unsigned) std::distance(CS2.arg_begin(), I),
00189                          ArgMask);
00190         // ArgMask indicates what CS2 might do to CS2Loc, and the dependence of
00191         // CS1 on that location is the inverse.
00192         if (ArgMask == Mod)
00193           ArgMask = ModRef;
00194         else if (ArgMask == Ref)
00195           ArgMask = Mod;
00196 
00197         R = ModRefResult((R | (getModRefInfo(CS1, CS2Loc) & ArgMask)) & Mask);
00198         if (R == Mask)
00199           break;
00200       }
00201     }
00202     return R;
00203   }
00204 
00205   // If CS1 only accesses memory through arguments, check if CS2 references
00206   // any of the memory referenced by CS1's arguments. If not, return NoModRef.
00207   if (onlyAccessesArgPointees(CS1B)) {
00208     AliasAnalysis::ModRefResult R = NoModRef;
00209     if (doesAccessArgPointees(CS1B)) {
00210       for (ImmutableCallSite::arg_iterator
00211            I = CS1.arg_begin(), E = CS1.arg_end(); I != E; ++I) {
00212         const Value *Arg = *I;
00213         if (!Arg->getType()->isPointerTy())
00214           continue;
00215         ModRefResult ArgMask;
00216         Location CS1Loc = getArgLocation(
00217             CS1, (unsigned)std::distance(CS1.arg_begin(), I), ArgMask);
00218         // ArgMask indicates what CS1 might do to CS1Loc; if CS1 might Mod
00219         // CS1Loc, then we care about either a Mod or a Ref by CS2. If CS1
00220         // might Ref, then we care only about a Mod by CS2.
00221         ModRefResult ArgR = getModRefInfo(CS2, CS1Loc);
00222         if (((ArgMask & Mod) != NoModRef && (ArgR & ModRef) != NoModRef) ||
00223             ((ArgMask & Ref) != NoModRef && (ArgR & Mod)    != NoModRef))
00224           R = ModRefResult((R | ArgMask) & Mask);
00225 
00226         if (R == Mask)
00227           break;
00228       }
00229     }
00230     return R;
00231   }
00232 
00233   // If this is the end of the chain, don't forward.
00234   if (!AA) return Mask;
00235 
00236   // Otherwise, fall back to the next AA in the chain. But we can merge
00237   // in any mask we've managed to compute.
00238   return ModRefResult(AA->getModRefInfo(CS1, CS2) & Mask);
00239 }
00240 
00241 AliasAnalysis::ModRefBehavior
00242 AliasAnalysis::getModRefBehavior(ImmutableCallSite CS) {
00243   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
00244 
00245   ModRefBehavior Min = UnknownModRefBehavior;
00246 
00247   // Call back into the alias analysis with the other form of getModRefBehavior
00248   // to see if it can give a better response.
00249   if (const Function *F = CS.getCalledFunction())
00250     Min = getModRefBehavior(F);
00251 
00252   // If this is the end of the chain, don't forward.
00253   if (!AA) return Min;
00254 
00255   // Otherwise, fall back to the next AA in the chain. But we can merge
00256   // in any result we've managed to compute.
00257   return ModRefBehavior(AA->getModRefBehavior(CS) & Min);
00258 }
00259 
00260 AliasAnalysis::ModRefBehavior
00261 AliasAnalysis::getModRefBehavior(const Function *F) {
00262   assert(AA && "AA didn't call InitializeAliasAnalysis in its run method!");
00263   return AA->getModRefBehavior(F);
00264 }
00265 
00266 //===----------------------------------------------------------------------===//
00267 // AliasAnalysis non-virtual helper method implementation
00268 //===----------------------------------------------------------------------===//
00269 
00270 AliasAnalysis::Location AliasAnalysis::getLocation(const LoadInst *LI) {
00271   AAMDNodes AATags;
00272   LI->getAAMetadata(AATags);
00273 
00274   return Location(LI->getPointerOperand(),
00275                   getTypeStoreSize(LI->getType()), AATags);
00276 }
00277 
00278 AliasAnalysis::Location AliasAnalysis::getLocation(const StoreInst *SI) {
00279   AAMDNodes AATags;
00280   SI->getAAMetadata(AATags);
00281 
00282   return Location(SI->getPointerOperand(),
00283                   getTypeStoreSize(SI->getValueOperand()->getType()), AATags);
00284 }
00285 
00286 AliasAnalysis::Location AliasAnalysis::getLocation(const VAArgInst *VI) {
00287   AAMDNodes AATags;
00288   VI->getAAMetadata(AATags);
00289 
00290   return Location(VI->getPointerOperand(), UnknownSize, AATags);
00291 }
00292 
00293 AliasAnalysis::Location
00294 AliasAnalysis::getLocation(const AtomicCmpXchgInst *CXI) {
00295   AAMDNodes AATags;
00296   CXI->getAAMetadata(AATags);
00297 
00298   return Location(CXI->getPointerOperand(),
00299                   getTypeStoreSize(CXI->getCompareOperand()->getType()),
00300                   AATags);
00301 }
00302 
00303 AliasAnalysis::Location
00304 AliasAnalysis::getLocation(const AtomicRMWInst *RMWI) {
00305   AAMDNodes AATags;
00306   RMWI->getAAMetadata(AATags);
00307 
00308   return Location(RMWI->getPointerOperand(),
00309                   getTypeStoreSize(RMWI->getValOperand()->getType()), AATags);
00310 }
00311 
00312 AliasAnalysis::Location
00313 AliasAnalysis::getLocationForSource(const MemTransferInst *MTI) {
00314   uint64_t Size = UnknownSize;
00315   if (ConstantInt *C = dyn_cast<ConstantInt>(MTI->getLength()))
00316     Size = C->getValue().getZExtValue();
00317 
00318   // memcpy/memmove can have AA tags. For memcpy, they apply
00319   // to both the source and the destination.
00320   AAMDNodes AATags;
00321   MTI->getAAMetadata(AATags);
00322 
00323   return Location(MTI->getRawSource(), Size, AATags);
00324 }
00325 
00326 AliasAnalysis::Location
00327 AliasAnalysis::getLocationForDest(const MemIntrinsic *MTI) {
00328   uint64_t Size = UnknownSize;
00329   if (ConstantInt *C = dyn_cast<ConstantInt>(MTI->getLength()))
00330     Size = C->getValue().getZExtValue();
00331 
00332   // memcpy/memmove can have AA tags. For memcpy, they apply
00333   // to both the source and the destination.
00334   AAMDNodes AATags;
00335   MTI->getAAMetadata(AATags);
00336 
00337   return Location(MTI->getRawDest(), Size, AATags);
00338 }
00339 
00340 
00341 
00342 AliasAnalysis::ModRefResult
00343 AliasAnalysis::getModRefInfo(const LoadInst *L, const Location &Loc) {
00344   // Be conservative in the face of volatile/atomic.
00345   if (!L->isUnordered())
00346     return ModRef;
00347 
00348   // If the load address doesn't alias the given address, it doesn't read
00349   // or write the specified memory.
00350   if (Loc.Ptr && !alias(getLocation(L), Loc))
00351     return NoModRef;
00352 
00353   // Otherwise, a load just reads.
00354   return Ref;
00355 }
00356 
00357 AliasAnalysis::ModRefResult
00358 AliasAnalysis::getModRefInfo(const StoreInst *S, const Location &Loc) {
00359   // Be conservative in the face of volatile/atomic.
00360   if (!S->isUnordered())
00361     return ModRef;
00362 
00363   if (Loc.Ptr) {
00364     // If the store address cannot alias the pointer in question, then the
00365     // specified memory cannot be modified by the store.
00366     if (!alias(getLocation(S), Loc))
00367       return NoModRef;
00368 
00369     // If the pointer is a pointer to constant memory, then it could not have
00370     // been modified by this store.
00371     if (pointsToConstantMemory(Loc))
00372       return NoModRef;
00373 
00374   }
00375 
00376   // Otherwise, a store just writes.
00377   return Mod;
00378 }
00379 
00380 AliasAnalysis::ModRefResult
00381 AliasAnalysis::getModRefInfo(const VAArgInst *V, const Location &Loc) {
00382   // If the va_arg address cannot alias the pointer in question, then the
00383   // specified memory cannot be accessed by the va_arg.
00384   if (!alias(getLocation(V), Loc))
00385     return NoModRef;
00386 
00387   // If the pointer is a pointer to constant memory, then it could not have been
00388   // modified by this va_arg.
00389   if (pointsToConstantMemory(Loc))
00390     return NoModRef;
00391 
00392   // Otherwise, a va_arg reads and writes.
00393   return ModRef;
00394 }
00395 
00396 AliasAnalysis::ModRefResult
00397 AliasAnalysis::getModRefInfo(const AtomicCmpXchgInst *CX, const Location &Loc) {
00398   // Acquire/Release cmpxchg has properties that matter for arbitrary addresses.
00399   if (CX->getSuccessOrdering() > Monotonic)
00400     return ModRef;
00401 
00402   // If the cmpxchg address does not alias the location, it does not access it.
00403   if (!alias(getLocation(CX), Loc))
00404     return NoModRef;
00405 
00406   return ModRef;
00407 }
00408 
00409 AliasAnalysis::ModRefResult
00410 AliasAnalysis::getModRefInfo(const AtomicRMWInst *RMW, const Location &Loc) {
00411   // Acquire/Release atomicrmw has properties that matter for arbitrary addresses.
00412   if (RMW->getOrdering() > Monotonic)
00413     return ModRef;
00414 
00415   // If the atomicrmw address does not alias the location, it does not access it.
00416   if (!alias(getLocation(RMW), Loc))
00417     return NoModRef;
00418 
00419   return ModRef;
00420 }
00421 
00422 // FIXME: this is really just shoring-up a deficiency in alias analysis.
00423 // BasicAA isn't willing to spend linear time determining whether an alloca
00424 // was captured before or after this particular call, while we are. However,
00425 // with a smarter AA in place, this test is just wasting compile time.
00426 AliasAnalysis::ModRefResult
00427 AliasAnalysis::callCapturesBefore(const Instruction *I,
00428                                   const AliasAnalysis::Location &MemLoc,
00429                                   DominatorTree *DT) {
00430   if (!DT)
00431     return AliasAnalysis::ModRef;
00432 
00433   const Value *Object = GetUnderlyingObject(MemLoc.Ptr, *DL);
00434   if (!isIdentifiedObject(Object) || isa<GlobalValue>(Object) ||
00435       isa<Constant>(Object))
00436     return AliasAnalysis::ModRef;
00437 
00438   ImmutableCallSite CS(I);
00439   if (!CS.getInstruction() || CS.getInstruction() == Object)
00440     return AliasAnalysis::ModRef;
00441 
00442   if (llvm::PointerMayBeCapturedBefore(Object, /* ReturnCaptures */ true,
00443                                        /* StoreCaptures */ true, I, DT,
00444                                        /* include Object */ true))
00445     return AliasAnalysis::ModRef;
00446 
00447   unsigned ArgNo = 0;
00448   AliasAnalysis::ModRefResult R = AliasAnalysis::NoModRef;
00449   for (ImmutableCallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end();
00450        CI != CE; ++CI, ++ArgNo) {
00451     // Only look at the no-capture or byval pointer arguments.  If this
00452     // pointer were passed to arguments that were neither of these, then it
00453     // couldn't be no-capture.
00454     if (!(*CI)->getType()->isPointerTy() ||
00455         (!CS.doesNotCapture(ArgNo) && !CS.isByValArgument(ArgNo)))
00456       continue;
00457 
00458     // If this is a no-capture pointer argument, see if we can tell that it
00459     // is impossible to alias the pointer we're checking.  If not, we have to
00460     // assume that the call could touch the pointer, even though it doesn't
00461     // escape.
00462     if (isNoAlias(AliasAnalysis::Location(*CI),
00463                   AliasAnalysis::Location(Object)))
00464       continue;
00465     if (CS.doesNotAccessMemory(ArgNo))
00466       continue;
00467     if (CS.onlyReadsMemory(ArgNo)) {
00468       R = AliasAnalysis::Ref;
00469       continue;
00470     }
00471     return AliasAnalysis::ModRef;
00472   }
00473   return R;
00474 }
00475 
00476 // AliasAnalysis destructor: DO NOT move this to the header file for
00477 // AliasAnalysis or else clients of the AliasAnalysis class may not depend on
00478 // the AliasAnalysis.o file in the current .a file, causing alias analysis
00479 // support to not be included in the tool correctly!
00480 //
00481 AliasAnalysis::~AliasAnalysis() {}
00482 
00483 /// InitializeAliasAnalysis - Subclasses must call this method to initialize the
00484 /// AliasAnalysis interface before any other methods are called.
00485 ///
00486 void AliasAnalysis::InitializeAliasAnalysis(Pass *P, const DataLayout *NewDL) {
00487   DL = NewDL;
00488   auto *TLIP = P->getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
00489   TLI = TLIP ? &TLIP->getTLI() : nullptr;
00490   AA = &P->getAnalysis<AliasAnalysis>();
00491 }
00492 
00493 // getAnalysisUsage - All alias analysis implementations should invoke this
00494 // directly (using AliasAnalysis::getAnalysisUsage(AU)).
00495 void AliasAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
00496   AU.addRequired<AliasAnalysis>();         // All AA's chain
00497 }
00498 
00499 /// getTypeStoreSize - Return the DataLayout store size for the given type,
00500 /// if known, or a conservative value otherwise.
00501 ///
00502 uint64_t AliasAnalysis::getTypeStoreSize(Type *Ty) {
00503   return DL ? DL->getTypeStoreSize(Ty) : UnknownSize;
00504 }
00505 
00506 /// canBasicBlockModify - Return true if it is possible for execution of the
00507 /// specified basic block to modify the location Loc.
00508 ///
00509 bool AliasAnalysis::canBasicBlockModify(const BasicBlock &BB,
00510                                         const Location &Loc) {
00511   return canInstructionRangeModRef(BB.front(), BB.back(), Loc, Mod);
00512 }
00513 
00514 /// canInstructionRangeModRef - Return true if it is possible for the
00515 /// execution of the specified instructions to mod\ref (according to the
00516 /// mode) the location Loc. The instructions to consider are all
00517 /// of the instructions in the range of [I1,I2] INCLUSIVE.
00518 /// I1 and I2 must be in the same basic block.  
00519 bool AliasAnalysis::canInstructionRangeModRef(const Instruction &I1,
00520                                               const Instruction &I2,
00521                                               const Location &Loc,
00522                                               const ModRefResult Mode) {
00523   assert(I1.getParent() == I2.getParent() &&
00524          "Instructions not in same basic block!");
00525   BasicBlock::const_iterator I = &I1;
00526   BasicBlock::const_iterator E = &I2;
00527   ++E;  // Convert from inclusive to exclusive range.
00528 
00529   for (; I != E; ++I) // Check every instruction in range
00530     if (getModRefInfo(I, Loc) & Mode)
00531       return true;
00532   return false;
00533 }
00534 
00535 /// isNoAliasCall - Return true if this pointer is returned by a noalias
00536 /// function.
00537 bool llvm::isNoAliasCall(const Value *V) {
00538   if (isa<CallInst>(V) || isa<InvokeInst>(V))
00539     return ImmutableCallSite(cast<Instruction>(V))
00540       .paramHasAttr(0, Attribute::NoAlias);
00541   return false;
00542 }
00543 
00544 /// isNoAliasArgument - Return true if this is an argument with the noalias
00545 /// attribute.
00546 bool llvm::isNoAliasArgument(const Value *V)
00547 {
00548   if (const Argument *A = dyn_cast<Argument>(V))
00549     return A->hasNoAliasAttr();
00550   return false;
00551 }
00552 
00553 /// isIdentifiedObject - Return true if this pointer refers to a distinct and
00554 /// identifiable object.  This returns true for:
00555 ///    Global Variables and Functions (but not Global Aliases)
00556 ///    Allocas and Mallocs
00557 ///    ByVal and NoAlias Arguments
00558 ///    NoAlias returns
00559 ///
00560 bool llvm::isIdentifiedObject(const Value *V) {
00561   if (isa<AllocaInst>(V))
00562     return true;
00563   if (isa<GlobalValue>(V) && !isa<GlobalAlias>(V))
00564     return true;
00565   if (isNoAliasCall(V))
00566     return true;
00567   if (const Argument *A = dyn_cast<Argument>(V))
00568     return A->hasNoAliasAttr() || A->hasByValAttr();
00569   return false;
00570 }
00571 
00572 /// isIdentifiedFunctionLocal - Return true if V is umabigously identified
00573 /// at the function-level. Different IdentifiedFunctionLocals can't alias.
00574 /// Further, an IdentifiedFunctionLocal can not alias with any function
00575 /// arguments other than itself, which is not necessarily true for
00576 /// IdentifiedObjects.
00577 bool llvm::isIdentifiedFunctionLocal(const Value *V)
00578 {
00579   return isa<AllocaInst>(V) || isNoAliasCall(V) || isNoAliasArgument(V);
00580 }