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/BasicAliasAnalysis.h"
00029 #include "llvm/Analysis/CFG.h"
00030 #include "llvm/Analysis/CFLAliasAnalysis.h"
00031 #include "llvm/Analysis/CaptureTracking.h"
00032 #include "llvm/Analysis/GlobalsModRef.h"
00033 #include "llvm/Analysis/ObjCARCAliasAnalysis.h"
00034 #include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
00035 #include "llvm/Analysis/ScopedNoAliasAA.h"
00036 #include "llvm/Analysis/TargetLibraryInfo.h"
00037 #include "llvm/Analysis/TypeBasedAliasAnalysis.h"
00038 #include "llvm/Analysis/ValueTracking.h"
00039 #include "llvm/IR/BasicBlock.h"
00040 #include "llvm/IR/DataLayout.h"
00041 #include "llvm/IR/Dominators.h"
00042 #include "llvm/IR/Function.h"
00043 #include "llvm/IR/Instructions.h"
00044 #include "llvm/IR/IntrinsicInst.h"
00045 #include "llvm/IR/LLVMContext.h"
00046 #include "llvm/IR/Type.h"
00047 #include "llvm/Pass.h"
00048 using namespace llvm;
00049 
00050 /// Allow disabling BasicAA from the AA results. This is particularly useful
00051 /// when testing to isolate a single AA implementation.
00052 static cl::opt<bool> DisableBasicAA("disable-basicaa", cl::Hidden,
00053                                     cl::init(false));
00054 
00055 AAResults::AAResults(AAResults &&Arg) : AAs(std::move(Arg.AAs)) {
00056   for (auto &AA : AAs)
00057     AA->setAAResults(this);
00058 }
00059 
00060 AAResults &AAResults::operator=(AAResults &&Arg) {
00061   AAs = std::move(Arg.AAs);
00062   for (auto &AA : AAs)
00063     AA->setAAResults(this);
00064   return *this;
00065 }
00066 
00067 AAResults::~AAResults() {
00068 // FIXME; It would be nice to at least clear out the pointers back to this
00069 // aggregation here, but we end up with non-nesting lifetimes in the legacy
00070 // pass manager that prevent this from working. In the legacy pass manager
00071 // we'll end up with dangling references here in some cases.
00072 #if 0
00073   for (auto &AA : AAs)
00074     AA->setAAResults(nullptr);
00075 #endif
00076 }
00077 
00078 //===----------------------------------------------------------------------===//
00079 // Default chaining methods
00080 //===----------------------------------------------------------------------===//
00081 
00082 AliasResult AAResults::alias(const MemoryLocation &LocA,
00083                              const MemoryLocation &LocB) {
00084   for (const auto &AA : AAs) {
00085     auto Result = AA->alias(LocA, LocB);
00086     if (Result != MayAlias)
00087       return Result;
00088   }
00089   return MayAlias;
00090 }
00091 
00092 bool AAResults::pointsToConstantMemory(const MemoryLocation &Loc,
00093                                        bool OrLocal) {
00094   for (const auto &AA : AAs)
00095     if (AA->pointsToConstantMemory(Loc, OrLocal))
00096       return true;
00097 
00098   return false;
00099 }
00100 
00101 ModRefInfo AAResults::getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx) {
00102   ModRefInfo Result = MRI_ModRef;
00103 
00104   for (const auto &AA : AAs) {
00105     Result = ModRefInfo(Result & AA->getArgModRefInfo(CS, ArgIdx));
00106 
00107     // Early-exit the moment we reach the bottom of the lattice.
00108     if (Result == MRI_NoModRef)
00109       return Result;
00110   }
00111 
00112   return Result;
00113 }
00114 
00115 ModRefInfo AAResults::getModRefInfo(Instruction *I, ImmutableCallSite Call) {
00116   // We may have two calls
00117   if (auto CS = ImmutableCallSite(I)) {
00118     // Check if the two calls modify the same memory
00119     return getModRefInfo(Call, CS);
00120   } else {
00121     // Otherwise, check if the call modifies or references the
00122     // location this memory access defines.  The best we can say
00123     // is that if the call references what this instruction
00124     // defines, it must be clobbered by this location.
00125     const MemoryLocation DefLoc = MemoryLocation::get(I);
00126     if (getModRefInfo(Call, DefLoc) != MRI_NoModRef)
00127       return MRI_ModRef;
00128   }
00129   return MRI_NoModRef;
00130 }
00131 
00132 ModRefInfo AAResults::getModRefInfo(ImmutableCallSite CS,
00133                                     const MemoryLocation &Loc) {
00134   ModRefInfo Result = MRI_ModRef;
00135 
00136   for (const auto &AA : AAs) {
00137     Result = ModRefInfo(Result & AA->getModRefInfo(CS, Loc));
00138 
00139     // Early-exit the moment we reach the bottom of the lattice.
00140     if (Result == MRI_NoModRef)
00141       return Result;
00142   }
00143 
00144   return Result;
00145 }
00146 
00147 ModRefInfo AAResults::getModRefInfo(ImmutableCallSite CS1,
00148                                     ImmutableCallSite CS2) {
00149   ModRefInfo Result = MRI_ModRef;
00150 
00151   for (const auto &AA : AAs) {
00152     Result = ModRefInfo(Result & AA->getModRefInfo(CS1, CS2));
00153 
00154     // Early-exit the moment we reach the bottom of the lattice.
00155     if (Result == MRI_NoModRef)
00156       return Result;
00157   }
00158 
00159   return Result;
00160 }
00161 
00162 FunctionModRefBehavior AAResults::getModRefBehavior(ImmutableCallSite CS) {
00163   FunctionModRefBehavior Result = FMRB_UnknownModRefBehavior;
00164 
00165   for (const auto &AA : AAs) {
00166     Result = FunctionModRefBehavior(Result & AA->getModRefBehavior(CS));
00167 
00168     // Early-exit the moment we reach the bottom of the lattice.
00169     if (Result == FMRB_DoesNotAccessMemory)
00170       return Result;
00171   }
00172 
00173   return Result;
00174 }
00175 
00176 FunctionModRefBehavior AAResults::getModRefBehavior(const Function *F) {
00177   FunctionModRefBehavior Result = FMRB_UnknownModRefBehavior;
00178 
00179   for (const auto &AA : AAs) {
00180     Result = FunctionModRefBehavior(Result & AA->getModRefBehavior(F));
00181 
00182     // Early-exit the moment we reach the bottom of the lattice.
00183     if (Result == FMRB_DoesNotAccessMemory)
00184       return Result;
00185   }
00186 
00187   return Result;
00188 }
00189 
00190 //===----------------------------------------------------------------------===//
00191 // Helper method implementation
00192 //===----------------------------------------------------------------------===//
00193 
00194 ModRefInfo AAResults::getModRefInfo(const LoadInst *L,
00195                                     const MemoryLocation &Loc) {
00196   // Be conservative in the face of volatile/atomic.
00197   if (!L->isUnordered())
00198     return MRI_ModRef;
00199 
00200   // If the load address doesn't alias the given address, it doesn't read
00201   // or write the specified memory.
00202   if (Loc.Ptr && !alias(MemoryLocation::get(L), Loc))
00203     return MRI_NoModRef;
00204 
00205   // Otherwise, a load just reads.
00206   return MRI_Ref;
00207 }
00208 
00209 ModRefInfo AAResults::getModRefInfo(const StoreInst *S,
00210                                     const MemoryLocation &Loc) {
00211   // Be conservative in the face of volatile/atomic.
00212   if (!S->isUnordered())
00213     return MRI_ModRef;
00214 
00215   if (Loc.Ptr) {
00216     // If the store address cannot alias the pointer in question, then the
00217     // specified memory cannot be modified by the store.
00218     if (!alias(MemoryLocation::get(S), Loc))
00219       return MRI_NoModRef;
00220 
00221     // If the pointer is a pointer to constant memory, then it could not have
00222     // been modified by this store.
00223     if (pointsToConstantMemory(Loc))
00224       return MRI_NoModRef;
00225   }
00226 
00227   // Otherwise, a store just writes.
00228   return MRI_Mod;
00229 }
00230 
00231 ModRefInfo AAResults::getModRefInfo(const VAArgInst *V,
00232                                     const MemoryLocation &Loc) {
00233 
00234   if (Loc.Ptr) {
00235     // If the va_arg address cannot alias the pointer in question, then the
00236     // specified memory cannot be accessed by the va_arg.
00237     if (!alias(MemoryLocation::get(V), Loc))
00238       return MRI_NoModRef;
00239 
00240     // If the pointer is a pointer to constant memory, then it could not have
00241     // been modified by this va_arg.
00242     if (pointsToConstantMemory(Loc))
00243       return MRI_NoModRef;
00244   }
00245 
00246   // Otherwise, a va_arg reads and writes.
00247   return MRI_ModRef;
00248 }
00249 
00250 ModRefInfo AAResults::getModRefInfo(const CatchPadInst *CatchPad,
00251                                     const MemoryLocation &Loc) {
00252   if (Loc.Ptr) {
00253     // If the pointer is a pointer to constant memory,
00254     // then it could not have been modified by this catchpad.
00255     if (pointsToConstantMemory(Loc))
00256       return MRI_NoModRef;
00257   }
00258 
00259   // Otherwise, a catchpad reads and writes.
00260   return MRI_ModRef;
00261 }
00262 
00263 ModRefInfo AAResults::getModRefInfo(const CatchReturnInst *CatchRet,
00264                                     const MemoryLocation &Loc) {
00265   if (Loc.Ptr) {
00266     // If the pointer is a pointer to constant memory,
00267     // then it could not have been modified by this catchpad.
00268     if (pointsToConstantMemory(Loc))
00269       return MRI_NoModRef;
00270   }
00271 
00272   // Otherwise, a catchret reads and writes.
00273   return MRI_ModRef;
00274 }
00275 
00276 ModRefInfo AAResults::getModRefInfo(const AtomicCmpXchgInst *CX,
00277                                     const MemoryLocation &Loc) {
00278   // Acquire/Release cmpxchg has properties that matter for arbitrary addresses.
00279   if (CX->getSuccessOrdering() > Monotonic)
00280     return MRI_ModRef;
00281 
00282   // If the cmpxchg address does not alias the location, it does not access it.
00283   if (Loc.Ptr && !alias(MemoryLocation::get(CX), Loc))
00284     return MRI_NoModRef;
00285 
00286   return MRI_ModRef;
00287 }
00288 
00289 ModRefInfo AAResults::getModRefInfo(const AtomicRMWInst *RMW,
00290                                     const MemoryLocation &Loc) {
00291   // Acquire/Release atomicrmw has properties that matter for arbitrary addresses.
00292   if (RMW->getOrdering() > Monotonic)
00293     return MRI_ModRef;
00294 
00295   // If the atomicrmw address does not alias the location, it does not access it.
00296   if (Loc.Ptr && !alias(MemoryLocation::get(RMW), Loc))
00297     return MRI_NoModRef;
00298 
00299   return MRI_ModRef;
00300 }
00301 
00302 /// \brief Return information about whether a particular call site modifies
00303 /// or reads the specified memory location \p MemLoc before instruction \p I
00304 /// in a BasicBlock. A ordered basic block \p OBB can be used to speed up
00305 /// instruction-ordering queries inside the BasicBlock containing \p I.
00306 /// FIXME: this is really just shoring-up a deficiency in alias analysis.
00307 /// BasicAA isn't willing to spend linear time determining whether an alloca
00308 /// was captured before or after this particular call, while we are. However,
00309 /// with a smarter AA in place, this test is just wasting compile time.
00310 ModRefInfo AAResults::callCapturesBefore(const Instruction *I,
00311                                          const MemoryLocation &MemLoc,
00312                                          DominatorTree *DT,
00313                                          OrderedBasicBlock *OBB) {
00314   if (!DT)
00315     return MRI_ModRef;
00316 
00317   const Value *Object =
00318       GetUnderlyingObject(MemLoc.Ptr, I->getModule()->getDataLayout());
00319   if (!isIdentifiedObject(Object) || isa<GlobalValue>(Object) ||
00320       isa<Constant>(Object))
00321     return MRI_ModRef;
00322 
00323   ImmutableCallSite CS(I);
00324   if (!CS.getInstruction() || CS.getInstruction() == Object)
00325     return MRI_ModRef;
00326 
00327   if (llvm::PointerMayBeCapturedBefore(Object, /* ReturnCaptures */ true,
00328                                        /* StoreCaptures */ true, I, DT,
00329                                        /* include Object */ true,
00330                                        /* OrderedBasicBlock */ OBB))
00331     return MRI_ModRef;
00332 
00333   unsigned ArgNo = 0;
00334   ModRefInfo R = MRI_NoModRef;
00335   for (ImmutableCallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end();
00336        CI != CE; ++CI, ++ArgNo) {
00337     // Only look at the no-capture or byval pointer arguments.  If this
00338     // pointer were passed to arguments that were neither of these, then it
00339     // couldn't be no-capture.
00340     if (!(*CI)->getType()->isPointerTy() ||
00341         (!CS.doesNotCapture(ArgNo) && !CS.isByValArgument(ArgNo)))
00342       continue;
00343 
00344     // If this is a no-capture pointer argument, see if we can tell that it
00345     // is impossible to alias the pointer we're checking.  If not, we have to
00346     // assume that the call could touch the pointer, even though it doesn't
00347     // escape.
00348     if (isNoAlias(MemoryLocation(*CI), MemoryLocation(Object)))
00349       continue;
00350     if (CS.doesNotAccessMemory(ArgNo))
00351       continue;
00352     if (CS.onlyReadsMemory(ArgNo)) {
00353       R = MRI_Ref;
00354       continue;
00355     }
00356     return MRI_ModRef;
00357   }
00358   return R;
00359 }
00360 
00361 /// canBasicBlockModify - Return true if it is possible for execution of the
00362 /// specified basic block to modify the location Loc.
00363 ///
00364 bool AAResults::canBasicBlockModify(const BasicBlock &BB,
00365                                     const MemoryLocation &Loc) {
00366   return canInstructionRangeModRef(BB.front(), BB.back(), Loc, MRI_Mod);
00367 }
00368 
00369 /// canInstructionRangeModRef - Return true if it is possible for the
00370 /// execution of the specified instructions to mod\ref (according to the
00371 /// mode) the location Loc. The instructions to consider are all
00372 /// of the instructions in the range of [I1,I2] INCLUSIVE.
00373 /// I1 and I2 must be in the same basic block.
00374 bool AAResults::canInstructionRangeModRef(const Instruction &I1,
00375                                           const Instruction &I2,
00376                                           const MemoryLocation &Loc,
00377                                           const ModRefInfo Mode) {
00378   assert(I1.getParent() == I2.getParent() &&
00379          "Instructions not in same basic block!");
00380   BasicBlock::const_iterator I = I1.getIterator();
00381   BasicBlock::const_iterator E = I2.getIterator();
00382   ++E;  // Convert from inclusive to exclusive range.
00383 
00384   for (; I != E; ++I) // Check every instruction in range
00385     if (getModRefInfo(&*I, Loc) & Mode)
00386       return true;
00387   return false;
00388 }
00389 
00390 // Provide a definition for the root virtual destructor.
00391 AAResults::Concept::~Concept() {}
00392 
00393 namespace {
00394 /// A wrapper pass for external alias analyses. This just squirrels away the
00395 /// callback used to run any analyses and register their results.
00396 struct ExternalAAWrapperPass : ImmutablePass {
00397   typedef std::function<void(Pass &, Function &, AAResults &)> CallbackT;
00398 
00399   CallbackT CB;
00400 
00401   static char ID;
00402 
00403   ExternalAAWrapperPass() : ImmutablePass(ID) {
00404     initializeExternalAAWrapperPassPass(*PassRegistry::getPassRegistry());
00405   }
00406   explicit ExternalAAWrapperPass(CallbackT CB)
00407       : ImmutablePass(ID), CB(std::move(CB)) {
00408     initializeExternalAAWrapperPassPass(*PassRegistry::getPassRegistry());
00409   }
00410 
00411   void getAnalysisUsage(AnalysisUsage &AU) const override {
00412     AU.setPreservesAll();
00413   }
00414 };
00415 }
00416 
00417 char ExternalAAWrapperPass::ID = 0;
00418 INITIALIZE_PASS(ExternalAAWrapperPass, "external-aa", "External Alias Analysis",
00419                 false, true)
00420 
00421 ImmutablePass *
00422 llvm::createExternalAAWrapperPass(ExternalAAWrapperPass::CallbackT Callback) {
00423   return new ExternalAAWrapperPass(std::move(Callback));
00424 }
00425 
00426 AAResultsWrapperPass::AAResultsWrapperPass() : FunctionPass(ID) {
00427   initializeAAResultsWrapperPassPass(*PassRegistry::getPassRegistry());
00428 }
00429 
00430 char AAResultsWrapperPass::ID = 0;
00431 
00432 INITIALIZE_PASS_BEGIN(AAResultsWrapperPass, "aa",
00433                       "Function Alias Analysis Results", false, true)
00434 INITIALIZE_PASS_DEPENDENCY(BasicAAWrapperPass)
00435 INITIALIZE_PASS_DEPENDENCY(CFLAAWrapperPass)
00436 INITIALIZE_PASS_DEPENDENCY(ExternalAAWrapperPass)
00437 INITIALIZE_PASS_DEPENDENCY(GlobalsAAWrapperPass)
00438 INITIALIZE_PASS_DEPENDENCY(ObjCARCAAWrapperPass)
00439 INITIALIZE_PASS_DEPENDENCY(SCEVAAWrapperPass)
00440 INITIALIZE_PASS_DEPENDENCY(ScopedNoAliasAAWrapperPass)
00441 INITIALIZE_PASS_DEPENDENCY(TypeBasedAAWrapperPass)
00442 INITIALIZE_PASS_END(AAResultsWrapperPass, "aa",
00443                     "Function Alias Analysis Results", false, true)
00444 
00445 FunctionPass *llvm::createAAResultsWrapperPass() {
00446   return new AAResultsWrapperPass();
00447 }
00448 
00449 /// Run the wrapper pass to rebuild an aggregation over known AA passes.
00450 ///
00451 /// This is the legacy pass manager's interface to the new-style AA results
00452 /// aggregation object. Because this is somewhat shoe-horned into the legacy
00453 /// pass manager, we hard code all the specific alias analyses available into
00454 /// it. While the particular set enabled is configured via commandline flags,
00455 /// adding a new alias analysis to LLVM will require adding support for it to
00456 /// this list.
00457 bool AAResultsWrapperPass::runOnFunction(Function &F) {
00458   // NB! This *must* be reset before adding new AA results to the new
00459   // AAResults object because in the legacy pass manager, each instance
00460   // of these will refer to the *same* immutable analyses, registering and
00461   // unregistering themselves with them. We need to carefully tear down the
00462   // previous object first, in this case replacing it with an empty one, before
00463   // registering new results.
00464   AAR.reset(new AAResults());
00465 
00466   // BasicAA is always available for function analyses. Also, we add it first
00467   // so that it can trump TBAA results when it proves MustAlias.
00468   // FIXME: TBAA should have an explicit mode to support this and then we
00469   // should reconsider the ordering here.
00470   if (!DisableBasicAA)
00471     AAR->addAAResult(getAnalysis<BasicAAWrapperPass>().getResult());
00472 
00473   // Populate the results with the currently available AAs.
00474   if (auto *WrapperPass = getAnalysisIfAvailable<ScopedNoAliasAAWrapperPass>())
00475     AAR->addAAResult(WrapperPass->getResult());
00476   if (auto *WrapperPass = getAnalysisIfAvailable<TypeBasedAAWrapperPass>())
00477     AAR->addAAResult(WrapperPass->getResult());
00478   if (auto *WrapperPass =
00479           getAnalysisIfAvailable<objcarc::ObjCARCAAWrapperPass>())
00480     AAR->addAAResult(WrapperPass->getResult());
00481   if (auto *WrapperPass = getAnalysisIfAvailable<GlobalsAAWrapperPass>())
00482     AAR->addAAResult(WrapperPass->getResult());
00483   if (auto *WrapperPass = getAnalysisIfAvailable<SCEVAAWrapperPass>())
00484     AAR->addAAResult(WrapperPass->getResult());
00485   if (auto *WrapperPass = getAnalysisIfAvailable<CFLAAWrapperPass>())
00486     AAR->addAAResult(WrapperPass->getResult());
00487 
00488   // If available, run an external AA providing callback over the results as
00489   // well.
00490   if (auto *WrapperPass = getAnalysisIfAvailable<ExternalAAWrapperPass>())
00491     if (WrapperPass->CB)
00492       WrapperPass->CB(*this, F, *AAR);
00493 
00494   // Analyses don't mutate the IR, so return false.
00495   return false;
00496 }
00497 
00498 void AAResultsWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
00499   AU.setPreservesAll();
00500   AU.addRequired<BasicAAWrapperPass>();
00501 
00502   // We also need to mark all the alias analysis passes we will potentially
00503   // probe in runOnFunction as used here to ensure the legacy pass manager
00504   // preserves them. This hard coding of lists of alias analyses is specific to
00505   // the legacy pass manager.
00506   AU.addUsedIfAvailable<ScopedNoAliasAAWrapperPass>();
00507   AU.addUsedIfAvailable<TypeBasedAAWrapperPass>();
00508   AU.addUsedIfAvailable<objcarc::ObjCARCAAWrapperPass>();
00509   AU.addUsedIfAvailable<GlobalsAAWrapperPass>();
00510   AU.addUsedIfAvailable<SCEVAAWrapperPass>();
00511   AU.addUsedIfAvailable<CFLAAWrapperPass>();
00512 }
00513 
00514 AAResults llvm::createLegacyPMAAResults(Pass &P, Function &F,
00515                                         BasicAAResult &BAR) {
00516   AAResults AAR;
00517 
00518   // Add in our explicitly constructed BasicAA results.
00519   if (!DisableBasicAA)
00520     AAR.addAAResult(BAR);
00521 
00522   // Populate the results with the other currently available AAs.
00523   if (auto *WrapperPass =
00524           P.getAnalysisIfAvailable<ScopedNoAliasAAWrapperPass>())
00525     AAR.addAAResult(WrapperPass->getResult());
00526   if (auto *WrapperPass = P.getAnalysisIfAvailable<TypeBasedAAWrapperPass>())
00527     AAR.addAAResult(WrapperPass->getResult());
00528   if (auto *WrapperPass =
00529           P.getAnalysisIfAvailable<objcarc::ObjCARCAAWrapperPass>())
00530     AAR.addAAResult(WrapperPass->getResult());
00531   if (auto *WrapperPass = P.getAnalysisIfAvailable<GlobalsAAWrapperPass>())
00532     AAR.addAAResult(WrapperPass->getResult());
00533   if (auto *WrapperPass = P.getAnalysisIfAvailable<SCEVAAWrapperPass>())
00534     AAR.addAAResult(WrapperPass->getResult());
00535   if (auto *WrapperPass = P.getAnalysisIfAvailable<CFLAAWrapperPass>())
00536     AAR.addAAResult(WrapperPass->getResult());
00537 
00538   return AAR;
00539 }
00540 
00541 bool llvm::isNoAliasCall(const Value *V) {
00542   if (auto CS = ImmutableCallSite(V))
00543     return CS.paramHasAttr(0, Attribute::NoAlias);
00544   return false;
00545 }
00546 
00547 bool llvm::isNoAliasArgument(const Value *V) {
00548   if (const Argument *A = dyn_cast<Argument>(V))
00549     return A->hasNoAliasAttr();
00550   return false;
00551 }
00552 
00553 bool llvm::isIdentifiedObject(const Value *V) {
00554   if (isa<AllocaInst>(V))
00555     return true;
00556   if (isa<GlobalValue>(V) && !isa<GlobalAlias>(V))
00557     return true;
00558   if (isNoAliasCall(V))
00559     return true;
00560   if (const Argument *A = dyn_cast<Argument>(V))
00561     return A->hasNoAliasAttr() || A->hasByValAttr();
00562   return false;
00563 }
00564 
00565 bool llvm::isIdentifiedFunctionLocal(const Value *V) {
00566   return isa<AllocaInst>(V) || isNoAliasCall(V) || isNoAliasArgument(V);
00567 }