LLVM API Documentation

AliasAnalysis.h
Go to the documentation of this file.
00001 //===- llvm/Analysis/AliasAnalysis.h - Alias Analysis Interface -*- C++ -*-===//
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 defines the generic AliasAnalysis interface, which is used as the
00011 // common interface used by all clients of alias analysis information, and
00012 // implemented by all alias analysis implementations.  Mod/Ref information is
00013 // also captured by this interface.
00014 //
00015 // Implementations of this interface must implement the various virtual methods,
00016 // which automatically provides functionality for the entire suite of client
00017 // APIs.
00018 //
00019 // This API identifies memory regions with the Location class. The pointer
00020 // component specifies the base memory address of the region. The Size specifies
00021 // the maximum size (in address units) of the memory region, or UnknownSize if
00022 // the size is not known. The TBAA tag identifies the "type" of the memory
00023 // reference; see the TypeBasedAliasAnalysis class for details.
00024 //
00025 // Some non-obvious details include:
00026 //  - Pointers that point to two completely different objects in memory never
00027 //    alias, regardless of the value of the Size component.
00028 //  - NoAlias doesn't imply inequal pointers. The most obvious example of this
00029 //    is two pointers to constant memory. Even if they are equal, constant
00030 //    memory is never stored to, so there will never be any dependencies.
00031 //    In this and other situations, the pointers may be both NoAlias and
00032 //    MustAlias at the same time. The current API can only return one result,
00033 //    though this is rarely a problem in practice.
00034 //
00035 //===----------------------------------------------------------------------===//
00036 
00037 #ifndef LLVM_ANALYSIS_ALIASANALYSIS_H
00038 #define LLVM_ANALYSIS_ALIASANALYSIS_H
00039 
00040 #include "llvm/ADT/DenseMap.h"
00041 #include "llvm/IR/CallSite.h"
00042 #include "llvm/IR/Metadata.h"
00043 
00044 namespace llvm {
00045 
00046 class LoadInst;
00047 class StoreInst;
00048 class VAArgInst;
00049 class DataLayout;
00050 class TargetLibraryInfo;
00051 class Pass;
00052 class AnalysisUsage;
00053 class MemTransferInst;
00054 class MemIntrinsic;
00055 class DominatorTree;
00056 
00057 class AliasAnalysis {
00058 protected:
00059   const DataLayout *DL;
00060   const TargetLibraryInfo *TLI;
00061 
00062 private:
00063   AliasAnalysis *AA;       // Previous Alias Analysis to chain to.
00064 
00065 protected:
00066   /// InitializeAliasAnalysis - Subclasses must call this method to initialize
00067   /// the AliasAnalysis interface before any other methods are called.  This is
00068   /// typically called by the run* methods of these subclasses.  This may be
00069   /// called multiple times.
00070   ///
00071   void InitializeAliasAnalysis(Pass *P);
00072 
00073   /// getAnalysisUsage - All alias analysis implementations should invoke this
00074   /// directly (using AliasAnalysis::getAnalysisUsage(AU)).
00075   virtual void getAnalysisUsage(AnalysisUsage &AU) const;
00076 
00077 public:
00078   static char ID; // Class identification, replacement for typeinfo
00079   AliasAnalysis() : DL(nullptr), TLI(nullptr), AA(nullptr) {}
00080   virtual ~AliasAnalysis();  // We want to be subclassed
00081 
00082   /// UnknownSize - This is a special value which can be used with the
00083   /// size arguments in alias queries to indicate that the caller does not
00084   /// know the sizes of the potential memory references.
00085   static uint64_t const UnknownSize = ~UINT64_C(0);
00086 
00087   /// getDataLayout - Return a pointer to the current DataLayout object, or
00088   /// null if no DataLayout object is available.
00089   ///
00090   const DataLayout *getDataLayout() const { return DL; }
00091 
00092   /// getTargetLibraryInfo - Return a pointer to the current TargetLibraryInfo
00093   /// object, or null if no TargetLibraryInfo object is available.
00094   ///
00095   const TargetLibraryInfo *getTargetLibraryInfo() const { return TLI; }
00096 
00097   /// getTypeStoreSize - Return the DataLayout store size for the given type,
00098   /// if known, or a conservative value otherwise.
00099   ///
00100   uint64_t getTypeStoreSize(Type *Ty);
00101 
00102   //===--------------------------------------------------------------------===//
00103   /// Alias Queries...
00104   ///
00105 
00106   /// Location - A description of a memory location.
00107   struct Location {
00108     /// Ptr - The address of the start of the location.
00109     const Value *Ptr;
00110     /// Size - The maximum size of the location, in address-units, or
00111     /// UnknownSize if the size is not known.  Note that an unknown size does
00112     /// not mean the pointer aliases the entire virtual address space, because
00113     /// there are restrictions on stepping out of one object and into another.
00114     /// See http://llvm.org/docs/LangRef.html#pointeraliasing
00115     uint64_t Size;
00116     /// AATags - The metadata nodes which describes the aliasing of the
00117     /// location (each member is null if that kind of information is
00118     /// unavailable)..
00119     AAMDNodes AATags;
00120 
00121     explicit Location(const Value *P = nullptr, uint64_t S = UnknownSize,
00122                       const AAMDNodes &N = AAMDNodes())
00123       : Ptr(P), Size(S), AATags(N) {}
00124 
00125     Location getWithNewPtr(const Value *NewPtr) const {
00126       Location Copy(*this);
00127       Copy.Ptr = NewPtr;
00128       return Copy;
00129     }
00130 
00131     Location getWithNewSize(uint64_t NewSize) const {
00132       Location Copy(*this);
00133       Copy.Size = NewSize;
00134       return Copy;
00135     }
00136 
00137     Location getWithoutAATags() const {
00138       Location Copy(*this);
00139       Copy.AATags = AAMDNodes();
00140       return Copy;
00141     }
00142   };
00143 
00144   /// getLocation - Fill in Loc with information about the memory reference by
00145   /// the given instruction.
00146   Location getLocation(const LoadInst *LI);
00147   Location getLocation(const StoreInst *SI);
00148   Location getLocation(const VAArgInst *VI);
00149   Location getLocation(const AtomicCmpXchgInst *CXI);
00150   Location getLocation(const AtomicRMWInst *RMWI);
00151   static Location getLocationForSource(const MemTransferInst *MTI);
00152   static Location getLocationForDest(const MemIntrinsic *MI);
00153 
00154   /// Alias analysis result - Either we know for sure that it does not alias, we
00155   /// know for sure it must alias, or we don't know anything: The two pointers
00156   /// _might_ alias.  This enum is designed so you can do things like:
00157   ///     if (AA.alias(P1, P2)) { ... }
00158   /// to check to see if two pointers might alias.
00159   ///
00160   /// See docs/AliasAnalysis.html for more information on the specific meanings
00161   /// of these values.
00162   ///
00163   enum AliasResult {
00164     NoAlias = 0,        ///< No dependencies.
00165     MayAlias,           ///< Anything goes.
00166     PartialAlias,       ///< Pointers differ, but pointees overlap.
00167     MustAlias           ///< Pointers are equal.
00168   };
00169 
00170   /// alias - The main low level interface to the alias analysis implementation.
00171   /// Returns an AliasResult indicating whether the two pointers are aliased to
00172   /// each other.  This is the interface that must be implemented by specific
00173   /// alias analysis implementations.
00174   virtual AliasResult alias(const Location &LocA, const Location &LocB);
00175 
00176   /// alias - A convenience wrapper.
00177   AliasResult alias(const Value *V1, uint64_t V1Size,
00178                     const Value *V2, uint64_t V2Size) {
00179     return alias(Location(V1, V1Size), Location(V2, V2Size));
00180   }
00181 
00182   /// alias - A convenience wrapper.
00183   AliasResult alias(const Value *V1, const Value *V2) {
00184     return alias(V1, UnknownSize, V2, UnknownSize);
00185   }
00186 
00187   /// isNoAlias - A trivial helper function to check to see if the specified
00188   /// pointers are no-alias.
00189   bool isNoAlias(const Location &LocA, const Location &LocB) {
00190     return alias(LocA, LocB) == NoAlias;
00191   }
00192 
00193   /// isNoAlias - A convenience wrapper.
00194   bool isNoAlias(const Value *V1, uint64_t V1Size,
00195                  const Value *V2, uint64_t V2Size) {
00196     return isNoAlias(Location(V1, V1Size), Location(V2, V2Size));
00197   }
00198   
00199   /// isNoAlias - A convenience wrapper.
00200   bool isNoAlias(const Value *V1, const Value *V2) {
00201     return isNoAlias(Location(V1), Location(V2));
00202   }
00203   
00204   /// isMustAlias - A convenience wrapper.
00205   bool isMustAlias(const Location &LocA, const Location &LocB) {
00206     return alias(LocA, LocB) == MustAlias;
00207   }
00208 
00209   /// isMustAlias - A convenience wrapper.
00210   bool isMustAlias(const Value *V1, const Value *V2) {
00211     return alias(V1, 1, V2, 1) == MustAlias;
00212   }
00213   
00214   /// pointsToConstantMemory - If the specified memory location is
00215   /// known to be constant, return true. If OrLocal is true and the
00216   /// specified memory location is known to be "local" (derived from
00217   /// an alloca), return true. Otherwise return false.
00218   virtual bool pointsToConstantMemory(const Location &Loc,
00219                                       bool OrLocal = false);
00220 
00221   /// pointsToConstantMemory - A convenient wrapper.
00222   bool pointsToConstantMemory(const Value *P, bool OrLocal = false) {
00223     return pointsToConstantMemory(Location(P), OrLocal);
00224   }
00225 
00226   //===--------------------------------------------------------------------===//
00227   /// Simple mod/ref information...
00228   ///
00229 
00230   /// ModRefResult - Represent the result of a mod/ref query.  Mod and Ref are
00231   /// bits which may be or'd together.
00232   ///
00233   enum ModRefResult { NoModRef = 0, Ref = 1, Mod = 2, ModRef = 3 };
00234 
00235   /// These values define additional bits used to define the
00236   /// ModRefBehavior values.
00237   enum { Nowhere = 0, ArgumentPointees = 4, Anywhere = 8 | ArgumentPointees };
00238 
00239   /// ModRefBehavior - Summary of how a function affects memory in the program.
00240   /// Loads from constant globals are not considered memory accesses for this
00241   /// interface.  Also, functions may freely modify stack space local to their
00242   /// invocation without having to report it through these interfaces.
00243   enum ModRefBehavior {
00244     /// DoesNotAccessMemory - This function does not perform any non-local loads
00245     /// or stores to memory.
00246     ///
00247     /// This property corresponds to the GCC 'const' attribute.
00248     /// This property corresponds to the LLVM IR 'readnone' attribute.
00249     /// This property corresponds to the IntrNoMem LLVM intrinsic flag.
00250     DoesNotAccessMemory = Nowhere | NoModRef,
00251 
00252     /// OnlyReadsArgumentPointees - The only memory references in this function
00253     /// (if it has any) are non-volatile loads from objects pointed to by its
00254     /// pointer-typed arguments, with arbitrary offsets.
00255     ///
00256     /// This property corresponds to the IntrReadArgMem LLVM intrinsic flag.
00257     OnlyReadsArgumentPointees = ArgumentPointees | Ref,
00258 
00259     /// OnlyAccessesArgumentPointees - The only memory references in this
00260     /// function (if it has any) are non-volatile loads and stores from objects
00261     /// pointed to by its pointer-typed arguments, with arbitrary offsets.
00262     ///
00263     /// This property corresponds to the IntrReadWriteArgMem LLVM intrinsic flag.
00264     OnlyAccessesArgumentPointees = ArgumentPointees | ModRef,
00265 
00266     /// OnlyReadsMemory - This function does not perform any non-local stores or
00267     /// volatile loads, but may read from any memory location.
00268     ///
00269     /// This property corresponds to the GCC 'pure' attribute.
00270     /// This property corresponds to the LLVM IR 'readonly' attribute.
00271     /// This property corresponds to the IntrReadMem LLVM intrinsic flag.
00272     OnlyReadsMemory = Anywhere | Ref,
00273 
00274     /// UnknownModRefBehavior - This indicates that the function could not be
00275     /// classified into one of the behaviors above.
00276     UnknownModRefBehavior = Anywhere | ModRef
00277   };
00278 
00279   /// Get the location associated with a pointer argument of a callsite.
00280   /// The mask bits are set to indicate the allowed aliasing ModRef kinds.
00281   /// Note that these mask bits do not necessarily account for the overall
00282   /// behavior of the function, but rather only provide additional
00283   /// per-argument information.
00284   virtual Location getArgLocation(ImmutableCallSite CS, unsigned ArgIdx,
00285                                   ModRefResult &Mask);
00286 
00287   /// getModRefBehavior - Return the behavior when calling the given call site.
00288   virtual ModRefBehavior getModRefBehavior(ImmutableCallSite CS);
00289 
00290   /// getModRefBehavior - Return the behavior when calling the given function.
00291   /// For use when the call site is not known.
00292   virtual ModRefBehavior getModRefBehavior(const Function *F);
00293 
00294   /// doesNotAccessMemory - If the specified call is known to never read or
00295   /// write memory, return true.  If the call only reads from known-constant
00296   /// memory, it is also legal to return true.  Calls that unwind the stack
00297   /// are legal for this predicate.
00298   ///
00299   /// Many optimizations (such as CSE and LICM) can be performed on such calls
00300   /// without worrying about aliasing properties, and many calls have this
00301   /// property (e.g. calls to 'sin' and 'cos').
00302   ///
00303   /// This property corresponds to the GCC 'const' attribute.
00304   ///
00305   bool doesNotAccessMemory(ImmutableCallSite CS) {
00306     return getModRefBehavior(CS) == DoesNotAccessMemory;
00307   }
00308 
00309   /// doesNotAccessMemory - If the specified function is known to never read or
00310   /// write memory, return true.  For use when the call site is not known.
00311   ///
00312   bool doesNotAccessMemory(const Function *F) {
00313     return getModRefBehavior(F) == DoesNotAccessMemory;
00314   }
00315 
00316   /// onlyReadsMemory - If the specified call is known to only read from
00317   /// non-volatile memory (or not access memory at all), return true.  Calls
00318   /// that unwind the stack are legal for this predicate.
00319   ///
00320   /// This property allows many common optimizations to be performed in the
00321   /// absence of interfering store instructions, such as CSE of strlen calls.
00322   ///
00323   /// This property corresponds to the GCC 'pure' attribute.
00324   ///
00325   bool onlyReadsMemory(ImmutableCallSite CS) {
00326     return onlyReadsMemory(getModRefBehavior(CS));
00327   }
00328 
00329   /// onlyReadsMemory - If the specified function is known to only read from
00330   /// non-volatile memory (or not access memory at all), return true.  For use
00331   /// when the call site is not known.
00332   ///
00333   bool onlyReadsMemory(const Function *F) {
00334     return onlyReadsMemory(getModRefBehavior(F));
00335   }
00336 
00337   /// onlyReadsMemory - Return true if functions with the specified behavior are
00338   /// known to only read from non-volatile memory (or not access memory at all).
00339   ///
00340   static bool onlyReadsMemory(ModRefBehavior MRB) {
00341     return !(MRB & Mod);
00342   }
00343 
00344   /// onlyAccessesArgPointees - Return true if functions with the specified
00345   /// behavior are known to read and write at most from objects pointed to by
00346   /// their pointer-typed arguments (with arbitrary offsets).
00347   ///
00348   static bool onlyAccessesArgPointees(ModRefBehavior MRB) {
00349     return !(MRB & Anywhere & ~ArgumentPointees);
00350   }
00351 
00352   /// doesAccessArgPointees - Return true if functions with the specified
00353   /// behavior are known to potentially read or write from objects pointed
00354   /// to be their pointer-typed arguments (with arbitrary offsets).
00355   ///
00356   static bool doesAccessArgPointees(ModRefBehavior MRB) {
00357     return (MRB & ModRef) && (MRB & ArgumentPointees);
00358   }
00359 
00360   /// getModRefInfo - Return information about whether or not an instruction may
00361   /// read or write the specified memory location.  An instruction
00362   /// that doesn't read or write memory may be trivially LICM'd for example.
00363   ModRefResult getModRefInfo(const Instruction *I,
00364                              const Location &Loc) {
00365     switch (I->getOpcode()) {
00366     case Instruction::VAArg:  return getModRefInfo((const VAArgInst*)I, Loc);
00367     case Instruction::Load:   return getModRefInfo((const LoadInst*)I,  Loc);
00368     case Instruction::Store:  return getModRefInfo((const StoreInst*)I, Loc);
00369     case Instruction::Fence:  return getModRefInfo((const FenceInst*)I, Loc);
00370     case Instruction::AtomicCmpXchg:
00371       return getModRefInfo((const AtomicCmpXchgInst*)I, Loc);
00372     case Instruction::AtomicRMW:
00373       return getModRefInfo((const AtomicRMWInst*)I, Loc);
00374     case Instruction::Call:   return getModRefInfo((const CallInst*)I,  Loc);
00375     case Instruction::Invoke: return getModRefInfo((const InvokeInst*)I,Loc);
00376     default:                  return NoModRef;
00377     }
00378   }
00379 
00380   /// getModRefInfo - A convenience wrapper.
00381   ModRefResult getModRefInfo(const Instruction *I,
00382                              const Value *P, uint64_t Size) {
00383     return getModRefInfo(I, Location(P, Size));
00384   }
00385 
00386   /// getModRefInfo (for call sites) - Return information about whether
00387   /// a particular call site modifies or reads the specified memory location.
00388   virtual ModRefResult getModRefInfo(ImmutableCallSite CS,
00389                                      const Location &Loc);
00390 
00391   /// getModRefInfo (for call sites) - A convenience wrapper.
00392   ModRefResult getModRefInfo(ImmutableCallSite CS,
00393                              const Value *P, uint64_t Size) {
00394     return getModRefInfo(CS, Location(P, Size));
00395   }
00396 
00397   /// getModRefInfo (for calls) - Return information about whether
00398   /// a particular call modifies or reads the specified memory location.
00399   ModRefResult getModRefInfo(const CallInst *C, const Location &Loc) {
00400     return getModRefInfo(ImmutableCallSite(C), Loc);
00401   }
00402 
00403   /// getModRefInfo (for calls) - A convenience wrapper.
00404   ModRefResult getModRefInfo(const CallInst *C, const Value *P, uint64_t Size) {
00405     return getModRefInfo(C, Location(P, Size));
00406   }
00407 
00408   /// getModRefInfo (for invokes) - Return information about whether
00409   /// a particular invoke modifies or reads the specified memory location.
00410   ModRefResult getModRefInfo(const InvokeInst *I,
00411                              const Location &Loc) {
00412     return getModRefInfo(ImmutableCallSite(I), Loc);
00413   }
00414 
00415   /// getModRefInfo (for invokes) - A convenience wrapper.
00416   ModRefResult getModRefInfo(const InvokeInst *I,
00417                              const Value *P, uint64_t Size) {
00418     return getModRefInfo(I, Location(P, Size));
00419   }
00420 
00421   /// getModRefInfo (for loads) - Return information about whether
00422   /// a particular load modifies or reads the specified memory location.
00423   ModRefResult getModRefInfo(const LoadInst *L, const Location &Loc);
00424 
00425   /// getModRefInfo (for loads) - A convenience wrapper.
00426   ModRefResult getModRefInfo(const LoadInst *L, const Value *P, uint64_t Size) {
00427     return getModRefInfo(L, Location(P, Size));
00428   }
00429 
00430   /// getModRefInfo (for stores) - Return information about whether
00431   /// a particular store modifies or reads the specified memory location.
00432   ModRefResult getModRefInfo(const StoreInst *S, const Location &Loc);
00433 
00434   /// getModRefInfo (for stores) - A convenience wrapper.
00435   ModRefResult getModRefInfo(const StoreInst *S, const Value *P, uint64_t Size){
00436     return getModRefInfo(S, Location(P, Size));
00437   }
00438 
00439   /// getModRefInfo (for fences) - Return information about whether
00440   /// a particular store modifies or reads the specified memory location.
00441   ModRefResult getModRefInfo(const FenceInst *S, const Location &Loc) {
00442     // Conservatively correct.  (We could possibly be a bit smarter if
00443     // Loc is a alloca that doesn't escape.)
00444     return ModRef;
00445   }
00446 
00447   /// getModRefInfo (for fences) - A convenience wrapper.
00448   ModRefResult getModRefInfo(const FenceInst *S, const Value *P, uint64_t Size){
00449     return getModRefInfo(S, Location(P, Size));
00450   }
00451 
00452   /// getModRefInfo (for cmpxchges) - Return information about whether
00453   /// a particular cmpxchg modifies or reads the specified memory location.
00454   ModRefResult getModRefInfo(const AtomicCmpXchgInst *CX, const Location &Loc);
00455 
00456   /// getModRefInfo (for cmpxchges) - A convenience wrapper.
00457   ModRefResult getModRefInfo(const AtomicCmpXchgInst *CX,
00458                              const Value *P, unsigned Size) {
00459     return getModRefInfo(CX, Location(P, Size));
00460   }
00461 
00462   /// getModRefInfo (for atomicrmws) - Return information about whether
00463   /// a particular atomicrmw modifies or reads the specified memory location.
00464   ModRefResult getModRefInfo(const AtomicRMWInst *RMW, const Location &Loc);
00465 
00466   /// getModRefInfo (for atomicrmws) - A convenience wrapper.
00467   ModRefResult getModRefInfo(const AtomicRMWInst *RMW,
00468                              const Value *P, unsigned Size) {
00469     return getModRefInfo(RMW, Location(P, Size));
00470   }
00471 
00472   /// getModRefInfo (for va_args) - Return information about whether
00473   /// a particular va_arg modifies or reads the specified memory location.
00474   ModRefResult getModRefInfo(const VAArgInst* I, const Location &Loc);
00475 
00476   /// getModRefInfo (for va_args) - A convenience wrapper.
00477   ModRefResult getModRefInfo(const VAArgInst* I, const Value* P, uint64_t Size){
00478     return getModRefInfo(I, Location(P, Size));
00479   }
00480 
00481   /// getModRefInfo - Return information about whether two call sites may refer
00482   /// to the same set of memory locations.  See 
00483   ///   http://llvm.org/docs/AliasAnalysis.html#ModRefInfo
00484   /// for details.
00485   virtual ModRefResult getModRefInfo(ImmutableCallSite CS1,
00486                                      ImmutableCallSite CS2);
00487 
00488   /// callCapturesBefore - Return information about whether a particular call 
00489   /// site modifies or reads the specified memory location.
00490   ModRefResult callCapturesBefore(const Instruction *I,
00491                                   const AliasAnalysis::Location &MemLoc,
00492                                   DominatorTree *DT);
00493 
00494   /// callCapturesBefore - A convenience wrapper.
00495   ModRefResult callCapturesBefore(const Instruction *I, const Value *P,
00496                                   uint64_t Size, DominatorTree *DT) {
00497     return callCapturesBefore(I, Location(P, Size), DT);
00498   }
00499 
00500   //===--------------------------------------------------------------------===//
00501   /// Higher level methods for querying mod/ref information.
00502   ///
00503 
00504   /// canBasicBlockModify - Return true if it is possible for execution of the
00505   /// specified basic block to modify the value pointed to by Ptr.
00506   bool canBasicBlockModify(const BasicBlock &BB, const Location &Loc);
00507 
00508   /// canBasicBlockModify - A convenience wrapper.
00509   bool canBasicBlockModify(const BasicBlock &BB, const Value *P, uint64_t Size){
00510     return canBasicBlockModify(BB, Location(P, Size));
00511   }
00512 
00513   /// canInstructionRangeModify - Return true if it is possible for the
00514   /// execution of the specified instructions to modify the value pointed to by
00515   /// Ptr.  The instructions to consider are all of the instructions in the
00516   /// range of [I1,I2] INCLUSIVE.  I1 and I2 must be in the same basic block.
00517   bool canInstructionRangeModify(const Instruction &I1, const Instruction &I2,
00518                                  const Location &Loc);
00519 
00520   /// canInstructionRangeModify - A convenience wrapper.
00521   bool canInstructionRangeModify(const Instruction &I1, const Instruction &I2,
00522                                  const Value *Ptr, uint64_t Size) {
00523     return canInstructionRangeModify(I1, I2, Location(Ptr, Size));
00524   }
00525 
00526   //===--------------------------------------------------------------------===//
00527   /// Methods that clients should call when they transform the program to allow
00528   /// alias analyses to update their internal data structures.  Note that these
00529   /// methods may be called on any instruction, regardless of whether or not
00530   /// they have pointer-analysis implications.
00531   ///
00532 
00533   /// deleteValue - This method should be called whenever an LLVM Value is
00534   /// deleted from the program, for example when an instruction is found to be
00535   /// redundant and is eliminated.
00536   ///
00537   virtual void deleteValue(Value *V);
00538 
00539   /// copyValue - This method should be used whenever a preexisting value in the
00540   /// program is copied or cloned, introducing a new value.  Note that analysis
00541   /// implementations should tolerate clients that use this method to introduce
00542   /// the same value multiple times: if the analysis already knows about a
00543   /// value, it should ignore the request.
00544   ///
00545   virtual void copyValue(Value *From, Value *To);
00546 
00547   /// addEscapingUse - This method should be used whenever an escaping use is
00548   /// added to a pointer value.  Analysis implementations may either return
00549   /// conservative responses for that value in the future, or may recompute
00550   /// some or all internal state to continue providing precise responses.
00551   ///
00552   /// Escaping uses are considered by anything _except_ the following:
00553   ///  - GEPs or bitcasts of the pointer
00554   ///  - Loads through the pointer
00555   ///  - Stores through (but not of) the pointer
00556   virtual void addEscapingUse(Use &U);
00557 
00558   /// replaceWithNewValue - This method is the obvious combination of the two
00559   /// above, and it provided as a helper to simplify client code.
00560   ///
00561   void replaceWithNewValue(Value *Old, Value *New) {
00562     copyValue(Old, New);
00563     deleteValue(Old);
00564   }
00565 };
00566 
00567 // Specialize DenseMapInfo for Location.
00568 template<>
00569 struct DenseMapInfo<AliasAnalysis::Location> {
00570   static inline AliasAnalysis::Location getEmptyKey() {
00571     return
00572       AliasAnalysis::Location(DenseMapInfo<const Value *>::getEmptyKey(),
00573                               0, nullptr);
00574   }
00575   static inline AliasAnalysis::Location getTombstoneKey() {
00576     return
00577       AliasAnalysis::Location(DenseMapInfo<const Value *>::getTombstoneKey(),
00578                               0, nullptr);
00579   }
00580   static unsigned getHashValue(const AliasAnalysis::Location &Val) {
00581     return DenseMapInfo<const Value *>::getHashValue(Val.Ptr) ^
00582            DenseMapInfo<uint64_t>::getHashValue(Val.Size) ^
00583            DenseMapInfo<AAMDNodes>::getHashValue(Val.AATags);
00584   }
00585   static bool isEqual(const AliasAnalysis::Location &LHS,
00586                       const AliasAnalysis::Location &RHS) {
00587     return LHS.Ptr == RHS.Ptr &&
00588            LHS.Size == RHS.Size &&
00589            LHS.AATags == RHS.AATags;
00590   }
00591 };
00592 
00593 /// isNoAliasCall - Return true if this pointer is returned by a noalias
00594 /// function.
00595 bool isNoAliasCall(const Value *V);
00596 
00597 /// isNoAliasArgument - Return true if this is an argument with the noalias
00598 /// attribute.
00599 bool isNoAliasArgument(const Value *V);
00600 
00601 /// isIdentifiedObject - Return true if this pointer refers to a distinct and
00602 /// identifiable object.  This returns true for:
00603 ///    Global Variables and Functions (but not Global Aliases)
00604 ///    Allocas
00605 ///    ByVal and NoAlias Arguments
00606 ///    NoAlias returns (e.g. calls to malloc)
00607 ///
00608 bool isIdentifiedObject(const Value *V);
00609 
00610 /// isIdentifiedFunctionLocal - Return true if V is umabigously identified
00611 /// at the function-level. Different IdentifiedFunctionLocals can't alias.
00612 /// Further, an IdentifiedFunctionLocal can not alias with any function
00613 /// arguments other than itself, which is not necessarily true for
00614 /// IdentifiedObjects.
00615 bool isIdentifiedFunctionLocal(const Value *V);
00616 
00617 } // End llvm namespace
00618 
00619 #endif