LLVM  4.0.0
AliasAnalysis.h
Go to the documentation of this file.
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 
38 #ifndef LLVM_ANALYSIS_ALIASANALYSIS_H
39 #define LLVM_ANALYSIS_ALIASANALYSIS_H
40 
41 #include "llvm/IR/CallSite.h"
42 #include "llvm/IR/Metadata.h"
43 #include "llvm/IR/PassManager.h"
46 
47 namespace llvm {
48 class BasicAAResult;
49 class LoadInst;
50 class StoreInst;
51 class VAArgInst;
52 class DataLayout;
53 class Pass;
54 class AnalysisUsage;
55 class MemTransferInst;
56 class MemIntrinsic;
57 class DominatorTree;
58 class OrderedBasicBlock;
59 
60 /// The possible results of an alias query.
61 ///
62 /// These results are always computed between two MemoryLocation objects as
63 /// a query to some alias analysis.
64 ///
65 /// Note that these are unscoped enumerations because we would like to support
66 /// implicitly testing a result for the existence of any possible aliasing with
67 /// a conversion to bool, but an "enum class" doesn't support this. The
68 /// canonical names from the literature are suffixed and unique anyways, and so
69 /// they serve as global constants in LLVM for these results.
70 ///
71 /// See docs/AliasAnalysis.html for more information on the specific meanings
72 /// of these values.
74  /// The two locations do not alias at all.
75  ///
76  /// This value is arranged to convert to false, while all other values
77  /// convert to true. This allows a boolean context to convert the result to
78  /// a binary flag indicating whether there is the possibility of aliasing.
79  NoAlias = 0,
80  /// The two locations may or may not alias. This is the least precise result.
82  /// The two locations alias, but only due to a partial overlap.
84  /// The two locations precisely alias each other.
86 };
87 
88 /// Flags indicating whether a memory access modifies or references memory.
89 ///
90 /// This is no access at all, a modification, a reference, or both
91 /// a modification and a reference. These are specifically structured such that
92 /// they form a two bit matrix and bit-tests for 'mod' or 'ref' work with any
93 /// of the possible values.
94 enum ModRefInfo {
95  /// The access neither references nor modifies the value stored in memory.
97  /// The access references the value stored in memory.
98  MRI_Ref = 1,
99  /// The access modifies the value stored in memory.
100  MRI_Mod = 2,
101  /// The access both references and modifies the value stored in memory.
103 };
104 
105 /// The locations at which a function might access memory.
106 ///
107 /// These are primarily used in conjunction with the \c AccessKind bits to
108 /// describe both the nature of access and the locations of access for a
109 /// function call.
111  /// Base case is no access to memory.
113  /// Access to memory via argument pointers.
115  /// Memory that is inaccessible via LLVM IR.
117  /// Access to any memory.
119 };
120 
121 /// Summary of how a function affects memory in the program.
122 ///
123 /// Loads from constant globals are not considered memory accesses for this
124 /// interface. Also, functions may freely modify stack space local to their
125 /// invocation without having to report it through these interfaces.
127  /// This function does not perform any non-local loads or stores to memory.
128  ///
129  /// This property corresponds to the GCC 'const' attribute.
130  /// This property corresponds to the LLVM IR 'readnone' attribute.
131  /// This property corresponds to the IntrNoMem LLVM intrinsic flag.
133 
134  /// The only memory references in this function (if it has any) are
135  /// non-volatile loads from objects pointed to by its pointer-typed
136  /// arguments, with arbitrary offsets.
137  ///
138  /// This property corresponds to the IntrReadArgMem LLVM intrinsic flag.
140 
141  /// The only memory references in this function (if it has any) are
142  /// non-volatile loads and stores from objects pointed to by its
143  /// pointer-typed arguments, with arbitrary offsets.
144  ///
145  /// This property corresponds to the IntrArgMemOnly LLVM intrinsic flag.
147 
148  /// The only memory references in this function (if it has any) are
149  /// references of memory that is otherwise inaccessible via LLVM IR.
150  ///
151  /// This property corresponds to the LLVM IR inaccessiblememonly attribute.
153 
154  /// The function may perform non-volatile loads and stores of objects
155  /// pointed to by its pointer-typed arguments, with arbitrary offsets, and
156  /// it may also perform loads and stores of memory that is otherwise
157  /// inaccessible via LLVM IR.
158  ///
159  /// This property corresponds to the LLVM IR
160  /// inaccessiblemem_or_argmemonly attribute.
163 
164  /// This function does not perform any non-local stores or volatile loads,
165  /// but may read from any memory location.
166  ///
167  /// This property corresponds to the GCC 'pure' attribute.
168  /// This property corresponds to the LLVM IR 'readonly' attribute.
169  /// This property corresponds to the IntrReadMem LLVM intrinsic flag.
171 
172  // This function does not read from memory anywhere, but may write to any
173  // memory location.
174  //
175  // This property corresponds to the LLVM IR 'writeonly' attribute.
176  // This property corresponds to the IntrWriteMem LLVM intrinsic flag.
178 
179  /// This indicates that the function could not be classified into one of the
180  /// behaviors above.
182 };
183 
184 class AAResults {
185 public:
186  // Make these results default constructable and movable. We have to spell
187  // these out because MSVC won't synthesize them.
188  AAResults(const TargetLibraryInfo &TLI) : TLI(TLI) {}
189  AAResults(AAResults &&Arg);
190  ~AAResults();
191 
192  /// Register a specific AA result.
193  template <typename AAResultT> void addAAResult(AAResultT &AAResult) {
194  // FIXME: We should use a much lighter weight system than the usual
195  // polymorphic pattern because we don't own AAResult. It should
196  // ideally involve two pointers and no separate allocation.
197  AAs.emplace_back(new Model<AAResultT>(AAResult, *this));
198  }
199 
200  /// Register a function analysis ID that the results aggregation depends on.
201  ///
202  /// This is used in the new pass manager to implement the invalidation logic
203  /// where we must invalidate the results aggregation if any of our component
204  /// analyses become invalid.
205  void addAADependencyID(AnalysisKey *ID) { AADeps.push_back(ID); }
206 
207  /// Handle invalidation events in the new pass manager.
208  ///
209  /// The aggregation is invalidated if any of the underlying analyses is
210  /// invalidated.
211  bool invalidate(Function &F, const PreservedAnalyses &PA,
213 
214  //===--------------------------------------------------------------------===//
215  /// \name Alias Queries
216  /// @{
217 
218  /// The main low level interface to the alias analysis implementation.
219  /// Returns an AliasResult indicating whether the two pointers are aliased to
220  /// each other. This is the interface that must be implemented by specific
221  /// alias analysis implementations.
222  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
223 
224  /// A convenience wrapper around the primary \c alias interface.
225  AliasResult alias(const Value *V1, uint64_t V1Size, const Value *V2,
226  uint64_t V2Size) {
227  return alias(MemoryLocation(V1, V1Size), MemoryLocation(V2, V2Size));
228  }
229 
230  /// A convenience wrapper around the primary \c alias interface.
231  AliasResult alias(const Value *V1, const Value *V2) {
232  return alias(V1, MemoryLocation::UnknownSize, V2,
234  }
235 
236  /// A trivial helper function to check to see if the specified pointers are
237  /// no-alias.
238  bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
239  return alias(LocA, LocB) == NoAlias;
240  }
241 
242  /// A convenience wrapper around the \c isNoAlias helper interface.
243  bool isNoAlias(const Value *V1, uint64_t V1Size, const Value *V2,
244  uint64_t V2Size) {
245  return isNoAlias(MemoryLocation(V1, V1Size), MemoryLocation(V2, V2Size));
246  }
247 
248  /// A convenience wrapper around the \c isNoAlias helper interface.
249  bool isNoAlias(const Value *V1, const Value *V2) {
250  return isNoAlias(MemoryLocation(V1), MemoryLocation(V2));
251  }
252 
253  /// A trivial helper function to check to see if the specified pointers are
254  /// must-alias.
255  bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
256  return alias(LocA, LocB) == MustAlias;
257  }
258 
259  /// A convenience wrapper around the \c isMustAlias helper interface.
260  bool isMustAlias(const Value *V1, const Value *V2) {
261  return alias(V1, 1, V2, 1) == MustAlias;
262  }
263 
264  /// Checks whether the given location points to constant memory, or if
265  /// \p OrLocal is true whether it points to a local alloca.
266  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal = false);
267 
268  /// A convenience wrapper around the primary \c pointsToConstantMemory
269  /// interface.
270  bool pointsToConstantMemory(const Value *P, bool OrLocal = false) {
271  return pointsToConstantMemory(MemoryLocation(P), OrLocal);
272  }
273 
274  /// @}
275  //===--------------------------------------------------------------------===//
276  /// \name Simple mod/ref information
277  /// @{
278 
279  /// Get the ModRef info associated with a pointer argument of a callsite. The
280  /// result's bits are set to indicate the allowed aliasing ModRef kinds. Note
281  /// that these bits do not necessarily account for the overall behavior of
282  /// the function, but rather only provide additional per-argument
283  /// information.
284  ModRefInfo getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx);
285 
286  /// Return the behavior of the given call site.
288 
289  /// Return the behavior when calling the given function.
291 
292  /// Checks if the specified call is known to never read or write memory.
293  ///
294  /// Note that if the call only reads from known-constant memory, it is also
295  /// legal to return true. Also, calls that unwind the stack are legal for
296  /// this predicate.
297  ///
298  /// Many optimizations (such as CSE and LICM) can be performed on such calls
299  /// without worrying about aliasing properties, and many calls have this
300  /// property (e.g. calls to 'sin' and 'cos').
301  ///
302  /// This property corresponds to the GCC 'const' attribute.
305  }
306 
307  /// Checks if the specified function is known to never read or write memory.
308  ///
309  /// Note that if the function only reads from known-constant memory, it is
310  /// also legal to return true. Also, function that unwind the stack are legal
311  /// for this predicate.
312  ///
313  /// Many optimizations (such as CSE and LICM) can be performed on such calls
314  /// to such functions without worrying about aliasing properties, and many
315  /// functions have this property (e.g. 'sin' and 'cos').
316  ///
317  /// This property corresponds to the GCC 'const' attribute.
320  }
321 
322  /// Checks if the specified call is known to only read from non-volatile
323  /// memory (or not access memory at all).
324  ///
325  /// Calls that unwind the stack are legal for this predicate.
326  ///
327  /// This property allows many common optimizations to be performed in the
328  /// absence of interfering store instructions, such as CSE of strlen calls.
329  ///
330  /// This property corresponds to the GCC 'pure' attribute.
333  }
334 
335  /// Checks if the specified function is known to only read from non-volatile
336  /// memory (or not access memory at all).
337  ///
338  /// Functions that unwind the stack are legal for this predicate.
339  ///
340  /// This property allows many common optimizations to be performed in the
341  /// absence of interfering store instructions, such as CSE of strlen calls.
342  ///
343  /// This property corresponds to the GCC 'pure' attribute.
344  bool onlyReadsMemory(const Function *F) {
346  }
347 
348  /// Checks if functions with the specified behavior are known to only read
349  /// from non-volatile memory (or not access memory at all).
351  return !(MRB & MRI_Mod);
352  }
353 
354  /// Checks if functions with the specified behavior are known to only write
355  /// memory (or not access memory at all).
357  return !(MRB & MRI_Ref);
358  }
359 
360  /// Checks if functions with the specified behavior are known to read and
361  /// write at most from objects pointed to by their pointer-typed arguments
362  /// (with arbitrary offsets).
364  return !(MRB & FMRL_Anywhere & ~FMRL_ArgumentPointees);
365  }
366 
367  /// Checks if functions with the specified behavior are known to potentially
368  /// read or write from objects pointed to be their pointer-typed arguments
369  /// (with arbitrary offsets).
371  return (MRB & MRI_ModRef) && (MRB & FMRL_ArgumentPointees);
372  }
373 
374  /// Checks if functions with the specified behavior are known to read and
375  /// write at most from memory that is inaccessible from LLVM IR.
377  return !(MRB & FMRL_Anywhere & ~FMRL_InaccessibleMem);
378  }
379 
380  /// Checks if functions with the specified behavior are known to potentially
381  /// read or write from memory that is inaccessible from LLVM IR.
383  return (MRB & MRI_ModRef) && (MRB & FMRL_InaccessibleMem);
384  }
385 
386  /// Checks if functions with the specified behavior are known to read and
387  /// write at most from memory that is inaccessible from LLVM IR or objects
388  /// pointed to by their pointer-typed arguments (with arbitrary offsets).
390  return !(MRB & FMRL_Anywhere &
392  }
393 
394  /// getModRefInfo (for call sites) - Return information about whether
395  /// a particular call site modifies or reads the specified memory location.
397 
398  /// getModRefInfo (for call sites) - A convenience wrapper.
400  uint64_t Size) {
401  return getModRefInfo(CS, MemoryLocation(P, Size));
402  }
403 
404  /// getModRefInfo (for calls) - Return information about whether
405  /// a particular call modifies or reads the specified memory location.
407  return getModRefInfo(ImmutableCallSite(C), Loc);
408  }
409 
410  /// getModRefInfo (for calls) - A convenience wrapper.
411  ModRefInfo getModRefInfo(const CallInst *C, const Value *P, uint64_t Size) {
412  return getModRefInfo(C, MemoryLocation(P, Size));
413  }
414 
415  /// getModRefInfo (for invokes) - Return information about whether
416  /// a particular invoke modifies or reads the specified memory location.
418  return getModRefInfo(ImmutableCallSite(I), Loc);
419  }
420 
421  /// getModRefInfo (for invokes) - A convenience wrapper.
422  ModRefInfo getModRefInfo(const InvokeInst *I, const Value *P, uint64_t Size) {
423  return getModRefInfo(I, MemoryLocation(P, Size));
424  }
425 
426  /// getModRefInfo (for loads) - Return information about whether
427  /// a particular load modifies or reads the specified memory location.
428  ModRefInfo getModRefInfo(const LoadInst *L, const MemoryLocation &Loc);
429 
430  /// getModRefInfo (for loads) - A convenience wrapper.
431  ModRefInfo getModRefInfo(const LoadInst *L, const Value *P, uint64_t Size) {
432  return getModRefInfo(L, MemoryLocation(P, Size));
433  }
434 
435  /// getModRefInfo (for stores) - Return information about whether
436  /// a particular store modifies or reads the specified memory location.
437  ModRefInfo getModRefInfo(const StoreInst *S, const MemoryLocation &Loc);
438 
439  /// getModRefInfo (for stores) - A convenience wrapper.
440  ModRefInfo getModRefInfo(const StoreInst *S, const Value *P, uint64_t Size) {
441  return getModRefInfo(S, MemoryLocation(P, Size));
442  }
443 
444  /// getModRefInfo (for fences) - Return information about whether
445  /// a particular store modifies or reads the specified memory location.
447  // Conservatively correct. (We could possibly be a bit smarter if
448  // Loc is a alloca that doesn't escape.)
449  return MRI_ModRef;
450  }
451 
452  /// getModRefInfo (for fences) - A convenience wrapper.
453  ModRefInfo getModRefInfo(const FenceInst *S, const Value *P, uint64_t Size) {
454  return getModRefInfo(S, MemoryLocation(P, Size));
455  }
456 
457  /// getModRefInfo (for cmpxchges) - Return information about whether
458  /// a particular cmpxchg modifies or reads the specified memory location.
460  const MemoryLocation &Loc);
461 
462  /// getModRefInfo (for cmpxchges) - A convenience wrapper.
464  unsigned Size) {
465  return getModRefInfo(CX, MemoryLocation(P, Size));
466  }
467 
468  /// getModRefInfo (for atomicrmws) - Return information about whether
469  /// a particular atomicrmw modifies or reads the specified memory location.
470  ModRefInfo getModRefInfo(const AtomicRMWInst *RMW, const MemoryLocation &Loc);
471 
472  /// getModRefInfo (for atomicrmws) - A convenience wrapper.
474  unsigned Size) {
475  return getModRefInfo(RMW, MemoryLocation(P, Size));
476  }
477 
478  /// getModRefInfo (for va_args) - Return information about whether
479  /// a particular va_arg modifies or reads the specified memory location.
480  ModRefInfo getModRefInfo(const VAArgInst *I, const MemoryLocation &Loc);
481 
482  /// getModRefInfo (for va_args) - A convenience wrapper.
483  ModRefInfo getModRefInfo(const VAArgInst *I, const Value *P, uint64_t Size) {
484  return getModRefInfo(I, MemoryLocation(P, Size));
485  }
486 
487  /// getModRefInfo (for catchpads) - Return information about whether
488  /// a particular catchpad modifies or reads the specified memory location.
490 
491  /// getModRefInfo (for catchpads) - A convenience wrapper.
493  uint64_t Size) {
494  return getModRefInfo(I, MemoryLocation(P, Size));
495  }
496 
497  /// getModRefInfo (for catchrets) - Return information about whether
498  /// a particular catchret modifies or reads the specified memory location.
500 
501  /// getModRefInfo (for catchrets) - A convenience wrapper.
503  uint64_t Size) {
504  return getModRefInfo(I, MemoryLocation(P, Size));
505  }
506 
507  /// Check whether or not an instruction may read or write memory (without
508  /// regard to a specific location).
509  ///
510  /// For function calls, this delegates to the alias-analysis specific
511  /// call-site mod-ref behavior queries. Otherwise it delegates to the generic
512  /// mod ref information query without a location.
514  if (auto CS = ImmutableCallSite(I)) {
515  auto MRB = getModRefBehavior(CS);
516  if ((MRB & MRI_ModRef) == MRI_ModRef)
517  return MRI_ModRef;
518  if (MRB & MRI_Ref)
519  return MRI_Ref;
520  if (MRB & MRI_Mod)
521  return MRI_Mod;
522  return MRI_NoModRef;
523  }
524 
525  return getModRefInfo(I, MemoryLocation());
526  }
527 
528  /// Check whether or not an instruction may read or write the specified
529  /// memory location.
530  ///
531  /// An instruction that doesn't read or write memory may be trivially LICM'd
532  /// for example.
533  ///
534  /// This primarily delegates to specific helpers above.
536  switch (I->getOpcode()) {
537  case Instruction::VAArg: return getModRefInfo((const VAArgInst*)I, Loc);
538  case Instruction::Load: return getModRefInfo((const LoadInst*)I, Loc);
539  case Instruction::Store: return getModRefInfo((const StoreInst*)I, Loc);
540  case Instruction::Fence: return getModRefInfo((const FenceInst*)I, Loc);
541  case Instruction::AtomicCmpXchg:
542  return getModRefInfo((const AtomicCmpXchgInst*)I, Loc);
543  case Instruction::AtomicRMW:
544  return getModRefInfo((const AtomicRMWInst*)I, Loc);
545  case Instruction::Call: return getModRefInfo((const CallInst*)I, Loc);
546  case Instruction::Invoke: return getModRefInfo((const InvokeInst*)I,Loc);
547  case Instruction::CatchPad:
548  return getModRefInfo((const CatchPadInst *)I, Loc);
549  case Instruction::CatchRet:
550  return getModRefInfo((const CatchReturnInst *)I, Loc);
551  default:
552  return MRI_NoModRef;
553  }
554  }
555 
556  /// A convenience wrapper for constructing the memory location.
558  uint64_t Size) {
559  return getModRefInfo(I, MemoryLocation(P, Size));
560  }
561 
562  /// Return information about whether a call and an instruction may refer to
563  /// the same memory locations.
565 
566  /// Return information about whether two call sites may refer to the same set
567  /// of memory locations. See the AA documentation for details:
568  /// http://llvm.org/docs/AliasAnalysis.html#ModRefInfo
570 
571  /// \brief Return information about whether a particular call site modifies
572  /// or reads the specified memory location \p MemLoc before instruction \p I
573  /// in a BasicBlock. A ordered basic block \p OBB can be used to speed up
574  /// instruction ordering queries inside the BasicBlock containing \p I.
576  const MemoryLocation &MemLoc, DominatorTree *DT,
577  OrderedBasicBlock *OBB = nullptr);
578 
579  /// \brief A convenience wrapper to synthesize a memory location.
581  uint64_t Size, DominatorTree *DT,
582  OrderedBasicBlock *OBB = nullptr) {
583  return callCapturesBefore(I, MemoryLocation(P, Size), DT, OBB);
584  }
585 
586  /// @}
587  //===--------------------------------------------------------------------===//
588  /// \name Higher level methods for querying mod/ref information.
589  /// @{
590 
591  /// Check if it is possible for execution of the specified basic block to
592  /// modify the location Loc.
593  bool canBasicBlockModify(const BasicBlock &BB, const MemoryLocation &Loc);
594 
595  /// A convenience wrapper synthesizing a memory location.
596  bool canBasicBlockModify(const BasicBlock &BB, const Value *P,
597  uint64_t Size) {
598  return canBasicBlockModify(BB, MemoryLocation(P, Size));
599  }
600 
601  /// Check if it is possible for the execution of the specified instructions
602  /// to mod\ref (according to the mode) the location Loc.
603  ///
604  /// The instructions to consider are all of the instructions in the range of
605  /// [I1,I2] INCLUSIVE. I1 and I2 must be in the same basic block.
606  bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2,
607  const MemoryLocation &Loc,
608  const ModRefInfo Mode);
609 
610  /// A convenience wrapper synthesizing a memory location.
612  const Value *Ptr, uint64_t Size,
613  const ModRefInfo Mode) {
614  return canInstructionRangeModRef(I1, I2, MemoryLocation(Ptr, Size), Mode);
615  }
616 
617 private:
618  class Concept;
619  template <typename T> class Model;
620 
621  template <typename T> friend class AAResultBase;
622 
623  const TargetLibraryInfo &TLI;
624 
625  std::vector<std::unique_ptr<Concept>> AAs;
626 
627  std::vector<AnalysisKey *> AADeps;
628 };
629 
630 /// Temporary typedef for legacy code that uses a generic \c AliasAnalysis
631 /// pointer or reference.
633 
634 /// A private abstract base class describing the concept of an individual alias
635 /// analysis implementation.
636 ///
637 /// This interface is implemented by any \c Model instantiation. It is also the
638 /// interface which a type used to instantiate the model must provide.
639 ///
640 /// All of these methods model methods by the same name in the \c
641 /// AAResults class. Only differences and specifics to how the
642 /// implementations are called are documented here.
644 public:
645  virtual ~Concept() = 0;
646 
647  /// An update API used internally by the AAResults to provide
648  /// a handle back to the top level aggregation.
649  virtual void setAAResults(AAResults *NewAAR) = 0;
650 
651  //===--------------------------------------------------------------------===//
652  /// \name Alias Queries
653  /// @{
654 
655  /// The main low level interface to the alias analysis implementation.
656  /// Returns an AliasResult indicating whether the two pointers are aliased to
657  /// each other. This is the interface that must be implemented by specific
658  /// alias analysis implementations.
659  virtual AliasResult alias(const MemoryLocation &LocA,
660  const MemoryLocation &LocB) = 0;
661 
662  /// Checks whether the given location points to constant memory, or if
663  /// \p OrLocal is true whether it points to a local alloca.
664  virtual bool pointsToConstantMemory(const MemoryLocation &Loc,
665  bool OrLocal) = 0;
666 
667  /// @}
668  //===--------------------------------------------------------------------===//
669  /// \name Simple mod/ref information
670  /// @{
671 
672  /// Get the ModRef info associated with a pointer argument of a callsite. The
673  /// result's bits are set to indicate the allowed aliasing ModRef kinds. Note
674  /// that these bits do not necessarily account for the overall behavior of
675  /// the function, but rather only provide additional per-argument
676  /// information.
678  unsigned ArgIdx) = 0;
679 
680  /// Return the behavior of the given call site.
682 
683  /// Return the behavior when calling the given function.
685 
686  /// getModRefInfo (for call sites) - Return information about whether
687  /// a particular call site modifies or reads the specified memory location.
689  const MemoryLocation &Loc) = 0;
690 
691  /// Return information about whether two call sites may refer to the same set
692  /// of memory locations. See the AA documentation for details:
693  /// http://llvm.org/docs/AliasAnalysis.html#ModRefInfo
695  ImmutableCallSite CS2) = 0;
696 
697  /// @}
698 };
699 
700 /// A private class template which derives from \c Concept and wraps some other
701 /// type.
702 ///
703 /// This models the concept by directly forwarding each interface point to the
704 /// wrapped type which must implement a compatible interface. This provides
705 /// a type erased binding.
706 template <typename AAResultT> class AAResults::Model final : public Concept {
707  AAResultT &Result;
708 
709 public:
710  explicit Model(AAResultT &Result, AAResults &AAR) : Result(Result) {
711  Result.setAAResults(&AAR);
712  }
713  ~Model() override {}
714 
715  void setAAResults(AAResults *NewAAR) override { Result.setAAResults(NewAAR); }
716 
717  AliasResult alias(const MemoryLocation &LocA,
718  const MemoryLocation &LocB) override {
719  return Result.alias(LocA, LocB);
720  }
721 
722  bool pointsToConstantMemory(const MemoryLocation &Loc,
723  bool OrLocal) override {
724  return Result.pointsToConstantMemory(Loc, OrLocal);
725  }
726 
727  ModRefInfo getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx) override {
728  return Result.getArgModRefInfo(CS, ArgIdx);
729  }
730 
731  FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS) override {
732  return Result.getModRefBehavior(CS);
733  }
734 
735  FunctionModRefBehavior getModRefBehavior(const Function *F) override {
736  return Result.getModRefBehavior(F);
737  }
738 
739  ModRefInfo getModRefInfo(ImmutableCallSite CS,
740  const MemoryLocation &Loc) override {
741  return Result.getModRefInfo(CS, Loc);
742  }
743 
744  ModRefInfo getModRefInfo(ImmutableCallSite CS1,
745  ImmutableCallSite CS2) override {
746  return Result.getModRefInfo(CS1, CS2);
747  }
748 };
749 
750 /// A CRTP-driven "mixin" base class to help implement the function alias
751 /// analysis results concept.
752 ///
753 /// Because of the nature of many alias analysis implementations, they often
754 /// only implement a subset of the interface. This base class will attempt to
755 /// implement the remaining portions of the interface in terms of simpler forms
756 /// of the interface where possible, and otherwise provide conservatively
757 /// correct fallback implementations.
758 ///
759 /// Implementors of an alias analysis should derive from this CRTP, and then
760 /// override specific methods that they wish to customize. There is no need to
761 /// use virtual anywhere, the CRTP base class does static dispatch to the
762 /// derived type passed into it.
763 template <typename DerivedT> class AAResultBase {
764  // Expose some parts of the interface only to the AAResults::Model
765  // for wrapping. Specifically, this allows the model to call our
766  // setAAResults method without exposing it as a fully public API.
767  friend class AAResults::Model<DerivedT>;
768 
769  /// A pointer to the AAResults object that this AAResult is
770  /// aggregated within. May be null if not aggregated.
771  AAResults *AAR;
772 
773  /// Helper to dispatch calls back through the derived type.
774  DerivedT &derived() { return static_cast<DerivedT &>(*this); }
775 
776  /// A setter for the AAResults pointer, which is used to satisfy the
777  /// AAResults::Model contract.
778  void setAAResults(AAResults *NewAAR) { AAR = NewAAR; }
779 
780 protected:
781  /// This proxy class models a common pattern where we delegate to either the
782  /// top-level \c AAResults aggregation if one is registered, or to the
783  /// current result if none are registered.
785  AAResults *AAR;
786  DerivedT &CurrentResult;
787 
788  public:
789  AAResultsProxy(AAResults *AAR, DerivedT &CurrentResult)
790  : AAR(AAR), CurrentResult(CurrentResult) {}
791 
792  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
793  return AAR ? AAR->alias(LocA, LocB) : CurrentResult.alias(LocA, LocB);
794  }
795 
796  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) {
797  return AAR ? AAR->pointsToConstantMemory(Loc, OrLocal)
798  : CurrentResult.pointsToConstantMemory(Loc, OrLocal);
799  }
800 
802  return AAR ? AAR->getArgModRefInfo(CS, ArgIdx) : CurrentResult.getArgModRefInfo(CS, ArgIdx);
803  }
804 
806  return AAR ? AAR->getModRefBehavior(CS) : CurrentResult.getModRefBehavior(CS);
807  }
808 
810  return AAR ? AAR->getModRefBehavior(F) : CurrentResult.getModRefBehavior(F);
811  }
812 
814  return AAR ? AAR->getModRefInfo(CS, Loc)
815  : CurrentResult.getModRefInfo(CS, Loc);
816  }
817 
819  return AAR ? AAR->getModRefInfo(CS1, CS2) : CurrentResult.getModRefInfo(CS1, CS2);
820  }
821  };
822 
823  explicit AAResultBase() {}
824 
825  // Provide all the copy and move constructors so that derived types aren't
826  // constrained.
827  AAResultBase(const AAResultBase &Arg) {}
829 
830  /// Get a proxy for the best AA result set to query at this time.
831  ///
832  /// When this result is part of a larger aggregation, this will proxy to that
833  /// aggregation. When this result is used in isolation, it will just delegate
834  /// back to the derived class's implementation.
835  ///
836  /// Note that callers of this need to take considerable care to not cause
837  /// performance problems when they use this routine, in the case of a large
838  /// number of alias analyses being aggregated, it can be expensive to walk
839  /// back across the chain.
840  AAResultsProxy getBestAAResults() { return AAResultsProxy(AAR, derived()); }
841 
842 public:
843  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
844  return MayAlias;
845  }
846 
847  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) {
848  return false;
849  }
850 
852  return MRI_ModRef;
853  }
854 
857  }
858 
861  }
862 
864  return MRI_ModRef;
865  }
866 
868  return MRI_ModRef;
869  }
870 };
871 
872 
873 /// Return true if this pointer is returned by a noalias function.
874 bool isNoAliasCall(const Value *V);
875 
876 /// Return true if this is an argument with the noalias attribute.
877 bool isNoAliasArgument(const Value *V);
878 
879 /// Return true if this pointer refers to a distinct and identifiable object.
880 /// This returns true for:
881 /// Global Variables and Functions (but not Global Aliases)
882 /// Allocas
883 /// ByVal and NoAlias Arguments
884 /// NoAlias returns (e.g. calls to malloc)
885 ///
886 bool isIdentifiedObject(const Value *V);
887 
888 /// Return true if V is umabigously identified at the function-level.
889 /// Different IdentifiedFunctionLocals can't alias.
890 /// Further, an IdentifiedFunctionLocal can not alias with any function
891 /// arguments other than itself, which is not necessarily true for
892 /// IdentifiedObjects.
893 bool isIdentifiedFunctionLocal(const Value *V);
894 
895 /// A manager for alias analyses.
896 ///
897 /// This class can have analyses registered with it and when run, it will run
898 /// all of them and aggregate their results into single AA results interface
899 /// that dispatches across all of the alias analysis results available.
900 ///
901 /// Note that the order in which analyses are registered is very significant.
902 /// That is the order in which the results will be aggregated and queried.
903 ///
904 /// This manager effectively wraps the AnalysisManager for registering alias
905 /// analyses. When you register your alias analysis with this manager, it will
906 /// ensure the analysis itself is registered with its AnalysisManager.
907 class AAManager : public AnalysisInfoMixin<AAManager> {
908 public:
909  typedef AAResults Result;
910 
911  /// Register a specific AA result.
912  template <typename AnalysisT> void registerFunctionAnalysis() {
913  ResultGetters.push_back(&getFunctionAAResultImpl<AnalysisT>);
914  }
915 
916  /// Register a specific AA result.
917  template <typename AnalysisT> void registerModuleAnalysis() {
918  ResultGetters.push_back(&getModuleAAResultImpl<AnalysisT>);
919  }
920 
922  Result R(AM.getResult<TargetLibraryAnalysis>(F));
923  for (auto &Getter : ResultGetters)
924  (*Getter)(F, AM, R);
925  return R;
926  }
927 
928 private:
930  static AnalysisKey Key;
931 
934  4> ResultGetters;
935 
936  template <typename AnalysisT>
937  static void getFunctionAAResultImpl(Function &F,
939  AAResults &AAResults) {
940  AAResults.addAAResult(AM.template getResult<AnalysisT>(F));
941  AAResults.addAADependencyID(AnalysisT::ID());
942  }
943 
944  template <typename AnalysisT>
945  static void getModuleAAResultImpl(Function &F, FunctionAnalysisManager &AM,
946  AAResults &AAResults) {
947  auto &MAMProxy = AM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
948  auto &MAM = MAMProxy.getManager();
949  if (auto *R = MAM.template getCachedResult<AnalysisT>(*F.getParent())) {
950  AAResults.addAAResult(*R);
951  MAMProxy
952  .template registerOuterAnalysisInvalidation<AnalysisT, AAManager>();
953  }
954  }
955 };
956 
957 /// A wrapper pass to provide the legacy pass manager access to a suitably
958 /// prepared AAResults object.
960  std::unique_ptr<AAResults> AAR;
961 
962 public:
963  static char ID;
964 
966 
967  AAResults &getAAResults() { return *AAR; }
968  const AAResults &getAAResults() const { return *AAR; }
969 
970  bool runOnFunction(Function &F) override;
971 
972  void getAnalysisUsage(AnalysisUsage &AU) const override;
973 };
974 
975 FunctionPass *createAAResultsWrapperPass();
976 
977 /// A wrapper pass around a callback which can be used to populate the
978 /// AAResults in the AAResultsWrapperPass from an external AA.
979 ///
980 /// The callback provided here will be used each time we prepare an AAResults
981 /// object, and will receive a reference to the function wrapper pass, the
982 /// function, and the AAResults object to populate. This should be used when
983 /// setting up a custom pass pipeline to inject a hook into the AA results.
984 ImmutablePass *createExternalAAWrapperPass(
985  std::function<void(Pass &, Function &, AAResults &)> Callback);
986 
987 /// A helper for the legacy pass manager to create a \c AAResults
988 /// object populated to the best of our ability for a particular function when
989 /// inside of a \c ModulePass or a \c CallGraphSCCPass.
990 ///
991 /// If a \c ModulePass or a \c CallGraphSCCPass calls \p
992 /// createLegacyPMAAResults, it also needs to call \p addUsedAAAnalyses in \p
993 /// getAnalysisUsage.
994 AAResults createLegacyPMAAResults(Pass &P, Function &F, BasicAAResult &BAR);
995 
996 /// A helper for the legacy pass manager to populate \p AU to add uses to make
997 /// sure the analyses required by \p createLegacyPMAAResults are available.
998 void getAAResultsAnalysisUsage(AnalysisUsage &AU);
999 
1000 } // End llvm namespace
1001 
1002 #endif
MachineLoop * L
ModRefInfo getModRefInfo(const LoadInst *L, const Value *P, uint64_t Size)
getModRefInfo (for loads) - A convenience wrapper.
The two locations precisely alias each other.
Definition: AliasAnalysis.h:85
const AAResults & getAAResults() const
static bool onlyAccessesInaccessibleMem(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to read and write at most from memory that ...
ModRefInfo getModRefInfo(const Instruction *I, const Value *P, uint64_t Size)
A convenience wrapper for constructing the memory location.
void addAAResult(AAResultT &AAResult)
Register a specific AA result.
bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2, const Value *Ptr, uint64_t Size, const ModRefInfo Mode)
A convenience wrapper synthesizing a memory location.
SI Whole Quad Mode
ModRefInfo getModRefInfo(const AtomicRMWInst *RMW, const Value *P, unsigned Size)
getModRefInfo (for atomicrmws) - A convenience wrapper.
AAResults AliasAnalysis
Temporary typedef for legacy code that uses a generic AliasAnalysis pointer or reference.
AAResultsProxy(AAResults *AAR, DerivedT &CurrentResult)
virtual ModRefInfo getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc)=0
getModRefInfo (for call sites) - Return information about whether a particular call site modifies or ...
An instruction for ordering other memory operations.
Definition: Instructions.h:430
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal)
an instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
Definition: Instructions.h:504
aarch64 AArch64 CCMP Pass
bool isNoAlias(const Value *V1, uint64_t V1Size, const Value *V2, uint64_t V2Size)
A convenience wrapper around the isNoAlias helper interface.
The two locations alias, but only due to a partial overlap.
Definition: AliasAnalysis.h:83
bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A trivial helper function to check to see if the specified pointers are no-alias. ...
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
ModRefInfo getModRefInfo(const CatchReturnInst *I, const Value *P, uint64_t Size)
getModRefInfo (for catchrets) - A convenience wrapper.
This class represents a function call, abstracting a target machine's calling convention.
This file contains the declarations for metadata subclasses.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
Definition: PassManager.h:886
bool doesNotAccessMemory(const Function *F)
Checks if the specified function is known to never read or write memory.
void registerModuleAnalysis()
Register a specific AA result.
bool onlyReadsMemory(ImmutableCallSite CS)
Checks if the specified call is known to only read from non-volatile memory (or not access memory at ...
static bool onlyAccessesInaccessibleOrArgMem(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to read and write at most from memory that ...
bool pointsToConstantMemory(const Value *P, bool OrLocal=false)
A convenience wrapper around the primary pointsToConstantMemory interface.
The two locations do not alias at all.
Definition: AliasAnalysis.h:79
bool isNoAliasCall(const Value *V)
Return true if this pointer is returned by a noalias function.
An instruction for reading from memory.
Definition: Instructions.h:164
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
Definition: Instructions.h:669
ModRefInfo getModRefInfo(const AtomicCmpXchgInst *CX, const Value *P, unsigned Size)
getModRefInfo (for cmpxchges) - A convenience wrapper.
ModRefInfo getModRefInfo(const CatchPadInst *I, const Value *P, uint64_t Size)
getModRefInfo (for catchpads) - A convenience wrapper.
The access modifies the value stored in memory.
The two locations may or may not alias. This is the least precise result.
Definition: AliasAnalysis.h:81
Access to any memory.
This indicates that the function could not be classified into one of the behaviors above...
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
The main low level interface to the alias analysis implementation.
The only memory references in this function (if it has any) are references of memory that is otherwis...
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
Definition: AliasAnalysis.h:94
FunctionPass * createAAResultsWrapperPass()
static bool doesNotReadMemory(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to only write memory (or not access memory ...
bool isNoAlias(const Value *V1, const Value *V2)
A convenience wrapper around the isNoAlias helper interface.
The only memory references in this function (if it has any) are non-volatile loads from objects point...
The access references the value stored in memory.
Definition: AliasAnalysis.h:98
AAResults createLegacyPMAAResults(Pass &P, Function &F, BasicAAResult &BAR)
A helper for the legacy pass manager to create a AAResults object populated to the best of our abilit...
The function may perform non-volatile loads and stores of objects pointed to by its pointer-typed arg...
virtual bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal)=0
Checks whether the given location points to constant memory, or if OrLocal is true whether it points ...
bool isIdentifiedObject(const Value *V)
Return true if this pointer refers to a distinct and identifiable object.
A CRTP-driven "mixin" base class to help implement the function alias analysis results concept...
AliasResult alias(const Value *V1, const Value *V2)
A convenience wrapper around the primary alias interface.
virtual void setAAResults(AAResults *NewAAR)=0
An update API used internally by the AAResults to provide a handle back to the top level aggregation...
AliasResult alias(const Value *V1, uint64_t V1Size, const Value *V2, uint64_t V2Size)
A convenience wrapper around the primary alias interface.
#define F(x, y, z)
Definition: MD5.cpp:51
ModRefInfo getModRefInfo(const InvokeInst *I, const Value *P, uint64_t Size)
getModRefInfo (for invokes) - A convenience wrapper.
Access to memory via argument pointers.
FunctionModRefBehavior
Summary of how a function affects memory in the program.
bool runOnFunction(Function &F) override
Run the wrapper pass to rebuild an aggregation over known AA passes.
ModRefInfo getModRefInfo(const FenceInst *S, const Value *P, uint64_t Size)
getModRefInfo (for fences) - A convenience wrapper.
AAResultBase(AAResultBase &&Arg)
An instruction for storing to memory.
Definition: Instructions.h:300
void registerFunctionAnalysis()
Register a specific AA result.
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
Definition: Dominators.h:96
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal)
A private abstract base class describing the concept of an individual alias analysis implementation...
static bool onlyReadsMemory(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to only read from non-volatile memory (or n...
ModRefInfo getModRefInfo(const VAArgInst *I, const Value *P, uint64_t Size)
getModRefInfo (for va_args) - A convenience wrapper.
ModRefInfo getModRefInfo(const Instruction *I, const MemoryLocation &Loc)
Check whether or not an instruction may read or write the specified memory location.
FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS)
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)
Handle invalidation events in the new pass manager.
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal=false)
Checks whether the given location points to constant memory, or if OrLocal is true whether it points ...
The access neither references nor modifies the value stored in memory.
Definition: AliasAnalysis.h:96
ImmutablePass * createExternalAAWrapperPass(std::function< void(Pass &, Function &, AAResults &)> Callback)
A wrapper pass around a callback which can be used to populate the AAResults in the AAResultsWrapperP...
#define P(N)
bool onlyReadsMemory(const Function *F)
Checks if the specified function is known to only read from non-volatile memory (or not access memory...
AAResultBase(const AAResultBase &Arg)
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:107
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs...ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:653
LLVM Basic Block Representation.
Definition: BasicBlock.h:51
bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2, const MemoryLocation &Loc, const ModRefInfo Mode)
Check if it is possible for the execution of the specified instructions to mod(according to the mode)...
A manager for alias analyses.
ModRefInfo getModRefInfo(const CallInst *C, const Value *P, uint64_t Size)
getModRefInfo (for calls) - A convenience wrapper.
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:328
ModRefInfo getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx)
Result run(Function &F, FunctionAnalysisManager &AM)
AliasResult
The possible results of an alias query.
Definition: AliasAnalysis.h:73
FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS)
Return the behavior of the given call site.
Represent the analysis usage information of a pass.
void addAADependencyID(AnalysisKey *ID)
Register a function analysis ID that the results aggregation depends on.
static bool doesAccessArgPointees(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to potentially read or write from objects p...
The only memory references in this function (if it has any) are non-volatile loads and stores from ob...
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:298
ModRefInfo getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2)
AAResults Result
ModRefInfo getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx)
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
void getAAResultsAnalysisUsage(AnalysisUsage &AU)
A helper for the legacy pass manager to populate AU to add uses to make sure the analyses required by...
ModRefInfo getModRefInfo(const FenceInst *S, const MemoryLocation &Loc)
getModRefInfo (for fences) - Return information about whether a particular store modifies or reads th...
This function does not perform any non-local loads or stores to memory.
bool isIdentifiedFunctionLocal(const Value *V)
Return true if V is umabigously identified at the function-level.
FunctionModRefLocation
The locations at which a function might access memory.
Representation for a specific memory location.
bool doesNotAccessMemory(ImmutableCallSite CS)
Checks if the specified call is known to never read or write memory.
Memory that is inaccessible via LLVM IR.
ModRefInfo getModRefInfo(ImmutableCallSite CS, const Value *P, uint64_t Size)
getModRefInfo (for call sites) - A convenience wrapper.
ModRefInfo getModRefInfo(const InvokeInst *I, const MemoryLocation &Loc)
getModRefInfo (for invokes) - Return information about whether a particular invoke modifies or reads ...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:843
Provides information about what library functions are available for the current target.
This function does not perform any non-local stores or volatile loads, but may read from any memory l...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
OuterAnalysisManagerProxy< ModuleAnalysisManager, Function > ModuleAnalysisManagerFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
Definition: PassManager.h:1095
bool isMustAlias(const Value *V1, const Value *V2)
A convenience wrapper around the isMustAlias helper interface.
This proxy class models a common pattern where we delegate to either the top-level AAResults aggregat...
ModRefInfo callCapturesBefore(const Instruction *I, const MemoryLocation &MemLoc, DominatorTree *DT, OrderedBasicBlock *OBB=nullptr)
Return information about whether a particular call site modifies or reads the specified memory locati...
ModRefInfo getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc)
getModRefInfo (for call sites) - Return information about whether a particular call site modifies or ...
virtual ModRefInfo getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx)=0
Get the ModRef info associated with a pointer argument of a callsite.
bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A trivial helper function to check to see if the specified pointers are must-alias.
AAResults(const TargetLibraryInfo &TLI)
static bool onlyAccessesArgPointees(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to read and write at most from objects poin...
ModRefInfo getModRefInfo(const CallInst *C, const MemoryLocation &Loc)
getModRefInfo (for calls) - Return information about whether a particular call modifies or reads the ...
Base case is no access to memory.
This file provides utility analysis objects describing memory locations.
static bool doesAccessInaccessibleMem(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to potentially read or write from memory th...
ImmutableCallSite - establish a view to a call site for examination.
Definition: CallSite.h:665
The access both references and modifies the value stored in memory.
#define I(x, y, z)
Definition: MD5.cpp:54
AAResultsProxy getBestAAResults()
Get a proxy for the best AA result set to query at this time.
virtual AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)=0
The main low level interface to the alias analysis implementation.
FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS)
ModRefInfo getModRefInfo(const StoreInst *S, const Value *P, uint64_t Size)
getModRefInfo (for stores) - A convenience wrapper.
ModRefInfo getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc)
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:525
Analysis pass providing the TargetLibraryInfo.
ModRefInfo callCapturesBefore(const Instruction *I, const Value *P, uint64_t Size, DominatorTree *DT, OrderedBasicBlock *OBB=nullptr)
A convenience wrapper to synthesize a memory location.
LLVM Value Representation.
Definition: Value.h:71
ModRefInfo getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc)
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Definition: Instruction.h:111
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Invoke instruction.
print Print MemDeps of function
FunctionModRefBehavior getModRefBehavior(const Function *F)
A container for analyses that lazily runs them and caches their results.
bool isNoAliasArgument(const Value *V)
Return true if this is an argument with the noalias attribute.
int * Ptr
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
This header defines various interfaces for pass management in LLVM.
bool canBasicBlockModify(const BasicBlock &BB, const Value *P, uint64_t Size)
A convenience wrapper synthesizing a memory location.
bool canBasicBlockModify(const BasicBlock &BB, const MemoryLocation &Loc)
Check if it is possible for execution of the specified basic block to modify the location Loc...
ModRefInfo getModRefInfo(const Instruction *I)
Check whether or not an instruction may read or write memory (without regard to a specific location)...
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:64
ModRefInfo getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx)
Get the ModRef info associated with a pointer argument of a callsite.
ModRefInfo getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2)
virtual FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS)=0
Return the behavior of the given call site.
FunctionModRefBehavior getModRefBehavior(const Function *F)