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 
00383   if (Loc.Ptr) {
00384     // If the va_arg address cannot alias the pointer in question, then the
00385     // specified memory cannot be accessed by the va_arg.
00386     if (!alias(getLocation(V), Loc))
00387       return NoModRef;
00388 
00389     // If the pointer is a pointer to constant memory, then it could not have
00390     // been modified by this va_arg.
00391     if (pointsToConstantMemory(Loc))
00392       return NoModRef;
00393   }
00394 
00395   // Otherwise, a va_arg reads and writes.
00396   return ModRef;
00397 }
00398 
00399 AliasAnalysis::ModRefResult
00400 AliasAnalysis::getModRefInfo(const AtomicCmpXchgInst *CX, const Location &Loc) {
00401   // Acquire/Release cmpxchg has properties that matter for arbitrary addresses.
00402   if (CX->getSuccessOrdering() > Monotonic)
00403     return ModRef;
00404 
00405   // If the cmpxchg address does not alias the location, it does not access it.
00406   if (Loc.Ptr && !alias(getLocation(CX), Loc))
00407     return NoModRef;
00408 
00409   return ModRef;
00410 }
00411 
00412 AliasAnalysis::ModRefResult
00413 AliasAnalysis::getModRefInfo(const AtomicRMWInst *RMW, const Location &Loc) {
00414   // Acquire/Release atomicrmw has properties that matter for arbitrary addresses.
00415   if (RMW->getOrdering() > Monotonic)
00416     return ModRef;
00417 
00418   // If the atomicrmw address does not alias the location, it does not access it.
00419   if (Loc.Ptr && !alias(getLocation(RMW), Loc))
00420     return NoModRef;
00421 
00422   return ModRef;
00423 }
00424 
00425 // FIXME: this is really just shoring-up a deficiency in alias analysis.
00426 // BasicAA isn't willing to spend linear time determining whether an alloca
00427 // was captured before or after this particular call, while we are. However,
00428 // with a smarter AA in place, this test is just wasting compile time.
00429 AliasAnalysis::ModRefResult
00430 AliasAnalysis::callCapturesBefore(const Instruction *I,
00431                                   const AliasAnalysis::Location &MemLoc,
00432                                   DominatorTree *DT) {
00433   if (!DT)
00434     return AliasAnalysis::ModRef;
00435 
00436   const Value *Object = GetUnderlyingObject(MemLoc.Ptr, *DL);
00437   if (!isIdentifiedObject(Object) || isa<GlobalValue>(Object) ||
00438       isa<Constant>(Object))
00439     return AliasAnalysis::ModRef;
00440 
00441   ImmutableCallSite CS(I);
00442   if (!CS.getInstruction() || CS.getInstruction() == Object)
00443     return AliasAnalysis::ModRef;
00444 
00445   if (llvm::PointerMayBeCapturedBefore(Object, /* ReturnCaptures */ true,
00446                                        /* StoreCaptures */ true, I, DT,
00447                                        /* include Object */ true))
00448     return AliasAnalysis::ModRef;
00449 
00450   unsigned ArgNo = 0;
00451   AliasAnalysis::ModRefResult R = AliasAnalysis::NoModRef;
00452   for (ImmutableCallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end();
00453        CI != CE; ++CI, ++ArgNo) {
00454     // Only look at the no-capture or byval pointer arguments.  If this
00455     // pointer were passed to arguments that were neither of these, then it
00456     // couldn't be no-capture.
00457     if (!(*CI)->getType()->isPointerTy() ||
00458         (!CS.doesNotCapture(ArgNo) && !CS.isByValArgument(ArgNo)))
00459       continue;
00460 
00461     // If this is a no-capture pointer argument, see if we can tell that it
00462     // is impossible to alias the pointer we're checking.  If not, we have to
00463     // assume that the call could touch the pointer, even though it doesn't
00464     // escape.
00465     if (isNoAlias(AliasAnalysis::Location(*CI),
00466                   AliasAnalysis::Location(Object)))
00467       continue;
00468     if (CS.doesNotAccessMemory(ArgNo))
00469       continue;
00470     if (CS.onlyReadsMemory(ArgNo)) {
00471       R = AliasAnalysis::Ref;
00472       continue;
00473     }
00474     return AliasAnalysis::ModRef;
00475   }
00476   return R;
00477 }
00478 
00479 // AliasAnalysis destructor: DO NOT move this to the header file for
00480 // AliasAnalysis or else clients of the AliasAnalysis class may not depend on
00481 // the AliasAnalysis.o file in the current .a file, causing alias analysis
00482 // support to not be included in the tool correctly!
00483 //
00484 AliasAnalysis::~AliasAnalysis() {}
00485 
00486 /// InitializeAliasAnalysis - Subclasses must call this method to initialize the
00487 /// AliasAnalysis interface before any other methods are called.
00488 ///
00489 void AliasAnalysis::InitializeAliasAnalysis(Pass *P, const DataLayout *NewDL) {
00490   DL = NewDL;
00491   auto *TLIP = P->getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
00492   TLI = TLIP ? &TLIP->getTLI() : nullptr;
00493   AA = &P->getAnalysis<AliasAnalysis>();
00494 }
00495 
00496 // getAnalysisUsage - All alias analysis implementations should invoke this
00497 // directly (using AliasAnalysis::getAnalysisUsage(AU)).
00498 void AliasAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
00499   AU.addRequired<AliasAnalysis>();         // All AA's chain
00500 }
00501 
00502 /// getTypeStoreSize - Return the DataLayout store size for the given type,
00503 /// if known, or a conservative value otherwise.
00504 ///
00505 uint64_t AliasAnalysis::getTypeStoreSize(Type *Ty) {
00506   return DL ? DL->getTypeStoreSize(Ty) : UnknownSize;
00507 }
00508 
00509 /// canBasicBlockModify - Return true if it is possible for execution of the
00510 /// specified basic block to modify the location Loc.
00511 ///
00512 bool AliasAnalysis::canBasicBlockModify(const BasicBlock &BB,
00513                                         const Location &Loc) {
00514   return canInstructionRangeModRef(BB.front(), BB.back(), Loc, Mod);
00515 }
00516 
00517 /// canInstructionRangeModRef - Return true if it is possible for the
00518 /// execution of the specified instructions to mod\ref (according to the
00519 /// mode) the location Loc. The instructions to consider are all
00520 /// of the instructions in the range of [I1,I2] INCLUSIVE.
00521 /// I1 and I2 must be in the same basic block.
00522 bool AliasAnalysis::canInstructionRangeModRef(const Instruction &I1,
00523                                               const Instruction &I2,
00524                                               const Location &Loc,
00525                                               const ModRefResult Mode) {
00526   assert(I1.getParent() == I2.getParent() &&
00527          "Instructions not in same basic block!");
00528   BasicBlock::const_iterator I = &I1;
00529   BasicBlock::const_iterator E = &I2;
00530   ++E;  // Convert from inclusive to exclusive range.
00531 
00532   for (; I != E; ++I) // Check every instruction in range
00533     if (getModRefInfo(I, Loc) & Mode)
00534       return true;
00535   return false;
00536 }
00537 
00538 /// isNoAliasCall - Return true if this pointer is returned by a noalias
00539 /// function.
00540 bool llvm::isNoAliasCall(const Value *V) {
00541   if (isa<CallInst>(V) || isa<InvokeInst>(V))
00542     return ImmutableCallSite(cast<Instruction>(V))
00543       .paramHasAttr(0, Attribute::NoAlias);
00544   return false;
00545 }
00546 
00547 /// isNoAliasArgument - Return true if this is an argument with the noalias
00548 /// attribute.
00549 bool llvm::isNoAliasArgument(const Value *V)
00550 {
00551   if (const Argument *A = dyn_cast<Argument>(V))
00552     return A->hasNoAliasAttr();
00553   return false;
00554 }
00555 
00556 /// isIdentifiedObject - Return true if this pointer refers to a distinct and
00557 /// identifiable object.  This returns true for:
00558 ///    Global Variables and Functions (but not Global Aliases)
00559 ///    Allocas and Mallocs
00560 ///    ByVal and NoAlias Arguments
00561 ///    NoAlias returns
00562 ///
00563 bool llvm::isIdentifiedObject(const Value *V) {
00564   if (isa<AllocaInst>(V))
00565     return true;
00566   if (isa<GlobalValue>(V) && !isa<GlobalAlias>(V))
00567     return true;
00568   if (isNoAliasCall(V))
00569     return true;
00570   if (const Argument *A = dyn_cast<Argument>(V))
00571     return A->hasNoAliasAttr() || A->hasByValAttr();
00572   return false;
00573 }
00574 
00575 /// isIdentifiedFunctionLocal - Return true if V is umabigously identified
00576 /// at the function-level. Different IdentifiedFunctionLocals can't alias.
00577 /// Further, an IdentifiedFunctionLocal can not alias with any function
00578 /// arguments other than itself, which is not necessarily true for
00579 /// IdentifiedObjects.
00580 bool llvm::isIdentifiedFunctionLocal(const Value *V)
00581 {
00582   return isa<AllocaInst>(V) || isNoAliasCall(V) || isNoAliasArgument(V);
00583 }