AliasAnalysis.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  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 MemoryLocation 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
  22. // MemoryLocation::UnknownSize if the size is not known. The TBAA tag
  23. // identifies the "type" of the memory reference; see the
  24. // TypeBasedAliasAnalysis class for details.
  25. //
  26. // Some non-obvious details include:
  27. // - Pointers that point to two completely different objects in memory never
  28. // alias, regardless of the value of the Size component.
  29. // - NoAlias doesn't imply inequal pointers. The most obvious example of this
  30. // is two pointers to constant memory. Even if they are equal, constant
  31. // memory is never stored to, so there will never be any dependencies.
  32. // In this and other situations, the pointers may be both NoAlias and
  33. // MustAlias at the same time. The current API can only return one result,
  34. // though this is rarely a problem in practice.
  35. //
  36. //===----------------------------------------------------------------------===//
  37. #ifndef LLVM_ANALYSIS_ALIASANALYSIS_H
  38. #define LLVM_ANALYSIS_ALIASANALYSIS_H
  39. #include "llvm/ADT/DenseMap.h"
  40. #include "llvm/IR/CallSite.h"
  41. #include "llvm/IR/Metadata.h"
  42. #include "llvm/Analysis/MemoryLocation.h"
  43. namespace llvm {
  44. class LoadInst;
  45. class StoreInst;
  46. class VAArgInst;
  47. class DataLayout;
  48. class TargetLibraryInfo;
  49. class Pass;
  50. class AnalysisUsage;
  51. class MemTransferInst;
  52. class MemIntrinsic;
  53. class DominatorTree;
  54. /// The possible results of an alias query.
  55. ///
  56. /// These results are always computed between two MemoryLocation objects as
  57. /// a query to some alias analysis.
  58. ///
  59. /// Note that these are unscoped enumerations because we would like to support
  60. /// implicitly testing a result for the existence of any possible aliasing with
  61. /// a conversion to bool, but an "enum class" doesn't support this. The
  62. /// canonical names from the literature are suffixed and unique anyways, and so
  63. /// they serve as global constants in LLVM for these results.
  64. ///
  65. /// See docs/AliasAnalysis.html for more information on the specific meanings
  66. /// of these values.
  67. enum AliasResult {
  68. /// The two locations do not alias at all.
  69. ///
  70. /// This value is arranged to convert to false, while all other values
  71. /// convert to true. This allows a boolean context to convert the result to
  72. /// a binary flag indicating whether there is the possibility of aliasing.
  73. NoAlias = 0,
  74. /// The two locations may or may not alias. This is the least precise result.
  75. MayAlias,
  76. /// The two locations alias, but only due to a partial overlap.
  77. PartialAlias,
  78. /// The two locations precisely alias each other.
  79. MustAlias,
  80. };
  81. class AliasAnalysis {
  82. protected:
  83. const DataLayout *DL;
  84. const TargetLibraryInfo *TLI;
  85. private:
  86. AliasAnalysis *AA; // Previous Alias Analysis to chain to.
  87. protected:
  88. /// InitializeAliasAnalysis - Subclasses must call this method to initialize
  89. /// the AliasAnalysis interface before any other methods are called. This is
  90. /// typically called by the run* methods of these subclasses. This may be
  91. /// called multiple times.
  92. ///
  93. void InitializeAliasAnalysis(Pass *P, const DataLayout *DL);
  94. /// getAnalysisUsage - All alias analysis implementations should invoke this
  95. /// directly (using AliasAnalysis::getAnalysisUsage(AU)).
  96. virtual void getAnalysisUsage(AnalysisUsage &AU) const;
  97. public:
  98. static char ID; // Class identification, replacement for typeinfo
  99. AliasAnalysis() : DL(nullptr), TLI(nullptr), AA(nullptr) {}
  100. virtual ~AliasAnalysis(); // We want to be subclassed
  101. /// getTargetLibraryInfo - Return a pointer to the current TargetLibraryInfo
  102. /// object, or null if no TargetLibraryInfo object is available.
  103. ///
  104. const TargetLibraryInfo *getTargetLibraryInfo() const { return TLI; }
  105. /// getTypeStoreSize - Return the DataLayout store size for the given type,
  106. /// if known, or a conservative value otherwise.
  107. ///
  108. uint64_t getTypeStoreSize(Type *Ty);
  109. //===--------------------------------------------------------------------===//
  110. /// Alias Queries...
  111. ///
  112. /// alias - The main low level interface to the alias analysis implementation.
  113. /// Returns an AliasResult indicating whether the two pointers are aliased to
  114. /// each other. This is the interface that must be implemented by specific
  115. /// alias analysis implementations.
  116. virtual AliasResult alias(const MemoryLocation &LocA,
  117. const MemoryLocation &LocB);
  118. /// alias - A convenience wrapper.
  119. AliasResult alias(const Value *V1, uint64_t V1Size,
  120. const Value *V2, uint64_t V2Size) {
  121. return alias(MemoryLocation(V1, V1Size), MemoryLocation(V2, V2Size));
  122. }
  123. /// alias - A convenience wrapper.
  124. AliasResult alias(const Value *V1, const Value *V2) {
  125. return alias(V1, MemoryLocation::UnknownSize, V2,
  126. MemoryLocation::UnknownSize);
  127. }
  128. /// isNoAlias - A trivial helper function to check to see if the specified
  129. /// pointers are no-alias.
  130. bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
  131. return alias(LocA, LocB) == NoAlias;
  132. }
  133. /// isNoAlias - A convenience wrapper.
  134. bool isNoAlias(const Value *V1, uint64_t V1Size,
  135. const Value *V2, uint64_t V2Size) {
  136. return isNoAlias(MemoryLocation(V1, V1Size), MemoryLocation(V2, V2Size));
  137. }
  138. /// isNoAlias - A convenience wrapper.
  139. bool isNoAlias(const Value *V1, const Value *V2) {
  140. return isNoAlias(MemoryLocation(V1), MemoryLocation(V2));
  141. }
  142. /// isMustAlias - A convenience wrapper.
  143. bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
  144. return alias(LocA, LocB) == MustAlias;
  145. }
  146. /// isMustAlias - A convenience wrapper.
  147. bool isMustAlias(const Value *V1, const Value *V2) {
  148. return alias(V1, 1, V2, 1) == MustAlias;
  149. }
  150. /// pointsToConstantMemory - If the specified memory location is
  151. /// known to be constant, return true. If OrLocal is true and the
  152. /// specified memory location is known to be "local" (derived from
  153. /// an alloca), return true. Otherwise return false.
  154. virtual bool pointsToConstantMemory(const MemoryLocation &Loc,
  155. bool OrLocal = false);
  156. /// pointsToConstantMemory - A convenient wrapper.
  157. bool pointsToConstantMemory(const Value *P, bool OrLocal = false) {
  158. return pointsToConstantMemory(MemoryLocation(P), OrLocal);
  159. }
  160. //===--------------------------------------------------------------------===//
  161. /// Simple mod/ref information...
  162. ///
  163. /// ModRefResult - Represent the result of a mod/ref query. Mod and Ref are
  164. /// bits which may be or'd together.
  165. ///
  166. enum ModRefResult { NoModRef = 0, Ref = 1, Mod = 2, ModRef = 3 };
  167. /// These values define additional bits used to define the
  168. /// ModRefBehavior values.
  169. enum { Nowhere = 0, ArgumentPointees = 4, Anywhere = 8 | ArgumentPointees };
  170. /// ModRefBehavior - Summary of how a function affects memory in the program.
  171. /// Loads from constant globals are not considered memory accesses for this
  172. /// interface. Also, functions may freely modify stack space local to their
  173. /// invocation without having to report it through these interfaces.
  174. enum ModRefBehavior {
  175. /// DoesNotAccessMemory - This function does not perform any non-local loads
  176. /// or stores to memory.
  177. ///
  178. /// This property corresponds to the GCC 'const' attribute.
  179. /// This property corresponds to the LLVM IR 'readnone' attribute.
  180. /// This property corresponds to the IntrNoMem LLVM intrinsic flag.
  181. DoesNotAccessMemory = Nowhere | NoModRef,
  182. /// OnlyReadsArgumentPointees - The only memory references in this function
  183. /// (if it has any) are non-volatile loads from objects pointed to by its
  184. /// pointer-typed arguments, with arbitrary offsets.
  185. ///
  186. /// This property corresponds to the LLVM IR 'argmemonly' attribute combined
  187. /// with 'readonly' attribute.
  188. /// This property corresponds to the IntrReadArgMem LLVM intrinsic flag.
  189. OnlyReadsArgumentPointees = ArgumentPointees | Ref,
  190. /// OnlyAccessesArgumentPointees - The only memory references in this
  191. /// function (if it has any) are non-volatile loads and stores from objects
  192. /// pointed to by its pointer-typed arguments, with arbitrary offsets.
  193. ///
  194. /// This property corresponds to the LLVM IR 'argmemonly' attribute.
  195. /// This property corresponds to the IntrReadWriteArgMem LLVM intrinsic flag.
  196. OnlyAccessesArgumentPointees = ArgumentPointees | ModRef,
  197. /// OnlyReadsMemory - This function does not perform any non-local stores or
  198. /// volatile loads, but may read from any memory location.
  199. ///
  200. /// This property corresponds to the GCC 'pure' attribute.
  201. /// This property corresponds to the LLVM IR 'readonly' attribute.
  202. /// This property corresponds to the IntrReadMem LLVM intrinsic flag.
  203. OnlyReadsMemory = Anywhere | Ref,
  204. /// UnknownModRefBehavior - This indicates that the function could not be
  205. /// classified into one of the behaviors above.
  206. UnknownModRefBehavior = Anywhere | ModRef
  207. };
  208. /// Get the ModRef info associated with a pointer argument of a callsite. The
  209. /// result's bits are set to indicate the allowed aliasing ModRef kinds. Note
  210. /// that these bits do not necessarily account for the overall behavior of
  211. /// the function, but rather only provide additional per-argument
  212. /// information.
  213. virtual ModRefResult getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx);
  214. /// getModRefBehavior - Return the behavior when calling the given call site.
  215. virtual ModRefBehavior getModRefBehavior(ImmutableCallSite CS);
  216. /// getModRefBehavior - Return the behavior when calling the given function.
  217. /// For use when the call site is not known.
  218. virtual ModRefBehavior getModRefBehavior(const Function *F);
  219. /// doesNotAccessMemory - If the specified call is known to never read or
  220. /// write memory, return true. If the call only reads from known-constant
  221. /// memory, it is also legal to return true. Calls that unwind the stack
  222. /// are legal for this predicate.
  223. ///
  224. /// Many optimizations (such as CSE and LICM) can be performed on such calls
  225. /// without worrying about aliasing properties, and many calls have this
  226. /// property (e.g. calls to 'sin' and 'cos').
  227. ///
  228. /// This property corresponds to the GCC 'const' attribute.
  229. ///
  230. bool doesNotAccessMemory(ImmutableCallSite CS) {
  231. return getModRefBehavior(CS) == DoesNotAccessMemory;
  232. }
  233. /// doesNotAccessMemory - If the specified function is known to never read or
  234. /// write memory, return true. For use when the call site is not known.
  235. ///
  236. bool doesNotAccessMemory(const Function *F) {
  237. return getModRefBehavior(F) == DoesNotAccessMemory;
  238. }
  239. /// onlyReadsMemory - If the specified call is known to only read from
  240. /// non-volatile memory (or not access memory at all), return true. Calls
  241. /// that unwind the stack are legal for this predicate.
  242. ///
  243. /// This property allows many common optimizations to be performed in the
  244. /// absence of interfering store instructions, such as CSE of strlen calls.
  245. ///
  246. /// This property corresponds to the GCC 'pure' attribute.
  247. ///
  248. bool onlyReadsMemory(ImmutableCallSite CS) {
  249. return onlyReadsMemory(getModRefBehavior(CS));
  250. }
  251. /// onlyReadsMemory - If the specified function is known to only read from
  252. /// non-volatile memory (or not access memory at all), return true. For use
  253. /// when the call site is not known.
  254. ///
  255. bool onlyReadsMemory(const Function *F) {
  256. return onlyReadsMemory(getModRefBehavior(F));
  257. }
  258. /// onlyReadsMemory - Return true if functions with the specified behavior are
  259. /// known to only read from non-volatile memory (or not access memory at all).
  260. ///
  261. static bool onlyReadsMemory(ModRefBehavior MRB) {
  262. return !(MRB & Mod);
  263. }
  264. /// onlyAccessesArgPointees - Return true if functions with the specified
  265. /// behavior are known to read and write at most from objects pointed to by
  266. /// their pointer-typed arguments (with arbitrary offsets).
  267. ///
  268. static bool onlyAccessesArgPointees(ModRefBehavior MRB) {
  269. return !(MRB & Anywhere & ~ArgumentPointees);
  270. }
  271. /// doesAccessArgPointees - Return true if functions with the specified
  272. /// behavior are known to potentially read or write from objects pointed
  273. /// to be their pointer-typed arguments (with arbitrary offsets).
  274. ///
  275. static bool doesAccessArgPointees(ModRefBehavior MRB) {
  276. return (MRB & ModRef) && (MRB & ArgumentPointees);
  277. }
  278. /// getModRefInfo - Return information about whether or not an
  279. /// instruction may read or write memory (without regard to a
  280. /// specific location)
  281. ModRefResult getModRefInfo(const Instruction *I) {
  282. if (auto CS = ImmutableCallSite(I)) {
  283. auto MRB = getModRefBehavior(CS);
  284. if (MRB & ModRef)
  285. return ModRef;
  286. else if (MRB & Ref)
  287. return Ref;
  288. else if (MRB & Mod)
  289. return Mod;
  290. return NoModRef;
  291. }
  292. return getModRefInfo(I, MemoryLocation());
  293. }
  294. /// getModRefInfo - Return information about whether or not an instruction may
  295. /// read or write the specified memory location. An instruction
  296. /// that doesn't read or write memory may be trivially LICM'd for example.
  297. ModRefResult getModRefInfo(const Instruction *I, const MemoryLocation &Loc) {
  298. switch (I->getOpcode()) {
  299. case Instruction::VAArg: return getModRefInfo((const VAArgInst*)I, Loc);
  300. case Instruction::Load: return getModRefInfo((const LoadInst*)I, Loc);
  301. case Instruction::Store: return getModRefInfo((const StoreInst*)I, Loc);
  302. case Instruction::Fence: return getModRefInfo((const FenceInst*)I, Loc);
  303. case Instruction::AtomicCmpXchg:
  304. return getModRefInfo((const AtomicCmpXchgInst*)I, Loc);
  305. case Instruction::AtomicRMW:
  306. return getModRefInfo((const AtomicRMWInst*)I, Loc);
  307. case Instruction::Call: return getModRefInfo((const CallInst*)I, Loc);
  308. case Instruction::Invoke: return getModRefInfo((const InvokeInst*)I,Loc);
  309. default: return NoModRef;
  310. }
  311. }
  312. /// getModRefInfo - A convenience wrapper.
  313. ModRefResult getModRefInfo(const Instruction *I,
  314. const Value *P, uint64_t Size) {
  315. return getModRefInfo(I, MemoryLocation(P, Size));
  316. }
  317. /// getModRefInfo (for call sites) - Return information about whether
  318. /// a particular call site modifies or reads the specified memory location.
  319. virtual ModRefResult getModRefInfo(ImmutableCallSite CS,
  320. const MemoryLocation &Loc);
  321. /// getModRefInfo (for call sites) - A convenience wrapper.
  322. ModRefResult getModRefInfo(ImmutableCallSite CS,
  323. const Value *P, uint64_t Size) {
  324. return getModRefInfo(CS, MemoryLocation(P, Size));
  325. }
  326. /// getModRefInfo (for calls) - Return information about whether
  327. /// a particular call modifies or reads the specified memory location.
  328. ModRefResult getModRefInfo(const CallInst *C, const MemoryLocation &Loc) {
  329. return getModRefInfo(ImmutableCallSite(C), Loc);
  330. }
  331. /// getModRefInfo (for calls) - A convenience wrapper.
  332. ModRefResult getModRefInfo(const CallInst *C, const Value *P, uint64_t Size) {
  333. return getModRefInfo(C, MemoryLocation(P, Size));
  334. }
  335. /// getModRefInfo (for invokes) - Return information about whether
  336. /// a particular invoke modifies or reads the specified memory location.
  337. ModRefResult getModRefInfo(const InvokeInst *I, const MemoryLocation &Loc) {
  338. return getModRefInfo(ImmutableCallSite(I), Loc);
  339. }
  340. /// getModRefInfo (for invokes) - A convenience wrapper.
  341. ModRefResult getModRefInfo(const InvokeInst *I,
  342. const Value *P, uint64_t Size) {
  343. return getModRefInfo(I, MemoryLocation(P, Size));
  344. }
  345. /// getModRefInfo (for loads) - Return information about whether
  346. /// a particular load modifies or reads the specified memory location.
  347. ModRefResult getModRefInfo(const LoadInst *L, const MemoryLocation &Loc);
  348. /// getModRefInfo (for loads) - A convenience wrapper.
  349. ModRefResult getModRefInfo(const LoadInst *L, const Value *P, uint64_t Size) {
  350. return getModRefInfo(L, MemoryLocation(P, Size));
  351. }
  352. /// getModRefInfo (for stores) - Return information about whether
  353. /// a particular store modifies or reads the specified memory location.
  354. ModRefResult getModRefInfo(const StoreInst *S, const MemoryLocation &Loc);
  355. /// getModRefInfo (for stores) - A convenience wrapper.
  356. ModRefResult getModRefInfo(const StoreInst *S, const Value *P, uint64_t Size){
  357. return getModRefInfo(S, MemoryLocation(P, Size));
  358. }
  359. /// getModRefInfo (for fences) - Return information about whether
  360. /// a particular store modifies or reads the specified memory location.
  361. ModRefResult getModRefInfo(const FenceInst *S, const MemoryLocation &Loc) {
  362. // Conservatively correct. (We could possibly be a bit smarter if
  363. // Loc is a alloca that doesn't escape.)
  364. return ModRef;
  365. }
  366. /// getModRefInfo (for fences) - A convenience wrapper.
  367. ModRefResult getModRefInfo(const FenceInst *S, const Value *P, uint64_t Size){
  368. return getModRefInfo(S, MemoryLocation(P, Size));
  369. }
  370. /// getModRefInfo (for cmpxchges) - Return information about whether
  371. /// a particular cmpxchg modifies or reads the specified memory location.
  372. ModRefResult getModRefInfo(const AtomicCmpXchgInst *CX,
  373. const MemoryLocation &Loc);
  374. /// getModRefInfo (for cmpxchges) - A convenience wrapper.
  375. ModRefResult getModRefInfo(const AtomicCmpXchgInst *CX,
  376. const Value *P, unsigned Size) {
  377. return getModRefInfo(CX, MemoryLocation(P, Size));
  378. }
  379. /// getModRefInfo (for atomicrmws) - Return information about whether
  380. /// a particular atomicrmw modifies or reads the specified memory location.
  381. ModRefResult getModRefInfo(const AtomicRMWInst *RMW,
  382. const MemoryLocation &Loc);
  383. /// getModRefInfo (for atomicrmws) - A convenience wrapper.
  384. ModRefResult getModRefInfo(const AtomicRMWInst *RMW,
  385. const Value *P, unsigned Size) {
  386. return getModRefInfo(RMW, MemoryLocation(P, Size));
  387. }
  388. /// getModRefInfo (for va_args) - Return information about whether
  389. /// a particular va_arg modifies or reads the specified memory location.
  390. ModRefResult getModRefInfo(const VAArgInst *I, const MemoryLocation &Loc);
  391. /// getModRefInfo (for va_args) - A convenience wrapper.
  392. ModRefResult getModRefInfo(const VAArgInst* I, const Value* P, uint64_t Size){
  393. return getModRefInfo(I, MemoryLocation(P, Size));
  394. }
  395. /// getModRefInfo - Return information about whether a call and an instruction
  396. /// may refer to the same memory locations.
  397. ModRefResult getModRefInfo(Instruction *I,
  398. ImmutableCallSite Call);
  399. /// getModRefInfo - Return information about whether two call sites may refer
  400. /// to the same set of memory locations. See
  401. /// http://llvm.org/docs/AliasAnalysis.html#ModRefInfo
  402. /// for details.
  403. virtual ModRefResult getModRefInfo(ImmutableCallSite CS1,
  404. ImmutableCallSite CS2);
  405. /// callCapturesBefore - Return information about whether a particular call
  406. /// site modifies or reads the specified memory location.
  407. ModRefResult callCapturesBefore(const Instruction *I,
  408. const MemoryLocation &MemLoc,
  409. DominatorTree *DT);
  410. /// callCapturesBefore - A convenience wrapper.
  411. ModRefResult callCapturesBefore(const Instruction *I, const Value *P,
  412. uint64_t Size, DominatorTree *DT) {
  413. return callCapturesBefore(I, MemoryLocation(P, Size), DT);
  414. }
  415. //===--------------------------------------------------------------------===//
  416. /// Higher level methods for querying mod/ref information.
  417. ///
  418. /// canBasicBlockModify - Return true if it is possible for execution of the
  419. /// specified basic block to modify the location Loc.
  420. bool canBasicBlockModify(const BasicBlock &BB, const MemoryLocation &Loc);
  421. /// canBasicBlockModify - A convenience wrapper.
  422. bool canBasicBlockModify(const BasicBlock &BB, const Value *P, uint64_t Size){
  423. return canBasicBlockModify(BB, MemoryLocation(P, Size));
  424. }
  425. /// canInstructionRangeModRef - Return true if it is possible for the
  426. /// execution of the specified instructions to mod\ref (according to the
  427. /// mode) the location Loc. The instructions to consider are all
  428. /// of the instructions in the range of [I1,I2] INCLUSIVE.
  429. /// I1 and I2 must be in the same basic block.
  430. bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2,
  431. const MemoryLocation &Loc,
  432. const ModRefResult Mode);
  433. /// canInstructionRangeModRef - A convenience wrapper.
  434. bool canInstructionRangeModRef(const Instruction &I1,
  435. const Instruction &I2, const Value *Ptr,
  436. uint64_t Size, const ModRefResult Mode) {
  437. return canInstructionRangeModRef(I1, I2, MemoryLocation(Ptr, Size), Mode);
  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. /// addEscapingUse - This method should be used whenever an escaping use is
  451. /// added to a pointer value. Analysis implementations may either return
  452. /// conservative responses for that value in the future, or may recompute
  453. /// some or all internal state to continue providing precise responses.
  454. ///
  455. /// Escaping uses are considered by anything _except_ the following:
  456. /// - GEPs or bitcasts of the pointer
  457. /// - Loads through the pointer
  458. /// - Stores through (but not of) the pointer
  459. virtual void addEscapingUse(Use &U);
  460. /// replaceWithNewValue - This method is the obvious combination of the two
  461. /// above, and it provided as a helper to simplify client code.
  462. ///
  463. void replaceWithNewValue(Value *Old, Value *New) {
  464. deleteValue(Old);
  465. }
  466. };
  467. /// isNoAliasCall - Return true if this pointer is returned by a noalias
  468. /// function.
  469. bool isNoAliasCall(const Value *V);
  470. /// isNoAliasArgument - Return true if this is an argument with the noalias
  471. /// attribute.
  472. bool isNoAliasArgument(const Value *V);
  473. /// isIdentifiedObject - Return true if this pointer refers to a distinct and
  474. /// identifiable object. This returns true for:
  475. /// Global Variables and Functions (but not Global Aliases)
  476. /// Allocas
  477. /// ByVal and NoAlias Arguments
  478. /// NoAlias returns (e.g. calls to malloc)
  479. ///
  480. bool isIdentifiedObject(const Value *V);
  481. /// isIdentifiedFunctionLocal - Return true if V is umabigously identified
  482. /// at the function-level. Different IdentifiedFunctionLocals can't alias.
  483. /// Further, an IdentifiedFunctionLocal can not alias with any function
  484. /// arguments other than itself, which is not necessarily true for
  485. /// IdentifiedObjects.
  486. bool isIdentifiedFunctionLocal(const Value *V);
  487. } // End llvm namespace
  488. #endif