Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

598 lines
24 KiB

  1. //===- llvm/Analysis/AliasAnalysis.h - Alias Analysis Interface -*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file defines the generic AliasAnalysis interface, which is used as the
  11. // common interface used by all clients of alias analysis information, and
  12. // implemented by all alias analysis implementations. Mod/Ref information is
  13. // also captured by this interface.
  14. //
  15. // Implementations of this interface must implement the various virtual methods,
  16. // which automatically provides functionality for the entire suite of client
  17. // APIs.
  18. //
  19. // This API identifies memory regions with the Location class. The pointer
  20. // component specifies the base memory address of the region. The Size specifies
  21. // the maximum size (in address units) of the memory region, or UnknownSize if
  22. // the size is not known. The TBAA tag identifies the "type" of the memory
  23. // reference; see the TypeBasedAliasAnalysis class for details.
  24. //
  25. // Some non-obvious details include:
  26. // - Pointers that point to two completely different objects in memory never
  27. // alias, regardless of the value of the Size component.
  28. // - NoAlias doesn't imply inequal pointers. The most obvious example of this
  29. // is two pointers to constant memory. Even if they are equal, constant
  30. // memory is never stored to, so there will never be any dependencies.
  31. // In this and other situations, the pointers may be both NoAlias and
  32. // MustAlias at the same time. The current API can only return one result,
  33. // though this is rarely a problem in practice.
  34. //
  35. //===----------------------------------------------------------------------===//
  36. #ifndef LLVM_ANALYSIS_ALIASANALYSIS_H
  37. #define LLVM_ANALYSIS_ALIASANALYSIS_H
  38. #include "llvm/ADT/DenseMap.h"
  39. #include "llvm/Support/CallSite.h"
  40. namespace llvm {
  41. class LoadInst;
  42. class StoreInst;
  43. class VAArgInst;
  44. class DataLayout;
  45. class TargetLibraryInfo;
  46. class Pass;
  47. class AnalysisUsage;
  48. class MemTransferInst;
  49. class MemIntrinsic;
  50. class DominatorTree;
  51. class AliasAnalysis {
  52. protected:
  53. const DataLayout *TD;
  54. const TargetLibraryInfo *TLI;
  55. private:
  56. AliasAnalysis *AA; // Previous Alias Analysis to chain to.
  57. protected:
  58. /// InitializeAliasAnalysis - Subclasses must call this method to initialize
  59. /// the AliasAnalysis interface before any other methods are called. This is
  60. /// typically called by the run* methods of these subclasses. This may be
  61. /// called multiple times.
  62. ///
  63. void InitializeAliasAnalysis(Pass *P);
  64. /// getAnalysisUsage - All alias analysis implementations should invoke this
  65. /// directly (using AliasAnalysis::getAnalysisUsage(AU)).
  66. virtual void getAnalysisUsage(AnalysisUsage &AU) const;
  67. public:
  68. static char ID; // Class identification, replacement for typeinfo
  69. AliasAnalysis() : TD(0), TLI(0), AA(0) {}
  70. virtual ~AliasAnalysis(); // We want to be subclassed
  71. /// UnknownSize - This is a special value which can be used with the
  72. /// size arguments in alias queries to indicate that the caller does not
  73. /// know the sizes of the potential memory references.
  74. static uint64_t const UnknownSize = ~UINT64_C(0);
  75. /// getDataLayout - Return a pointer to the current DataLayout object, or
  76. /// null if no DataLayout object is available.
  77. ///
  78. const DataLayout *getDataLayout() const { return TD; }
  79. /// getTargetLibraryInfo - Return a pointer to the current TargetLibraryInfo
  80. /// object, or null if no TargetLibraryInfo object is available.
  81. ///
  82. const TargetLibraryInfo *getTargetLibraryInfo() const { return TLI; }
  83. /// getTypeStoreSize - Return the DataLayout store size for the given type,
  84. /// if known, or a conservative value otherwise.
  85. ///
  86. uint64_t getTypeStoreSize(Type *Ty);
  87. //===--------------------------------------------------------------------===//
  88. /// Alias Queries...
  89. ///
  90. /// Location - A description of a memory location.
  91. struct Location {
  92. /// Ptr - The address of the start of the location.
  93. const Value *Ptr;
  94. /// Size - The maximum size of the location, in address-units, or
  95. /// UnknownSize if the size is not known. Note that an unknown size does
  96. /// not mean the pointer aliases the entire virtual address space, because
  97. /// there are restrictions on stepping out of one object and into another.
  98. /// See http://llvm.org/docs/LangRef.html#pointeraliasing
  99. uint64_t Size;
  100. /// TBAATag - The metadata node which describes the TBAA type of
  101. /// the location, or null if there is no known unique tag.
  102. const MDNode *TBAATag;
  103. explicit Location(const Value *P = 0, uint64_t S = UnknownSize,
  104. const MDNode *N = 0)
  105. : Ptr(P), Size(S), TBAATag(N) {}
  106. Location getWithNewPtr(const Value *NewPtr) const {
  107. Location Copy(*this);
  108. Copy.Ptr = NewPtr;
  109. return Copy;
  110. }
  111. Location getWithNewSize(uint64_t NewSize) const {
  112. Location Copy(*this);
  113. Copy.Size = NewSize;
  114. return Copy;
  115. }
  116. Location getWithoutTBAATag() const {
  117. Location Copy(*this);
  118. Copy.TBAATag = 0;
  119. return Copy;
  120. }
  121. };
  122. /// getLocation - Fill in Loc with information about the memory reference by
  123. /// the given instruction.
  124. Location getLocation(const LoadInst *LI);
  125. Location getLocation(const StoreInst *SI);
  126. Location getLocation(const VAArgInst *VI);
  127. Location getLocation(const AtomicCmpXchgInst *CXI);
  128. Location getLocation(const AtomicRMWInst *RMWI);
  129. static Location getLocationForSource(const MemTransferInst *MTI);
  130. static Location getLocationForDest(const MemIntrinsic *MI);
  131. /// Alias analysis result - Either we know for sure that it does not alias, we
  132. /// know for sure it must alias, or we don't know anything: The two pointers
  133. /// _might_ alias. This enum is designed so you can do things like:
  134. /// if (AA.alias(P1, P2)) { ... }
  135. /// to check to see if two pointers might alias.
  136. ///
  137. /// See docs/AliasAnalysis.html for more information on the specific meanings
  138. /// of these values.
  139. ///
  140. enum AliasResult {
  141. NoAlias = 0, ///< No dependencies.
  142. MayAlias, ///< Anything goes.
  143. PartialAlias, ///< Pointers differ, but pointees overlap.
  144. MustAlias ///< Pointers are equal.
  145. };
  146. /// alias - The main low level interface to the alias analysis implementation.
  147. /// Returns an AliasResult indicating whether the two pointers are aliased to
  148. /// each other. This is the interface that must be implemented by specific
  149. /// alias analysis implementations.
  150. virtual AliasResult alias(const Location &LocA, const Location &LocB);
  151. /// alias - A convenience wrapper.
  152. AliasResult alias(const Value *V1, uint64_t V1Size,
  153. const Value *V2, uint64_t V2Size) {
  154. return alias(Location(V1, V1Size), Location(V2, V2Size));
  155. }
  156. /// alias - A convenience wrapper.
  157. AliasResult alias(const Value *V1, const Value *V2) {
  158. return alias(V1, UnknownSize, V2, UnknownSize);
  159. }
  160. /// isNoAlias - A trivial helper function to check to see if the specified
  161. /// pointers are no-alias.
  162. bool isNoAlias(const Location &LocA, const Location &LocB) {
  163. return alias(LocA, LocB) == NoAlias;
  164. }
  165. /// isNoAlias - A convenience wrapper.
  166. bool isNoAlias(const Value *V1, uint64_t V1Size,
  167. const Value *V2, uint64_t V2Size) {
  168. return isNoAlias(Location(V1, V1Size), Location(V2, V2Size));
  169. }
  170. /// isNoAlias - A convenience wrapper.
  171. bool isNoAlias(const Value *V1, const Value *V2) {
  172. return isNoAlias(Location(V1), Location(V2));
  173. }
  174. /// isMustAlias - A convenience wrapper.
  175. bool isMustAlias(const Location &LocA, const Location &LocB) {
  176. return alias(LocA, LocB) == MustAlias;
  177. }
  178. /// isMustAlias - A convenience wrapper.
  179. bool isMustAlias(const Value *V1, const Value *V2) {
  180. return alias(V1, 1, V2, 1) == MustAlias;
  181. }
  182. /// pointsToConstantMemory - If the specified memory location is
  183. /// known to be constant, return true. If OrLocal is true and the
  184. /// specified memory location is known to be "local" (derived from
  185. /// an alloca), return true. Otherwise return false.
  186. virtual bool pointsToConstantMemory(const Location &Loc,
  187. bool OrLocal = false);
  188. /// pointsToConstantMemory - A convenient wrapper.
  189. bool pointsToConstantMemory(const Value *P, bool OrLocal = false) {
  190. return pointsToConstantMemory(Location(P), OrLocal);
  191. }
  192. //===--------------------------------------------------------------------===//
  193. /// Simple mod/ref information...
  194. ///
  195. /// ModRefResult - Represent the result of a mod/ref query. Mod and Ref are
  196. /// bits which may be or'd together.
  197. ///
  198. enum ModRefResult { NoModRef = 0, Ref = 1, Mod = 2, ModRef = 3 };
  199. /// These values define additional bits used to define the
  200. /// ModRefBehavior values.
  201. enum { Nowhere = 0, ArgumentPointees = 4, Anywhere = 8 | ArgumentPointees };
  202. /// ModRefBehavior - Summary of how a function affects memory in the program.
  203. /// Loads from constant globals are not considered memory accesses for this
  204. /// interface. Also, functions may freely modify stack space local to their
  205. /// invocation without having to report it through these interfaces.
  206. enum ModRefBehavior {
  207. /// DoesNotAccessMemory - This function does not perform any non-local loads
  208. /// or stores to memory.
  209. ///
  210. /// This property corresponds to the GCC 'const' attribute.
  211. /// This property corresponds to the LLVM IR 'readnone' attribute.
  212. /// This property corresponds to the IntrNoMem LLVM intrinsic flag.
  213. DoesNotAccessMemory = Nowhere | NoModRef,
  214. /// OnlyReadsArgumentPointees - The only memory references in this function
  215. /// (if it has any) are non-volatile loads from objects pointed to by its
  216. /// pointer-typed arguments, with arbitrary offsets.
  217. ///
  218. /// This property corresponds to the IntrReadArgMem LLVM intrinsic flag.
  219. OnlyReadsArgumentPointees = ArgumentPointees | Ref,
  220. /// OnlyAccessesArgumentPointees - The only memory references in this
  221. /// function (if it has any) are non-volatile loads and stores from objects
  222. /// pointed to by its pointer-typed arguments, with arbitrary offsets.
  223. ///
  224. /// This property corresponds to the IntrReadWriteArgMem LLVM intrinsic flag.
  225. OnlyAccessesArgumentPointees = ArgumentPointees | ModRef,
  226. /// OnlyReadsMemory - This function does not perform any non-local stores or
  227. /// volatile loads, but may read from any memory location.
  228. ///
  229. /// This property corresponds to the GCC 'pure' attribute.
  230. /// This property corresponds to the LLVM IR 'readonly' attribute.
  231. /// This property corresponds to the IntrReadMem LLVM intrinsic flag.
  232. OnlyReadsMemory = Anywhere | Ref,
  233. /// UnknownModRefBehavior - This indicates that the function could not be
  234. /// classified into one of the behaviors above.
  235. UnknownModRefBehavior = Anywhere | ModRef
  236. };
  237. /// getModRefBehavior - Return the behavior when calling the given call site.
  238. virtual ModRefBehavior getModRefBehavior(ImmutableCallSite CS);
  239. /// getModRefBehavior - Return the behavior when calling the given function.
  240. /// For use when the call site is not known.
  241. virtual ModRefBehavior getModRefBehavior(const Function *F);
  242. /// doesNotAccessMemory - If the specified call is known to never read or
  243. /// write memory, return true. If the call only reads from known-constant
  244. /// memory, it is also legal to return true. Calls that unwind the stack
  245. /// are legal for this predicate.
  246. ///
  247. /// Many optimizations (such as CSE and LICM) can be performed on such calls
  248. /// without worrying about aliasing properties, and many calls have this
  249. /// property (e.g. calls to 'sin' and 'cos').
  250. ///
  251. /// This property corresponds to the GCC 'const' attribute.
  252. ///
  253. bool doesNotAccessMemory(ImmutableCallSite CS) {
  254. return getModRefBehavior(CS) == DoesNotAccessMemory;
  255. }
  256. /// doesNotAccessMemory - If the specified function is known to never read or
  257. /// write memory, return true. For use when the call site is not known.
  258. ///
  259. bool doesNotAccessMemory(const Function *F) {
  260. return getModRefBehavior(F) == DoesNotAccessMemory;
  261. }
  262. /// onlyReadsMemory - If the specified call is known to only read from
  263. /// non-volatile memory (or not access memory at all), return true. Calls
  264. /// that unwind the stack are legal for this predicate.
  265. ///
  266. /// This property allows many common optimizations to be performed in the
  267. /// absence of interfering store instructions, such as CSE of strlen calls.
  268. ///
  269. /// This property corresponds to the GCC 'pure' attribute.
  270. ///
  271. bool onlyReadsMemory(ImmutableCallSite CS) {
  272. return onlyReadsMemory(getModRefBehavior(CS));
  273. }
  274. /// onlyReadsMemory - If the specified function is known to only read from
  275. /// non-volatile memory (or not access memory at all), return true. For use
  276. /// when the call site is not known.
  277. ///
  278. bool onlyReadsMemory(const Function *F) {
  279. return onlyReadsMemory(getModRefBehavior(F));
  280. }
  281. /// onlyReadsMemory - Return true if functions with the specified behavior are
  282. /// known to only read from non-volatile memory (or not access memory at all).
  283. ///
  284. static bool onlyReadsMemory(ModRefBehavior MRB) {
  285. return !(MRB & Mod);
  286. }
  287. /// onlyAccessesArgPointees - Return true if functions with the specified
  288. /// behavior are known to read and write at most from objects pointed to by
  289. /// their pointer-typed arguments (with arbitrary offsets).
  290. ///
  291. static bool onlyAccessesArgPointees(ModRefBehavior MRB) {
  292. return !(MRB & Anywhere & ~ArgumentPointees);
  293. }
  294. /// doesAccessArgPointees - Return true if functions with the specified
  295. /// behavior are known to potentially read or write from objects pointed
  296. /// to be their pointer-typed arguments (with arbitrary offsets).
  297. ///
  298. static bool doesAccessArgPointees(ModRefBehavior MRB) {
  299. return (MRB & ModRef) && (MRB & ArgumentPointees);
  300. }
  301. /// getModRefInfo - Return information about whether or not an instruction may
  302. /// read or write the specified memory location. An instruction
  303. /// that doesn't read or write memory may be trivially LICM'd for example.
  304. ModRefResult getModRefInfo(const Instruction *I,
  305. const Location &Loc) {
  306. switch (I->getOpcode()) {
  307. case Instruction::VAArg: return getModRefInfo((const VAArgInst*)I, Loc);
  308. case Instruction::Load: return getModRefInfo((const LoadInst*)I, Loc);
  309. case Instruction::Store: return getModRefInfo((const StoreInst*)I, Loc);
  310. case Instruction::Fence: return getModRefInfo((const FenceInst*)I, Loc);
  311. case Instruction::AtomicCmpXchg:
  312. return getModRefInfo((const AtomicCmpXchgInst*)I, Loc);
  313. case Instruction::AtomicRMW:
  314. return getModRefInfo((const AtomicRMWInst*)I, Loc);
  315. case Instruction::Call: return getModRefInfo((const CallInst*)I, Loc);
  316. case Instruction::Invoke: return getModRefInfo((const InvokeInst*)I,Loc);
  317. default: return NoModRef;
  318. }
  319. }
  320. /// getModRefInfo - A convenience wrapper.
  321. ModRefResult getModRefInfo(const Instruction *I,
  322. const Value *P, uint64_t Size) {
  323. return getModRefInfo(I, Location(P, Size));
  324. }
  325. /// getModRefInfo (for call sites) - Return information about whether
  326. /// a particular call site modifies or reads the specified memory location.
  327. virtual ModRefResult getModRefInfo(ImmutableCallSite CS,
  328. const Location &Loc);
  329. /// getModRefInfo (for call sites) - A convenience wrapper.
  330. ModRefResult getModRefInfo(ImmutableCallSite CS,
  331. const Value *P, uint64_t Size) {
  332. return getModRefInfo(CS, Location(P, Size));
  333. }
  334. /// getModRefInfo (for calls) - Return information about whether
  335. /// a particular call modifies or reads the specified memory location.
  336. ModRefResult getModRefInfo(const CallInst *C, const Location &Loc) {
  337. return getModRefInfo(ImmutableCallSite(C), Loc);
  338. }
  339. /// getModRefInfo (for calls) - A convenience wrapper.
  340. ModRefResult getModRefInfo(const CallInst *C, const Value *P, uint64_t Size) {
  341. return getModRefInfo(C, Location(P, Size));
  342. }
  343. /// getModRefInfo (for invokes) - Return information about whether
  344. /// a particular invoke modifies or reads the specified memory location.
  345. ModRefResult getModRefInfo(const InvokeInst *I,
  346. const Location &Loc) {
  347. return getModRefInfo(ImmutableCallSite(I), Loc);
  348. }
  349. /// getModRefInfo (for invokes) - A convenience wrapper.
  350. ModRefResult getModRefInfo(const InvokeInst *I,
  351. const Value *P, uint64_t Size) {
  352. return getModRefInfo(I, Location(P, Size));
  353. }
  354. /// getModRefInfo (for loads) - Return information about whether
  355. /// a particular load modifies or reads the specified memory location.
  356. ModRefResult getModRefInfo(const LoadInst *L, const Location &Loc);
  357. /// getModRefInfo (for loads) - A convenience wrapper.
  358. ModRefResult getModRefInfo(const LoadInst *L, const Value *P, uint64_t Size) {
  359. return getModRefInfo(L, Location(P, Size));
  360. }
  361. /// getModRefInfo (for stores) - Return information about whether
  362. /// a particular store modifies or reads the specified memory location.
  363. ModRefResult getModRefInfo(const StoreInst *S, const Location &Loc);
  364. /// getModRefInfo (for stores) - A convenience wrapper.
  365. ModRefResult getModRefInfo(const StoreInst *S, const Value *P, uint64_t Size){
  366. return getModRefInfo(S, Location(P, Size));
  367. }
  368. /// getModRefInfo (for fences) - Return information about whether
  369. /// a particular store modifies or reads the specified memory location.
  370. ModRefResult getModRefInfo(const FenceInst *S, const Location &Loc) {
  371. // Conservatively correct. (We could possibly be a bit smarter if
  372. // Loc is a alloca that doesn't escape.)
  373. return ModRef;
  374. }
  375. /// getModRefInfo (for fences) - A convenience wrapper.
  376. ModRefResult getModRefInfo(const FenceInst *S, const Value *P, uint64_t Size){
  377. return getModRefInfo(S, Location(P, Size));
  378. }
  379. /// getModRefInfo (for cmpxchges) - Return information about whether
  380. /// a particular cmpxchg modifies or reads the specified memory location.
  381. ModRefResult getModRefInfo(const AtomicCmpXchgInst *CX, const Location &Loc);
  382. /// getModRefInfo (for cmpxchges) - A convenience wrapper.
  383. ModRefResult getModRefInfo(const AtomicCmpXchgInst *CX,
  384. const Value *P, unsigned Size) {
  385. return getModRefInfo(CX, Location(P, Size));
  386. }
  387. /// getModRefInfo (for atomicrmws) - Return information about whether
  388. /// a particular atomicrmw modifies or reads the specified memory location.
  389. ModRefResult getModRefInfo(const AtomicRMWInst *RMW, const Location &Loc);
  390. /// getModRefInfo (for atomicrmws) - A convenience wrapper.
  391. ModRefResult getModRefInfo(const AtomicRMWInst *RMW,
  392. const Value *P, unsigned Size) {
  393. return getModRefInfo(RMW, Location(P, Size));
  394. }
  395. /// getModRefInfo (for va_args) - Return information about whether
  396. /// a particular va_arg modifies or reads the specified memory location.
  397. ModRefResult getModRefInfo(const VAArgInst* I, const Location &Loc);
  398. /// getModRefInfo (for va_args) - A convenience wrapper.
  399. ModRefResult getModRefInfo(const VAArgInst* I, const Value* P, uint64_t Size){
  400. return getModRefInfo(I, Location(P, Size));
  401. }
  402. /// getModRefInfo - Return information about whether two call sites may refer
  403. /// to the same set of memory locations. See
  404. /// http://llvm.org/docs/AliasAnalysis.html#ModRefInfo
  405. /// for details.
  406. virtual ModRefResult getModRefInfo(ImmutableCallSite CS1,
  407. ImmutableCallSite CS2);
  408. /// callCapturesBefore - Return information about whether a particular call
  409. /// site modifies or reads the specified memory location.
  410. ModRefResult callCapturesBefore(const Instruction *I,
  411. const AliasAnalysis::Location &MemLoc,
  412. DominatorTree *DT);
  413. /// callCapturesBefore - A convenience wrapper.
  414. ModRefResult callCapturesBefore(const Instruction *I, const Value *P,
  415. uint64_t Size, DominatorTree *DT) {
  416. return callCapturesBefore(I, Location(P, Size), DT);
  417. }
  418. //===--------------------------------------------------------------------===//
  419. /// Higher level methods for querying mod/ref information.
  420. ///
  421. /// canBasicBlockModify - Return true if it is possible for execution of the
  422. /// specified basic block to modify the value pointed to by Ptr.
  423. bool canBasicBlockModify(const BasicBlock &BB, const Location &Loc);
  424. /// canBasicBlockModify - A convenience wrapper.
  425. bool canBasicBlockModify(const BasicBlock &BB, const Value *P, uint64_t Size){
  426. return canBasicBlockModify(BB, Location(P, Size));
  427. }
  428. /// canInstructionRangeModify - Return true if it is possible for the
  429. /// execution of the specified instructions to modify the value pointed to by
  430. /// Ptr. The instructions to consider are all of the instructions in the
  431. /// range of [I1,I2] INCLUSIVE. I1 and I2 must be in the same basic block.
  432. bool canInstructionRangeModify(const Instruction &I1, const Instruction &I2,
  433. const Location &Loc);
  434. /// canInstructionRangeModify - A convenience wrapper.
  435. bool canInstructionRangeModify(const Instruction &I1, const Instruction &I2,
  436. const Value *Ptr, uint64_t Size) {
  437. return canInstructionRangeModify(I1, I2, Location(Ptr, Size));
  438. }
  439. //===--------------------------------------------------------------------===//
  440. /// Methods that clients should call when they transform the program to allow
  441. /// alias analyses to update their internal data structures. Note that these
  442. /// methods may be called on any instruction, regardless of whether or not
  443. /// they have pointer-analysis implications.
  444. ///
  445. /// deleteValue - This method should be called whenever an LLVM Value is
  446. /// deleted from the program, for example when an instruction is found to be
  447. /// redundant and is eliminated.
  448. ///
  449. virtual void deleteValue(Value *V);
  450. /// copyValue - This method should be used whenever a preexisting value in the
  451. /// program is copied or cloned, introducing a new value. Note that analysis
  452. /// implementations should tolerate clients that use this method to introduce
  453. /// the same value multiple times: if the analysis already knows about a
  454. /// value, it should ignore the request.
  455. ///
  456. virtual void copyValue(Value *From, Value *To);
  457. /// addEscapingUse - This method should be used whenever an escaping use is
  458. /// added to a pointer value. Analysis implementations may either return
  459. /// conservative responses for that value in the future, or may recompute
  460. /// some or all internal state to continue providing precise responses.
  461. ///
  462. /// Escaping uses are considered by anything _except_ the following:
  463. /// - GEPs or bitcasts of the pointer
  464. /// - Loads through the pointer
  465. /// - Stores through (but not of) the pointer
  466. virtual void addEscapingUse(Use &U);
  467. /// replaceWithNewValue - This method is the obvious combination of the two
  468. /// above, and it provided as a helper to simplify client code.
  469. ///
  470. void replaceWithNewValue(Value *Old, Value *New) {
  471. copyValue(Old, New);
  472. deleteValue(Old);
  473. }
  474. };
  475. // Specialize DenseMapInfo for Location.
  476. template<>
  477. struct DenseMapInfo<AliasAnalysis::Location> {
  478. static inline AliasAnalysis::Location getEmptyKey() {
  479. return
  480. AliasAnalysis::Location(DenseMapInfo<const Value *>::getEmptyKey(),
  481. 0, 0);
  482. }
  483. static inline AliasAnalysis::Location getTombstoneKey() {
  484. return
  485. AliasAnalysis::Location(DenseMapInfo<const Value *>::getTombstoneKey(),
  486. 0, 0);
  487. }
  488. static unsigned getHashValue(const AliasAnalysis::Location &Val) {
  489. return DenseMapInfo<const Value *>::getHashValue(Val.Ptr) ^
  490. DenseMapInfo<uint64_t>::getHashValue(Val.Size) ^
  491. DenseMapInfo<const MDNode *>::getHashValue(Val.TBAATag);
  492. }
  493. static bool isEqual(const AliasAnalysis::Location &LHS,
  494. const AliasAnalysis::Location &RHS) {
  495. return LHS.Ptr == RHS.Ptr &&
  496. LHS.Size == RHS.Size &&
  497. LHS.TBAATag == RHS.TBAATag;
  498. }
  499. };
  500. /// isNoAliasCall - Return true if this pointer is returned by a noalias
  501. /// function.
  502. bool isNoAliasCall(const Value *V);
  503. /// isIdentifiedObject - Return true if this pointer refers to a distinct and
  504. /// identifiable object. This returns true for:
  505. /// Global Variables and Functions (but not Global Aliases)
  506. /// Allocas
  507. /// ByVal and NoAlias Arguments
  508. /// NoAlias returns (e.g. calls to malloc)
  509. ///
  510. bool isIdentifiedObject(const Value *V);
  511. } // End llvm namespace
  512. #endif