LLVM  16.0.0git
AliasAnalysis.h
Go to the documentation of this file.
1 //===- llvm/Analysis/AliasAnalysis.h - Alias Analysis Interface -*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the generic AliasAnalysis interface, which is used as the
10 // common interface used by all clients of alias analysis information, and
11 // implemented by all alias analysis implementations. Mod/Ref information is
12 // also captured by this interface.
13 //
14 // Implementations of this interface must implement the various virtual methods,
15 // which automatically provides functionality for the entire suite of client
16 // APIs.
17 //
18 // This API identifies memory regions with the MemoryLocation class. The pointer
19 // component specifies the base memory address of the region. The Size specifies
20 // the maximum size (in address units) of the memory region, or
21 // MemoryLocation::UnknownSize if the size is not known. The TBAA tag
22 // identifies the "type" of the memory reference; see the
23 // 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 
37 #ifndef LLVM_ANALYSIS_ALIASANALYSIS_H
38 #define LLVM_ANALYSIS_ALIASANALYSIS_H
39 
40 #include "llvm/ADT/DenseMap.h"
41 #include "llvm/ADT/Optional.h"
42 #include "llvm/ADT/Sequence.h"
43 #include "llvm/ADT/SmallVector.h"
45 #include "llvm/IR/PassManager.h"
46 #include "llvm/Pass.h"
47 #include <cstdint>
48 #include <functional>
49 #include <memory>
50 #include <vector>
51 
52 namespace llvm {
53 
54 class AnalysisUsage;
55 class AtomicCmpXchgInst;
56 class BasicAAResult;
57 class BasicBlock;
58 class CatchPadInst;
59 class CatchReturnInst;
60 class DominatorTree;
61 class FenceInst;
62 class Function;
63 class LoopInfo;
64 class PreservedAnalyses;
65 class TargetLibraryInfo;
66 class Value;
67 template <typename> class SmallPtrSetImpl;
68 
69 /// The possible results of an alias query.
70 ///
71 /// These results are always computed between two MemoryLocation objects as
72 /// a query to some alias analysis.
73 ///
74 /// Note that these are unscoped enumerations because we would like to support
75 /// implicitly testing a result for the existence of any possible aliasing with
76 /// a conversion to bool, but an "enum class" doesn't support this. The
77 /// canonical names from the literature are suffixed and unique anyways, and so
78 /// they serve as global constants in LLVM for these results.
79 ///
80 /// See docs/AliasAnalysis.html for more information on the specific meanings
81 /// of these values.
82 class AliasResult {
83 private:
84  static const int OffsetBits = 23;
85  static const int AliasBits = 8;
86  static_assert(AliasBits + 1 + OffsetBits <= 32,
87  "AliasResult size is intended to be 4 bytes!");
88 
89  unsigned int Alias : AliasBits;
90  unsigned int HasOffset : 1;
91  signed int Offset : OffsetBits;
92 
93 public:
94  enum Kind : uint8_t {
95  /// The two locations do not alias at all.
96  ///
97  /// This value is arranged to convert to false, while all other values
98  /// convert to true. This allows a boolean context to convert the result to
99  /// a binary flag indicating whether there is the possibility of aliasing.
100  NoAlias = 0,
101  /// The two locations may or may not alias. This is the least precise
102  /// result.
104  /// The two locations alias, but only due to a partial overlap.
106  /// The two locations precisely alias each other.
108  };
109  static_assert(MustAlias < (1 << AliasBits),
110  "Not enough bit field size for the enum!");
111 
112  explicit AliasResult() = delete;
113  constexpr AliasResult(const Kind &Alias)
114  : Alias(Alias), HasOffset(false), Offset(0) {}
115 
116  operator Kind() const { return static_cast<Kind>(Alias); }
117 
118  constexpr bool hasOffset() const { return HasOffset; }
119  constexpr int32_t getOffset() const {
120  assert(HasOffset && "No offset!");
121  return Offset;
122  }
123  void setOffset(int32_t NewOffset) {
124  if (isInt<OffsetBits>(NewOffset)) {
125  HasOffset = true;
126  Offset = NewOffset;
127  }
128  }
129 
130  /// Helper for processing AliasResult for swapped memory location pairs.
131  void swap(bool DoSwap = true) {
132  if (DoSwap && hasOffset())
133  setOffset(-getOffset());
134  }
135 };
136 
137 static_assert(sizeof(AliasResult) == 4,
138  "AliasResult size is intended to be 4 bytes!");
139 
140 /// << operator for AliasResult.
141 raw_ostream &operator<<(raw_ostream &OS, AliasResult AR);
142 
143 /// Flags indicating whether a memory access modifies or references memory.
144 ///
145 /// This is no access at all, a modification, a reference, or both
146 /// a modification and a reference.
147 enum class ModRefInfo : uint8_t {
148  /// The access neither references nor modifies the value stored in memory.
149  NoModRef = 0,
150  /// The access may reference the value stored in memory.
151  Ref = 1,
152  /// The access may modify the value stored in memory.
153  Mod = 2,
154  /// The access may reference and may modify the value stored in memory.
155  ModRef = Ref | Mod,
157 };
158 
159 [[nodiscard]] inline bool isNoModRef(const ModRefInfo MRI) {
160  return MRI == ModRefInfo::NoModRef;
161 }
162 [[nodiscard]] inline bool isModOrRefSet(const ModRefInfo MRI) {
163  return MRI != ModRefInfo::NoModRef;
164 }
165 [[nodiscard]] inline bool isModAndRefSet(const ModRefInfo MRI) {
166  return MRI == ModRefInfo::ModRef;
167 }
168 [[nodiscard]] inline bool isModSet(const ModRefInfo MRI) {
169  return static_cast<int>(MRI) & static_cast<int>(ModRefInfo::Mod);
170 }
171 [[nodiscard]] inline bool isRefSet(const ModRefInfo MRI) {
172  return static_cast<int>(MRI) & static_cast<int>(ModRefInfo::Ref);
173 }
174 
175 [[deprecated("Use operator | instead")]] [[nodiscard]] inline ModRefInfo
177  return MRI | ModRefInfo::Mod;
178 }
179 [[deprecated("Use operator | instead")]] [[nodiscard]] inline ModRefInfo
181  return MRI | ModRefInfo::Ref;
182 }
183 [[deprecated("Use operator & instead")]] [[nodiscard]] inline ModRefInfo
185  return MRI & ModRefInfo::Ref;
186 }
187 [[deprecated("Use operator & instead")]] [[nodiscard]] inline ModRefInfo
189  return MRI & ModRefInfo::Mod;
190 }
191 [[deprecated("Use operator | instead")]] [[nodiscard]] inline ModRefInfo
192 unionModRef(const ModRefInfo MRI1, const ModRefInfo MRI2) {
193  return MRI1 | MRI2;
194 }
195 [[deprecated("Use operator & instead")]] [[nodiscard]] inline ModRefInfo
196 intersectModRef(const ModRefInfo MRI1, const ModRefInfo MRI2) {
197  return MRI1 & MRI2;
198 }
199 
200 /// Debug print ModRefInfo.
201 raw_ostream &operator<<(raw_ostream &OS, ModRefInfo MR);
202 
203 /// Summary of how a function affects memory in the program.
204 ///
205 /// Loads from constant globals are not considered memory accesses for this
206 /// interface. Also, functions may freely modify stack space local to their
207 /// invocation without having to report it through these interfaces.
209 public:
210  /// The locations at which a function might access memory.
211  enum Location {
212  /// Access to memory via argument pointers.
213  ArgMem = 0,
214  /// Memory that is inaccessible via LLVM IR.
216  /// Any other memory.
217  Other = 2,
218  };
219 
220 private:
221  uint32_t Data = 0;
222 
223  static constexpr uint32_t BitsPerLoc = 2;
224  static constexpr uint32_t LocMask = (1 << BitsPerLoc) - 1;
225 
226  static uint32_t getLocationPos(Location Loc) {
227  return (uint32_t)Loc * BitsPerLoc;
228  }
229 
230  static auto locations() {
231  return enum_seq_inclusive(Location::ArgMem, Location::Other,
233  }
234 
235  FunctionModRefBehavior(uint32_t Data) : Data(Data) {}
236 
237  void setModRef(Location Loc, ModRefInfo MR) {
238  Data &= ~(LocMask << getLocationPos(Loc));
239  Data |= static_cast<uint32_t>(MR) << getLocationPos(Loc);
240  }
241 
242  friend raw_ostream &operator<<(raw_ostream &OS, FunctionModRefBehavior RMRB);
243 
244 public:
245  /// Create FunctionModRefBehavior that can access only the given location
246  /// with the given ModRefInfo.
247  FunctionModRefBehavior(Location Loc, ModRefInfo MR) { setModRef(Loc, MR); }
248 
249  /// Create FunctionModRefBehavior that can access any location with the
250  /// given ModRefInfo.
252  for (Location Loc : locations())
253  setModRef(Loc, MR);
254  }
255 
256  /// Create FunctionModRefBehavior that can read and write any memory.
259  }
260 
261  /// Create FunctionModRefBehavior that cannot read or write any memory.
264  }
265 
266  /// Create FunctionModRefBehavior that can read any memory.
269  }
270 
271  /// Create FunctionModRefBehavior that can write any memory.
274  }
275 
276  /// Create FunctionModRefBehavior that can only access argument memory.
278  return FunctionModRefBehavior(ArgMem, MR);
279  }
280 
281  /// Create FunctionModRefBehavior that can only access inaccessible memory.
284  }
285 
286  /// Create FunctionModRefBehavior that can only access inaccessible or
287  /// argument memory.
289  FunctionModRefBehavior FRMB = none();
290  FRMB.setModRef(ArgMem, MR);
291  FRMB.setModRef(InaccessibleMem, MR);
292  return FRMB;
293  }
294 
295  /// Get ModRefInfo for the given Location.
297  return ModRefInfo((Data >> getLocationPos(Loc)) & LocMask);
298  }
299 
300  /// Get new FunctionModRefBehavior with modified ModRefInfo for Loc.
302  FunctionModRefBehavior FMRB = *this;
303  FMRB.setModRef(Loc, MR);
304  return FMRB;
305  }
306 
307  /// Get new FunctionModRefBehavior with NoModRef on the given Loc.
309  FunctionModRefBehavior FMRB = *this;
310  FMRB.setModRef(Loc, ModRefInfo::NoModRef);
311  return FMRB;
312  }
313 
314  /// Get ModRefInfo for any location.
317  for (Location Loc : locations())
318  MR |= getModRef(Loc);
319  return MR;
320  }
321 
322  /// Whether this function accesses no memory.
323  bool doesNotAccessMemory() const { return Data == 0; }
324 
325  /// Whether this function only (at most) reads memory.
326  bool onlyReadsMemory() const { return !isModSet(getModRef()); }
327 
328  /// Whether this function only (at most) writes memory.
329  bool onlyWritesMemory() const { return !isRefSet(getModRef()); }
330 
331  /// Whether this function only (at most) accesses argument memory.
332  bool onlyAccessesArgPointees() const {
334  }
335 
336  /// Whether this function may access argument memory.
337  bool doesAccessArgPointees() const {
338  return isModOrRefSet(getModRef(ArgMem));
339  }
340 
341  /// Whether this function only (at most) accesses inaccessible memory.
344  }
345 
346  /// Whether this function only (at most) accesses argument and inaccessible
347  /// memory.
349  return isNoModRef(getModRef(Other));
350  }
351 
352  /// Intersect with another FunctionModRefBehavior.
354  return FunctionModRefBehavior(Data & Other.Data);
355  }
356 
357  /// Intersect (in-place) with another FunctionModRefBehavior.
359  Data &= Other.Data;
360  return *this;
361  }
362 
363  /// Union with another FunctionModRefBehavior.
365  return FunctionModRefBehavior(Data | Other.Data);
366  }
367 
368  /// Union (in-place) with another FunctionModRefBehavior.
370  Data |= Other.Data;
371  return *this;
372  }
373 
374  /// Check whether this is the same as another FunctionModRefBehavior.
376  return Data == Other.Data;
377  }
378 
379  /// Check whether this is different from another FunctionModRefBehavior.
381  return !operator==(Other);
382  }
383 };
384 
385 /// Debug print FunctionModRefBehavior.
386 raw_ostream &operator<<(raw_ostream &OS, FunctionModRefBehavior RMRB);
387 
388 /// Virtual base class for providers of capture information.
389 struct CaptureInfo {
390  virtual ~CaptureInfo() = 0;
391  virtual bool isNotCapturedBeforeOrAt(const Value *Object,
392  const Instruction *I) = 0;
393 };
394 
395 /// Context-free CaptureInfo provider, which computes and caches whether an
396 /// object is captured in the function at all, but does not distinguish whether
397 /// it was captured before or after the context instruction.
398 class SimpleCaptureInfo final : public CaptureInfo {
400 
401 public:
403  const Instruction *I) override;
404 };
405 
406 /// Context-sensitive CaptureInfo provider, which computes and caches the
407 /// earliest common dominator closure of all captures. It provides a good
408 /// approximation to a precise "captures before" analysis.
409 class EarliestEscapeInfo final : public CaptureInfo {
410  DominatorTree &DT;
411  const LoopInfo &LI;
412 
413  /// Map from identified local object to an instruction before which it does
414  /// not escape, or nullptr if it never escapes. The "earliest" instruction
415  /// may be a conservative approximation, e.g. the first instruction in the
416  /// function is always a legal choice.
418 
419  /// Reverse map from instruction to the objects it is the earliest escape for.
420  /// This is used for cache invalidation purposes.
422 
423  const SmallPtrSetImpl<const Value *> &EphValues;
424 
425 public:
427  const SmallPtrSetImpl<const Value *> &EphValues)
428  : DT(DT), LI(LI), EphValues(EphValues) {}
429 
430  bool isNotCapturedBeforeOrAt(const Value *Object,
431  const Instruction *I) override;
432 
434 };
435 
436 /// Reduced version of MemoryLocation that only stores a pointer and size.
437 /// Used for caching AATags independent BasicAA results.
438 struct AACacheLoc {
439  const Value *Ptr;
441 };
442 
443 template <> struct DenseMapInfo<AACacheLoc> {
444  static inline AACacheLoc getEmptyKey() {
447  }
448  static inline AACacheLoc getTombstoneKey() {
451  }
452  static unsigned getHashValue(const AACacheLoc &Val) {
455  }
456  static bool isEqual(const AACacheLoc &LHS, const AACacheLoc &RHS) {
457  return LHS.Ptr == RHS.Ptr && LHS.Size == RHS.Size;
458  }
459 };
460 
461 /// This class stores info we want to provide to or retain within an alias
462 /// query. By default, the root query is stateless and starts with a freshly
463 /// constructed info object. Specific alias analyses can use this query info to
464 /// store per-query state that is important for recursive or nested queries to
465 /// avoid recomputing. To enable preserving this state across multiple queries
466 /// where safe (due to the IR not changing), use a `BatchAAResults` wrapper.
467 /// The information stored in an `AAQueryInfo` is currently limitted to the
468 /// caches used by BasicAA, but can further be extended to fit other AA needs.
469 class AAQueryInfo {
470 public:
471  using LocPair = std::pair<AACacheLoc, AACacheLoc>;
472  struct CacheEntry {
474  /// Number of times a NoAlias assumption has been used.
475  /// 0 for assumptions that have not been used, -1 for definitive results.
477  /// Whether this is a definitive (non-assumption) result.
478  bool isDefinitive() const { return NumAssumptionUses < 0; }
479  };
482 
484 
485  /// Query depth used to distinguish recursive queries.
486  unsigned Depth = 0;
487 
488  /// How many active NoAlias assumption uses there are.
490 
491  /// Location pairs for which an assumption based result is currently stored.
492  /// Used to remove all potentially incorrect results from the cache if an
493  /// assumption is disproven.
495 
497 
498  /// Create a new AAQueryInfo based on this one, but with the cache cleared.
499  /// This is used for recursive queries across phis, where cache results may
500  /// not be valid.
502  AAQueryInfo NewAAQI(CI);
503  NewAAQI.Depth = Depth;
504  return NewAAQI;
505  }
506 };
507 
508 /// AAQueryInfo that uses SimpleCaptureInfo.
511 
512 public:
514 };
515 
516 class BatchAAResults;
517 
518 class AAResults {
519 public:
520  // Make these results default constructable and movable. We have to spell
521  // these out because MSVC won't synthesize them.
522  AAResults(const TargetLibraryInfo &TLI) : TLI(TLI) {}
524  ~AAResults();
525 
526  /// Register a specific AA result.
527  template <typename AAResultT> void addAAResult(AAResultT &AAResult) {
528  // FIXME: We should use a much lighter weight system than the usual
529  // polymorphic pattern because we don't own AAResult. It should
530  // ideally involve two pointers and no separate allocation.
531  AAs.emplace_back(new Model<AAResultT>(AAResult, *this));
532  }
533 
534  /// Register a function analysis ID that the results aggregation depends on.
535  ///
536  /// This is used in the new pass manager to implement the invalidation logic
537  /// where we must invalidate the results aggregation if any of our component
538  /// analyses become invalid.
539  void addAADependencyID(AnalysisKey *ID) { AADeps.push_back(ID); }
540 
541  /// Handle invalidation events in the new pass manager.
542  ///
543  /// The aggregation is invalidated if any of the underlying analyses is
544  /// invalidated.
545  bool invalidate(Function &F, const PreservedAnalyses &PA,
547 
548  //===--------------------------------------------------------------------===//
549  /// \name Alias Queries
550  /// @{
551 
552  /// The main low level interface to the alias analysis implementation.
553  /// Returns an AliasResult indicating whether the two pointers are aliased to
554  /// each other. This is the interface that must be implemented by specific
555  /// alias analysis implementations.
556  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
557 
558  /// A convenience wrapper around the primary \c alias interface.
559  AliasResult alias(const Value *V1, LocationSize V1Size, const Value *V2,
560  LocationSize V2Size) {
561  return alias(MemoryLocation(V1, V1Size), MemoryLocation(V2, V2Size));
562  }
563 
564  /// A convenience wrapper around the primary \c alias interface.
565  AliasResult alias(const Value *V1, const Value *V2) {
568  }
569 
570  /// A trivial helper function to check to see if the specified pointers are
571  /// no-alias.
572  bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
573  return alias(LocA, LocB) == AliasResult::NoAlias;
574  }
575 
576  /// A convenience wrapper around the \c isNoAlias helper interface.
577  bool isNoAlias(const Value *V1, LocationSize V1Size, const Value *V2,
578  LocationSize V2Size) {
579  return isNoAlias(MemoryLocation(V1, V1Size), MemoryLocation(V2, V2Size));
580  }
581 
582  /// A convenience wrapper around the \c isNoAlias helper interface.
583  bool isNoAlias(const Value *V1, const Value *V2) {
586  }
587 
588  /// A trivial helper function to check to see if the specified pointers are
589  /// must-alias.
590  bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
591  return alias(LocA, LocB) == AliasResult::MustAlias;
592  }
593 
594  /// A convenience wrapper around the \c isMustAlias helper interface.
595  bool isMustAlias(const Value *V1, const Value *V2) {
596  return alias(V1, LocationSize::precise(1), V2, LocationSize::precise(1)) ==
598  }
599 
600  /// Checks whether the given location points to constant memory, or if
601  /// \p OrLocal is true whether it points to a local alloca.
602  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal = false);
603 
604  /// A convenience wrapper around the primary \c pointsToConstantMemory
605  /// interface.
606  bool pointsToConstantMemory(const Value *P, bool OrLocal = false) {
608  }
609 
610  /// @}
611  //===--------------------------------------------------------------------===//
612  /// \name Simple mod/ref information
613  /// @{
614 
615  /// Get the ModRef info associated with a pointer argument of a call. The
616  /// result's bits are set to indicate the allowed aliasing ModRef kinds. Note
617  /// that these bits do not necessarily account for the overall behavior of
618  /// the function, but rather only provide additional per-argument
619  /// information.
620  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx);
621 
622  /// Return the behavior of the given call site.
624 
625  /// Return the behavior when calling the given function.
627 
628  /// Checks if the specified call is known to never read or write memory.
629  ///
630  /// Note that if the call only reads from known-constant memory, it is also
631  /// legal to return true. Also, calls that unwind the stack are legal for
632  /// this predicate.
633  ///
634  /// Many optimizations (such as CSE and LICM) can be performed on such calls
635  /// without worrying about aliasing properties, and many calls have this
636  /// property (e.g. calls to 'sin' and 'cos').
637  ///
638  /// This property corresponds to the GCC 'const' attribute.
639  bool doesNotAccessMemory(const CallBase *Call) {
640  return getModRefBehavior(Call).doesNotAccessMemory();
641  }
642 
643  /// Checks if the specified function is known to never read or write memory.
644  ///
645  /// Note that if the function only reads from known-constant memory, it is
646  /// also legal to return true. Also, function that unwind the stack are legal
647  /// for this predicate.
648  ///
649  /// Many optimizations (such as CSE and LICM) can be performed on such calls
650  /// to such functions without worrying about aliasing properties, and many
651  /// functions have this property (e.g. 'sin' and 'cos').
652  ///
653  /// This property corresponds to the GCC 'const' attribute.
656  }
657 
658  /// Checks if the specified call is known to only read from non-volatile
659  /// memory (or not access memory at all).
660  ///
661  /// Calls that unwind the stack are legal for this predicate.
662  ///
663  /// This property allows many common optimizations to be performed in the
664  /// absence of interfering store instructions, such as CSE of strlen calls.
665  ///
666  /// This property corresponds to the GCC 'pure' attribute.
667  bool onlyReadsMemory(const CallBase *Call) {
668  return getModRefBehavior(Call).onlyReadsMemory();
669  }
670 
671  /// Checks if the specified function is known to only read from non-volatile
672  /// memory (or not access memory at all).
673  ///
674  /// Functions that unwind the stack are legal for this predicate.
675  ///
676  /// This property allows many common optimizations to be performed in the
677  /// absence of interfering store instructions, such as CSE of strlen calls.
678  ///
679  /// This property corresponds to the GCC 'pure' attribute.
680  bool onlyReadsMemory(const Function *F) {
682  }
683 
684  /// getModRefInfo (for call sites) - Return information about whether
685  /// a particular call site modifies or reads the specified memory location.
686  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc);
687 
688  /// getModRefInfo (for call sites) - A convenience wrapper.
689  ModRefInfo getModRefInfo(const CallBase *Call, const Value *P,
690  LocationSize Size) {
691  return getModRefInfo(Call, MemoryLocation(P, Size));
692  }
693 
694  /// getModRefInfo (for loads) - Return information about whether
695  /// a particular load modifies or reads the specified memory location.
696  ModRefInfo getModRefInfo(const LoadInst *L, const MemoryLocation &Loc);
697 
698  /// getModRefInfo (for loads) - A convenience wrapper.
700  LocationSize Size) {
701  return getModRefInfo(L, MemoryLocation(P, Size));
702  }
703 
704  /// getModRefInfo (for stores) - Return information about whether
705  /// a particular store modifies or reads the specified memory location.
706  ModRefInfo getModRefInfo(const StoreInst *S, const MemoryLocation &Loc);
707 
708  /// getModRefInfo (for stores) - A convenience wrapper.
710  LocationSize Size) {
711  return getModRefInfo(S, MemoryLocation(P, Size));
712  }
713 
714  /// getModRefInfo (for fences) - Return information about whether
715  /// a particular store modifies or reads the specified memory location.
716  ModRefInfo getModRefInfo(const FenceInst *S, const MemoryLocation &Loc);
717 
718  /// getModRefInfo (for fences) - A convenience wrapper.
720  LocationSize Size) {
721  return getModRefInfo(S, MemoryLocation(P, Size));
722  }
723 
724  /// getModRefInfo (for cmpxchges) - Return information about whether
725  /// a particular cmpxchg modifies or reads the specified memory location.
727  const MemoryLocation &Loc);
728 
729  /// getModRefInfo (for cmpxchges) - A convenience wrapper.
731  LocationSize Size) {
732  return getModRefInfo(CX, MemoryLocation(P, Size));
733  }
734 
735  /// getModRefInfo (for atomicrmws) - Return information about whether
736  /// a particular atomicrmw modifies or reads the specified memory location.
737  ModRefInfo getModRefInfo(const AtomicRMWInst *RMW, const MemoryLocation &Loc);
738 
739  /// getModRefInfo (for atomicrmws) - A convenience wrapper.
741  LocationSize Size) {
742  return getModRefInfo(RMW, MemoryLocation(P, Size));
743  }
744 
745  /// getModRefInfo (for va_args) - Return information about whether
746  /// a particular va_arg modifies or reads the specified memory location.
747  ModRefInfo getModRefInfo(const VAArgInst *I, const MemoryLocation &Loc);
748 
749  /// getModRefInfo (for va_args) - A convenience wrapper.
751  LocationSize Size) {
752  return getModRefInfo(I, MemoryLocation(P, Size));
753  }
754 
755  /// getModRefInfo (for catchpads) - Return information about whether
756  /// a particular catchpad modifies or reads the specified memory location.
758 
759  /// getModRefInfo (for catchpads) - A convenience wrapper.
761  LocationSize Size) {
762  return getModRefInfo(I, MemoryLocation(P, Size));
763  }
764 
765  /// getModRefInfo (for catchrets) - Return information about whether
766  /// a particular catchret modifies or reads the specified memory location.
768 
769  /// getModRefInfo (for catchrets) - A convenience wrapper.
771  LocationSize Size) {
772  return getModRefInfo(I, MemoryLocation(P, Size));
773  }
774 
775  /// Check whether or not an instruction may read or write the optionally
776  /// specified memory location.
777  ///
778  ///
779  /// An instruction that doesn't read or write memory may be trivially LICM'd
780  /// for example.
781  ///
782  /// For function calls, this delegates to the alias-analysis specific
783  /// call-site mod-ref behavior queries. Otherwise it delegates to the specific
784  /// helpers above.
786  const Optional<MemoryLocation> &OptLoc) {
787  SimpleAAQueryInfo AAQIP;
788  return getModRefInfo(I, OptLoc, AAQIP);
789  }
790 
791  /// A convenience wrapper for constructing the memory location.
793  LocationSize Size) {
794  return getModRefInfo(I, MemoryLocation(P, Size));
795  }
796 
797  /// Return information about whether a call and an instruction may refer to
798  /// the same memory locations.
800 
801  /// Return information about whether two call sites may refer to the same set
802  /// of memory locations. See the AA documentation for details:
803  /// http://llvm.org/docs/AliasAnalysis.html#ModRefInfo
804  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2);
805 
806  /// Return information about whether a particular call site modifies
807  /// or reads the specified memory location \p MemLoc before instruction \p I
808  /// in a BasicBlock.
810  const MemoryLocation &MemLoc,
811  DominatorTree *DT) {
812  SimpleAAQueryInfo AAQIP;
813  return callCapturesBefore(I, MemLoc, DT, AAQIP);
814  }
815 
816  /// A convenience wrapper to synthesize a memory location.
818  LocationSize Size, DominatorTree *DT) {
819  return callCapturesBefore(I, MemoryLocation(P, Size), DT);
820  }
821 
822  /// @}
823  //===--------------------------------------------------------------------===//
824  /// \name Higher level methods for querying mod/ref information.
825  /// @{
826 
827  /// Check if it is possible for execution of the specified basic block to
828  /// modify the location Loc.
829  bool canBasicBlockModify(const BasicBlock &BB, const MemoryLocation &Loc);
830 
831  /// A convenience wrapper synthesizing a memory location.
832  bool canBasicBlockModify(const BasicBlock &BB, const Value *P,
833  LocationSize Size) {
834  return canBasicBlockModify(BB, MemoryLocation(P, Size));
835  }
836 
837  /// Check if it is possible for the execution of the specified instructions
838  /// to mod\ref (according to the mode) the location Loc.
839  ///
840  /// The instructions to consider are all of the instructions in the range of
841  /// [I1,I2] INCLUSIVE. I1 and I2 must be in the same basic block.
842  bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2,
843  const MemoryLocation &Loc,
844  const ModRefInfo Mode);
845 
846  /// A convenience wrapper synthesizing a memory location.
848  const Value *Ptr, LocationSize Size,
849  const ModRefInfo Mode) {
850  return canInstructionRangeModRef(I1, I2, MemoryLocation(Ptr, Size), Mode);
851  }
852 
853 private:
854  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
855  AAQueryInfo &AAQI);
856  bool pointsToConstantMemory(const MemoryLocation &Loc, AAQueryInfo &AAQI,
857  bool OrLocal = false);
859  AAQueryInfo &AAQIP);
860  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
861  AAQueryInfo &AAQI);
862  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
863  AAQueryInfo &AAQI);
864  ModRefInfo getModRefInfo(const VAArgInst *V, const MemoryLocation &Loc,
865  AAQueryInfo &AAQI);
866  ModRefInfo getModRefInfo(const LoadInst *L, const MemoryLocation &Loc,
867  AAQueryInfo &AAQI);
869  AAQueryInfo &AAQI);
871  AAQueryInfo &AAQI);
873  const MemoryLocation &Loc, AAQueryInfo &AAQI);
874  ModRefInfo getModRefInfo(const AtomicRMWInst *RMW, const MemoryLocation &Loc,
875  AAQueryInfo &AAQI);
877  AAQueryInfo &AAQI);
879  AAQueryInfo &AAQI);
881  const Optional<MemoryLocation> &OptLoc,
882  AAQueryInfo &AAQIP);
884  const MemoryLocation &MemLoc, DominatorTree *DT,
885  AAQueryInfo &AAQIP);
886 
887  class Concept;
888 
889  template <typename T> class Model;
890 
891  template <typename T> friend class AAResultBase;
892 
893  const TargetLibraryInfo &TLI;
894 
895  std::vector<std::unique_ptr<Concept>> AAs;
896 
897  std::vector<AnalysisKey *> AADeps;
898 
899  friend class BatchAAResults;
900 };
901 
902 /// This class is a wrapper over an AAResults, and it is intended to be used
903 /// only when there are no IR changes inbetween queries. BatchAAResults is
904 /// reusing the same `AAQueryInfo` to preserve the state across queries,
905 /// esentially making AA work in "batch mode". The internal state cannot be
906 /// cleared, so to go "out-of-batch-mode", the user must either use AAResults,
907 /// or create a new BatchAAResults.
909  AAResults &AA;
910  AAQueryInfo AAQI;
911  SimpleCaptureInfo SimpleCI;
912 
913 public:
914  BatchAAResults(AAResults &AAR) : AA(AAR), AAQI(&SimpleCI) {}
915  BatchAAResults(AAResults &AAR, CaptureInfo *CI) : AA(AAR), AAQI(CI) {}
916 
917  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
918  return AA.alias(LocA, LocB, AAQI);
919  }
920  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal = false) {
921  return AA.pointsToConstantMemory(Loc, AAQI, OrLocal);
922  }
923  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc) {
924  return AA.getModRefInfo(Call, Loc, AAQI);
925  }
926  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2) {
927  return AA.getModRefInfo(Call1, Call2, AAQI);
928  }
930  const Optional<MemoryLocation> &OptLoc) {
931  return AA.getModRefInfo(I, OptLoc, AAQI);
932  }
934  return AA.getModRefInfo(I, Call2, AAQI);
935  }
936  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
937  return AA.getArgModRefInfo(Call, ArgIdx);
938  }
940  return AA.getModRefBehavior(Call);
941  }
942  bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
943  return alias(LocA, LocB) == AliasResult::MustAlias;
944  }
945  bool isMustAlias(const Value *V1, const Value *V2) {
949  }
951  const MemoryLocation &MemLoc,
952  DominatorTree *DT) {
953  return AA.callCapturesBefore(I, MemLoc, DT, AAQI);
954  }
955 };
956 
957 /// Temporary typedef for legacy code that uses a generic \c AliasAnalysis
958 /// pointer or reference.
960 
961 /// A private abstract base class describing the concept of an individual alias
962 /// analysis implementation.
963 ///
964 /// This interface is implemented by any \c Model instantiation. It is also the
965 /// interface which a type used to instantiate the model must provide.
966 ///
967 /// All of these methods model methods by the same name in the \c
968 /// AAResults class. Only differences and specifics to how the
969 /// implementations are called are documented here.
971 public:
972  virtual ~Concept() = 0;
973 
974  /// An update API used internally by the AAResults to provide
975  /// a handle back to the top level aggregation.
976  virtual void setAAResults(AAResults *NewAAR) = 0;
977 
978  //===--------------------------------------------------------------------===//
979  /// \name Alias Queries
980  /// @{
981 
982  /// The main low level interface to the alias analysis implementation.
983  /// Returns an AliasResult indicating whether the two pointers are aliased to
984  /// each other. This is the interface that must be implemented by specific
985  /// alias analysis implementations.
986  virtual AliasResult alias(const MemoryLocation &LocA,
987  const MemoryLocation &LocB, AAQueryInfo &AAQI) = 0;
988 
989  /// Checks whether the given location points to constant memory, or if
990  /// \p OrLocal is true whether it points to a local alloca.
991  virtual bool pointsToConstantMemory(const MemoryLocation &Loc,
992  AAQueryInfo &AAQI, bool OrLocal) = 0;
993 
994  /// @}
995  //===--------------------------------------------------------------------===//
996  /// \name Simple mod/ref information
997  /// @{
998 
999  /// Get the ModRef info associated with a pointer argument of a callsite. The
1000  /// result's bits are set to indicate the allowed aliasing ModRef kinds. Note
1001  /// that these bits do not necessarily account for the overall behavior of
1002  /// the function, but rather only provide additional per-argument
1003  /// information.
1004  virtual ModRefInfo getArgModRefInfo(const CallBase *Call,
1005  unsigned ArgIdx) = 0;
1006 
1007  /// Return the behavior of the given call site.
1008  virtual FunctionModRefBehavior getModRefBehavior(const CallBase *Call) = 0;
1009 
1010  /// Return the behavior when calling the given function.
1011  virtual FunctionModRefBehavior getModRefBehavior(const Function *F) = 0;
1012 
1013  /// getModRefInfo (for call sites) - Return information about whether
1014  /// a particular call site modifies or reads the specified memory location.
1015  virtual ModRefInfo getModRefInfo(const CallBase *Call,
1016  const MemoryLocation &Loc,
1017  AAQueryInfo &AAQI) = 0;
1018 
1019  /// Return information about whether two call sites may refer to the same set
1020  /// of memory locations. See the AA documentation for details:
1021  /// http://llvm.org/docs/AliasAnalysis.html#ModRefInfo
1022  virtual ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
1023  AAQueryInfo &AAQI) = 0;
1024 
1025  /// @}
1026 };
1027 
1028 /// A private class template which derives from \c Concept and wraps some other
1029 /// type.
1030 ///
1031 /// This models the concept by directly forwarding each interface point to the
1032 /// wrapped type which must implement a compatible interface. This provides
1033 /// a type erased binding.
1034 template <typename AAResultT> class AAResults::Model final : public Concept {
1035  AAResultT &Result;
1036 
1037 public:
1038  explicit Model(AAResultT &Result, AAResults &AAR) : Result(Result) {
1039  Result.setAAResults(&AAR);
1040  }
1041  ~Model() override = default;
1042 
1043  void setAAResults(AAResults *NewAAR) override { Result.setAAResults(NewAAR); }
1044 
1045  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
1046  AAQueryInfo &AAQI) override {
1047  return Result.alias(LocA, LocB, AAQI);
1048  }
1049 
1050  bool pointsToConstantMemory(const MemoryLocation &Loc, AAQueryInfo &AAQI,
1051  bool OrLocal) override {
1052  return Result.pointsToConstantMemory(Loc, AAQI, OrLocal);
1053  }
1054 
1055  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) override {
1056  return Result.getArgModRefInfo(Call, ArgIdx);
1057  }
1058 
1059  FunctionModRefBehavior getModRefBehavior(const CallBase *Call) override {
1060  return Result.getModRefBehavior(Call);
1061  }
1062 
1063  FunctionModRefBehavior getModRefBehavior(const Function *F) override {
1064  return Result.getModRefBehavior(F);
1065  }
1066 
1067  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
1068  AAQueryInfo &AAQI) override {
1069  return Result.getModRefInfo(Call, Loc, AAQI);
1070  }
1071 
1072  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
1073  AAQueryInfo &AAQI) override {
1074  return Result.getModRefInfo(Call1, Call2, AAQI);
1075  }
1076 };
1077 
1078 /// A CRTP-driven "mixin" base class to help implement the function alias
1079 /// analysis results concept.
1080 ///
1081 /// Because of the nature of many alias analysis implementations, they often
1082 /// only implement a subset of the interface. This base class will attempt to
1083 /// implement the remaining portions of the interface in terms of simpler forms
1084 /// of the interface where possible, and otherwise provide conservatively
1085 /// correct fallback implementations.
1086 ///
1087 /// Implementors of an alias analysis should derive from this CRTP, and then
1088 /// override specific methods that they wish to customize. There is no need to
1089 /// use virtual anywhere, the CRTP base class does static dispatch to the
1090 /// derived type passed into it.
1091 template <typename DerivedT> class AAResultBase {
1092  // Expose some parts of the interface only to the AAResults::Model
1093  // for wrapping. Specifically, this allows the model to call our
1094  // setAAResults method without exposing it as a fully public API.
1095  friend class AAResults::Model<DerivedT>;
1096 
1097  /// A pointer to the AAResults object that this AAResult is
1098  /// aggregated within. May be null if not aggregated.
1099  AAResults *AAR = nullptr;
1100 
1101  /// Helper to dispatch calls back through the derived type.
1102  DerivedT &derived() { return static_cast<DerivedT &>(*this); }
1103 
1104  /// A setter for the AAResults pointer, which is used to satisfy the
1105  /// AAResults::Model contract.
1106  void setAAResults(AAResults *NewAAR) { AAR = NewAAR; }
1107 
1108 protected:
1109  /// This proxy class models a common pattern where we delegate to either the
1110  /// top-level \c AAResults aggregation if one is registered, or to the
1111  /// current result if none are registered.
1113  AAResults *AAR;
1114  DerivedT &CurrentResult;
1115 
1116  public:
1117  AAResultsProxy(AAResults *AAR, DerivedT &CurrentResult)
1118  : AAR(AAR), CurrentResult(CurrentResult) {}
1119 
1121  AAQueryInfo &AAQI) {
1122  return AAR ? AAR->alias(LocA, LocB, AAQI)
1123  : CurrentResult.alias(LocA, LocB, AAQI);
1124  }
1125 
1127  bool OrLocal) {
1128  return AAR ? AAR->pointsToConstantMemory(Loc, AAQI, OrLocal)
1129  : CurrentResult.pointsToConstantMemory(Loc, AAQI, OrLocal);
1130  }
1131 
1132  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
1133  return AAR ? AAR->getArgModRefInfo(Call, ArgIdx)
1134  : CurrentResult.getArgModRefInfo(Call, ArgIdx);
1135  }
1136 
1138  return AAR ? AAR->getModRefBehavior(Call)
1139  : CurrentResult.getModRefBehavior(Call);
1140  }
1141 
1143  return AAR ? AAR->getModRefBehavior(F) : CurrentResult.getModRefBehavior(F);
1144  }
1145 
1147  AAQueryInfo &AAQI) {
1148  return AAR ? AAR->getModRefInfo(Call, Loc, AAQI)
1149  : CurrentResult.getModRefInfo(Call, Loc, AAQI);
1150  }
1151 
1152  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
1153  AAQueryInfo &AAQI) {
1154  return AAR ? AAR->getModRefInfo(Call1, Call2, AAQI)
1155  : CurrentResult.getModRefInfo(Call1, Call2, AAQI);
1156  }
1157  };
1158 
1159  explicit AAResultBase() = default;
1160 
1161  // Provide all the copy and move constructors so that derived types aren't
1162  // constrained.
1165 
1166  /// Get a proxy for the best AA result set to query at this time.
1167  ///
1168  /// When this result is part of a larger aggregation, this will proxy to that
1169  /// aggregation. When this result is used in isolation, it will just delegate
1170  /// back to the derived class's implementation.
1171  ///
1172  /// Note that callers of this need to take considerable care to not cause
1173  /// performance problems when they use this routine, in the case of a large
1174  /// number of alias analyses being aggregated, it can be expensive to walk
1175  /// back across the chain.
1176  AAResultsProxy getBestAAResults() { return AAResultsProxy(AAR, derived()); }
1177 
1178 public:
1180  AAQueryInfo &AAQI) {
1181  return AliasResult::MayAlias;
1182  }
1183 
1185  bool OrLocal) {
1186  return false;
1187  }
1188 
1189  ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
1190  return ModRefInfo::ModRef;
1191  }
1192 
1195  }
1196 
1199  }
1200 
1202  AAQueryInfo &AAQI) {
1203  return ModRefInfo::ModRef;
1204  }
1205 
1206  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
1207  AAQueryInfo &AAQI) {
1208  return ModRefInfo::ModRef;
1209  }
1210 };
1211 
1212 /// Return true if this pointer is returned by a noalias function.
1213 bool isNoAliasCall(const Value *V);
1214 
1215 /// Return true if this pointer refers to a distinct and identifiable object.
1216 /// This returns true for:
1217 /// Global Variables and Functions (but not Global Aliases)
1218 /// Allocas
1219 /// ByVal and NoAlias Arguments
1220 /// NoAlias returns (e.g. calls to malloc)
1221 ///
1222 bool isIdentifiedObject(const Value *V);
1223 
1224 /// Return true if V is umabigously identified at the function-level.
1225 /// Different IdentifiedFunctionLocals can't alias.
1226 /// Further, an IdentifiedFunctionLocal can not alias with any function
1227 /// arguments other than itself, which is not necessarily true for
1228 /// IdentifiedObjects.
1229 bool isIdentifiedFunctionLocal(const Value *V);
1230 
1231 /// Returns true if the pointer is one which would have been considered an
1232 /// escape by isNonEscapingLocalObject.
1233 bool isEscapeSource(const Value *V);
1234 
1235 /// Return true if Object memory is not visible after an unwind, in the sense
1236 /// that program semantics cannot depend on Object containing any particular
1237 /// value on unwind. If the RequiresNoCaptureBeforeUnwind out parameter is set
1238 /// to true, then the memory is only not visible if the object has not been
1239 /// captured prior to the unwind. Otherwise it is not visible even if captured.
1240 bool isNotVisibleOnUnwind(const Value *Object,
1241  bool &RequiresNoCaptureBeforeUnwind);
1242 
1243 /// A manager for alias analyses.
1244 ///
1245 /// This class can have analyses registered with it and when run, it will run
1246 /// all of them and aggregate their results into single AA results interface
1247 /// that dispatches across all of the alias analysis results available.
1248 ///
1249 /// Note that the order in which analyses are registered is very significant.
1250 /// That is the order in which the results will be aggregated and queried.
1251 ///
1252 /// This manager effectively wraps the AnalysisManager for registering alias
1253 /// analyses. When you register your alias analysis with this manager, it will
1254 /// ensure the analysis itself is registered with its AnalysisManager.
1255 ///
1256 /// The result of this analysis is only invalidated if one of the particular
1257 /// aggregated AA results end up being invalidated. This removes the need to
1258 /// explicitly preserve the results of `AAManager`. Note that analyses should no
1259 /// longer be registered once the `AAManager` is run.
1260 class AAManager : public AnalysisInfoMixin<AAManager> {
1261 public:
1263 
1264  /// Register a specific AA result.
1265  template <typename AnalysisT> void registerFunctionAnalysis() {
1266  ResultGetters.push_back(&getFunctionAAResultImpl<AnalysisT>);
1267  }
1268 
1269  /// Register a specific AA result.
1270  template <typename AnalysisT> void registerModuleAnalysis() {
1271  ResultGetters.push_back(&getModuleAAResultImpl<AnalysisT>);
1272  }
1273 
1275 
1276 private:
1278 
1279  static AnalysisKey Key;
1280 
1282  AAResults &AAResults),
1283  4> ResultGetters;
1284 
1285  template <typename AnalysisT>
1286  static void getFunctionAAResultImpl(Function &F,
1288  AAResults &AAResults) {
1289  AAResults.addAAResult(AM.template getResult<AnalysisT>(F));
1291  }
1292 
1293  template <typename AnalysisT>
1294  static void getModuleAAResultImpl(Function &F, FunctionAnalysisManager &AM,
1295  AAResults &AAResults) {
1296  auto &MAMProxy = AM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
1297  if (auto *R =
1298  MAMProxy.template getCachedResult<AnalysisT>(*F.getParent())) {
1299  AAResults.addAAResult(*R);
1300  MAMProxy
1301  .template registerOuterAnalysisInvalidation<AnalysisT, AAManager>();
1302  }
1303  }
1304 };
1305 
1306 /// A wrapper pass to provide the legacy pass manager access to a suitably
1307 /// prepared AAResults object.
1309  std::unique_ptr<AAResults> AAR;
1310 
1311 public:
1312  static char ID;
1313 
1315 
1316  AAResults &getAAResults() { return *AAR; }
1317  const AAResults &getAAResults() const { return *AAR; }
1318 
1319  bool runOnFunction(Function &F) override;
1320 
1321  void getAnalysisUsage(AnalysisUsage &AU) const override;
1322 };
1323 
1324 /// A wrapper pass for external alias analyses. This just squirrels away the
1325 /// callback used to run any analyses and register their results.
1328 
1330 
1331  static char ID;
1332 
1334 
1336 
1337  void getAnalysisUsage(AnalysisUsage &AU) const override {
1338  AU.setPreservesAll();
1339  }
1340 };
1341 
1342 FunctionPass *createAAResultsWrapperPass();
1343 
1344 /// A wrapper pass around a callback which can be used to populate the
1345 /// AAResults in the AAResultsWrapperPass from an external AA.
1346 ///
1347 /// The callback provided here will be used each time we prepare an AAResults
1348 /// object, and will receive a reference to the function wrapper pass, the
1349 /// function, and the AAResults object to populate. This should be used when
1350 /// setting up a custom pass pipeline to inject a hook into the AA results.
1351 ImmutablePass *createExternalAAWrapperPass(
1352  std::function<void(Pass &, Function &, AAResults &)> Callback);
1353 
1354 /// A helper for the legacy pass manager to create a \c AAResults
1355 /// object populated to the best of our ability for a particular function when
1356 /// inside of a \c ModulePass or a \c CallGraphSCCPass.
1357 ///
1358 /// If a \c ModulePass or a \c CallGraphSCCPass calls \p
1359 /// createLegacyPMAAResults, it also needs to call \p addUsedAAAnalyses in \p
1360 /// getAnalysisUsage.
1361 AAResults createLegacyPMAAResults(Pass &P, Function &F, BasicAAResult &BAR);
1362 
1363 /// A helper for the legacy pass manager to populate \p AU to add uses to make
1364 /// sure the analyses required by \p createLegacyPMAAResults are available.
1365 void getAAResultsAnalysisUsage(AnalysisUsage &AU);
1366 
1367 } // end namespace llvm
1368 
1369 #endif // LLVM_ANALYSIS_ALIASANALYSIS_H
llvm::AAResults::addAAResult
void addAAResult(AAResultT &AAResult)
Register a specific AA result.
Definition: AliasAnalysis.h:527
llvm::AAResults::addAADependencyID
void addAADependencyID(AnalysisKey *ID)
Register a function analysis ID that the results aggregation depends on.
Definition: AliasAnalysis.h:539
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
llvm::BatchAAResults
This class is a wrapper over an AAResults, and it is intended to be used only when there are no IR ch...
Definition: AliasAnalysis.h:908
llvm::FunctionModRefBehavior::operator|
FunctionModRefBehavior operator|(FunctionModRefBehavior Other) const
Union with another FunctionModRefBehavior.
Definition: AliasAnalysis.h:364
llvm::AAQueryInfo::CacheEntry::NumAssumptionUses
int NumAssumptionUses
Number of times a NoAlias assumption has been used.
Definition: AliasAnalysis.h:476
llvm::AAResultBase::AAResultsProxy::pointsToConstantMemory
bool pointsToConstantMemory(const MemoryLocation &Loc, AAQueryInfo &AAQI, bool OrLocal)
Definition: AliasAnalysis.h:1126
llvm::ModRefInfo::NoModRef
@ NoModRef
The access neither references nor modifies the value stored in memory.
llvm::enum_seq_inclusive
auto enum_seq_inclusive(EnumT Begin, EnumT End)
Iterate over an enum type from Begin to End inclusive.
Definition: Sequence.h:354
llvm::AAManager
A manager for alias analyses.
Definition: AliasAnalysis.h:1260
llvm::AliasResult::MayAlias
@ MayAlias
The two locations may or may not alias.
Definition: AliasAnalysis.h:103
llvm::FunctionModRefBehavior::operator<<
friend raw_ostream & operator<<(raw_ostream &OS, FunctionModRefBehavior RMRB)
Debug print FunctionModRefBehavior.
llvm::EarliestEscapeInfo::removeInstruction
void removeInstruction(Instruction *I)
Definition: BasicAliasAnalysis.cpp:228
llvm::AliasResult::PartialAlias
@ PartialAlias
The two locations alias, but only due to a partial overlap.
Definition: AliasAnalysis.h:105
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::ExternalAAWrapperPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition: AliasAnalysis.h:1337
Pass
print lazy value Lazy Value Info Printer Pass
Definition: LazyValueInfo.cpp:1979
llvm::AAResults::Concept::getArgModRefInfo
virtual ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx)=0
Get the ModRef info associated with a pointer argument of a callsite.
llvm::SimpleCaptureInfo
Context-free CaptureInfo provider, which computes and caches whether an object is captured in the fun...
Definition: AliasAnalysis.h:398
llvm::ExternalAAWrapperPass::ExternalAAWrapperPass
ExternalAAWrapperPass()
Definition: AliasAnalysis.cpp:791
llvm::VAArgInst
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
Definition: Instructions.h:1832
Optional.h
llvm::FunctionModRefBehavior::getWithModRef
FunctionModRefBehavior getWithModRef(Location Loc, ModRefInfo MR) const
Get new FunctionModRefBehavior with modified ModRefInfo for Loc.
Definition: AliasAnalysis.h:301
llvm::CaptureInfo
Virtual base class for providers of capture information.
Definition: AliasAnalysis.h:389
llvm::ImmutablePass
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:279
llvm::AAResults::Concept::pointsToConstantMemory
virtual bool pointsToConstantMemory(const MemoryLocation &Loc, AAQueryInfo &AAQI, bool OrLocal)=0
Checks whether the given location points to constant memory, or if OrLocal is true whether it points ...
llvm::ModuleAnalysisManagerFunctionProxy
OuterAnalysisManagerProxy< ModuleAnalysisManager, Function > ModuleAnalysisManagerFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
Definition: PassManager.h:1168
llvm::Function
Definition: Function.h:60
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
Pass.h
llvm::AAResults::canBasicBlockModify
bool canBasicBlockModify(const BasicBlock &BB, const Value *P, LocationSize Size)
A convenience wrapper synthesizing a memory location.
Definition: AliasAnalysis.h:832
llvm::AAResults::invalidate
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)
Handle invalidation events in the new pass manager.
Definition: AliasAnalysis.cpp:95
llvm::FunctionModRefBehavior::readOnly
static FunctionModRefBehavior readOnly()
Create FunctionModRefBehavior that can read any memory.
Definition: AliasAnalysis.h:267
llvm::createAAResultsWrapperPass
FunctionPass * createAAResultsWrapperPass()
Definition: AliasAnalysis.cpp:830
llvm::FunctionModRefBehavior::none
static FunctionModRefBehavior none()
Create FunctionModRefBehavior that cannot read or write any memory.
Definition: AliasAnalysis.h:262
llvm::SmallVector< AAQueryInfo::LocPair, 4 >
llvm::FunctionModRefBehavior::InaccessibleMem
@ InaccessibleMem
Memory that is inaccessible via LLVM IR.
Definition: AliasAnalysis.h:215
llvm::BatchAAResults::getModRefInfo
ModRefInfo getModRefInfo(const Instruction *I, const Optional< MemoryLocation > &OptLoc)
Definition: AliasAnalysis.h:929
llvm::EarliestEscapeInfo
Context-sensitive CaptureInfo provider, which computes and caches the earliest common dominator closu...
Definition: AliasAnalysis.h:409
llvm::FunctionModRefBehavior::operator&=
FunctionModRefBehavior & operator&=(FunctionModRefBehavior Other)
Intersect (in-place) with another FunctionModRefBehavior.
Definition: AliasAnalysis.h:358
llvm::AAResults::Concept::~Concept
virtual ~Concept()=0
llvm::AAResults::isNoAlias
bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A trivial helper function to check to see if the specified pointers are no-alias.
Definition: AliasAnalysis.h:572
llvm::isModSet
bool isModSet(const ModRefInfo MRI)
Definition: AliasAnalysis.h:168
llvm::SmallDenseMap
Definition: DenseMap.h:880
llvm::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:166
llvm::clearMod
ModRefInfo clearMod(const ModRefInfo MRI)
Definition: AliasAnalysis.h:184
llvm::FunctionModRefBehavior::onlyWritesMemory
bool onlyWritesMemory() const
Whether this function only (at most) writes memory.
Definition: AliasAnalysis.h:329
llvm::SimpleAAQueryInfo
AAQueryInfo that uses SimpleCaptureInfo.
Definition: AliasAnalysis.h:509
llvm::BatchAAResults::pointsToConstantMemory
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal=false)
Definition: AliasAnalysis.h:920
DenseMap.h
llvm::FunctionModRefBehavior::doesAccessArgPointees
bool doesAccessArgPointees() const
Whether this function may access argument memory.
Definition: AliasAnalysis.h:337
llvm::AAResults::getModRefInfo
ModRefInfo getModRefInfo(const StoreInst *S, const Value *P, LocationSize Size)
getModRefInfo (for stores) - A convenience wrapper.
Definition: AliasAnalysis.h:709
llvm::AAResults::Concept::getModRefInfo
virtual ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc, AAQueryInfo &AAQI)=0
getModRefInfo (for call sites) - Return information about whether a particular call site modifies or ...
llvm::AAResultBase::AAResultsProxy
This proxy class models a common pattern where we delegate to either the top-level AAResults aggregat...
Definition: AliasAnalysis.h:1112
llvm::AAQueryInfo::CacheEntry::isDefinitive
bool isDefinitive() const
Whether this is a definitive (non-assumption) result.
Definition: AliasAnalysis.h:478
llvm::isModOrRefSet
bool isModOrRefSet(const ModRefInfo MRI)
Definition: AliasAnalysis.h:162
llvm::FunctionModRefBehavior::getModRef
ModRefInfo getModRef() const
Get ModRefInfo for any location.
Definition: AliasAnalysis.h:315
llvm::Optional
Definition: APInt.h:33
llvm::AACacheLoc::Size
LocationSize Size
Definition: AliasAnalysis.h:440
llvm::FenceInst
An instruction for ordering other memory operations.
Definition: Instructions.h:433
llvm::AliasResult
The possible results of an alias query.
Definition: AliasAnalysis.h:82
llvm::FunctionModRefBehavior::Other
@ Other
Any other memory.
Definition: AliasAnalysis.h:217
llvm::DenseMapInfo< AACacheLoc >::getHashValue
static unsigned getHashValue(const AACacheLoc &Val)
Definition: AliasAnalysis.h:452
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
Sequence.h
llvm::BatchAAResults::getModRefInfo
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc)
Definition: AliasAnalysis.h:923
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::BatchAAResults::getModRefBehavior
FunctionModRefBehavior getModRefBehavior(const CallBase *Call)
Definition: AliasAnalysis.h:939
llvm::AAResults::getModRefInfo
ModRefInfo getModRefInfo(const Instruction *I, const Value *P, LocationSize Size)
A convenience wrapper for constructing the memory location.
Definition: AliasAnalysis.h:792
llvm::getAAResultsAnalysisUsage
void getAAResultsAnalysisUsage(AnalysisUsage &AU)
A helper for the legacy pass manager to populate AU to add uses to make sure the analyses required by...
Definition: AliasAnalysis.cpp:1015
llvm::FunctionModRefBehavior::getWithoutLoc
FunctionModRefBehavior getWithoutLoc(Location Loc) const
Get new FunctionModRefBehavior with NoModRef on the given Loc.
Definition: AliasAnalysis.h:308
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
llvm::Reloc::Model
Model
Definition: CodeGen.h:22
llvm::AAResults::Concept::alias
virtual AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB, AAQueryInfo &AAQI)=0
The main low level interface to the alias analysis implementation.
llvm::isIdentifiedFunctionLocal
bool isIdentifiedFunctionLocal(const Value *V)
Return true if V is umabigously identified at the function-level.
Definition: AliasAnalysis.cpp:966
llvm::AAResults::AAResults
AAResults(const TargetLibraryInfo &TLI)
Definition: AliasAnalysis.h:522
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:186
llvm::FunctionModRefBehavior::unknown
static FunctionModRefBehavior unknown()
Create FunctionModRefBehavior that can read and write any memory.
Definition: AliasAnalysis.h:257
llvm::AAQueryInfo
This class stores info we want to provide to or retain within an alias query.
Definition: AliasAnalysis.h:469
LHS
Value * LHS
Definition: X86PartialReduction.cpp:75
llvm::DenseMapInfo
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: APInt.h:34
llvm::AAResultBase::AAResultsProxy::getModRefBehavior
FunctionModRefBehavior getModRefBehavior(const Function *F)
Definition: AliasAnalysis.h:1142
llvm::AAResultBase::AAResultBase
AAResultBase()=default
llvm::CaptureInfo::~CaptureInfo
virtual ~CaptureInfo()=0
llvm::FunctionModRefBehavior::operator!=
bool operator!=(FunctionModRefBehavior Other) const
Check whether this is different from another FunctionModRefBehavior.
Definition: AliasAnalysis.h:380
llvm::BatchAAResults::getModRefInfo
ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2)
Definition: AliasAnalysis.h:926
llvm::isNoAliasCall
bool isNoAliasCall(const Value *V)
Return true if this pointer is returned by a noalias function.
Definition: AliasAnalysis.cpp:942
llvm::AAResults::pointsToConstantMemory
bool pointsToConstantMemory(const Value *P, bool OrLocal=false)
A convenience wrapper around the primary pointsToConstantMemory interface.
Definition: AliasAnalysis.h:606
llvm::AAResultsWrapperPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition: AliasAnalysis.cpp:886
llvm::AAResults::onlyReadsMemory
bool onlyReadsMemory(const CallBase *Call)
Checks if the specified call is known to only read from non-volatile memory (or not access memory at ...
Definition: AliasAnalysis.h:667
llvm::ModRefInfo::Ref
@ Ref
The access may reference the value stored in memory.
llvm::AAResults
Definition: AliasAnalysis.h:518
llvm::ExternalAAWrapperPass::CB
CallbackT CB
Definition: AliasAnalysis.h:1329
llvm::LocationSize
Definition: MemoryLocation.h:66
llvm::FunctionModRefBehavior::argMemOnly
static FunctionModRefBehavior argMemOnly(ModRefInfo MR)
Create FunctionModRefBehavior that can only access argument memory.
Definition: AliasAnalysis.h:277
llvm::EarliestEscapeInfo::isNotCapturedBeforeOrAt
bool isNotCapturedBeforeOrAt(const Value *Object, const Instruction *I) override
Definition: BasicAliasAnalysis.cpp:203
llvm::FunctionModRefBehavior::inaccessibleMemOnly
static FunctionModRefBehavior inaccessibleMemOnly(ModRefInfo MR)
Create FunctionModRefBehavior that can only access inaccessible memory.
Definition: AliasAnalysis.h:282
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::FunctionModRefBehavior::onlyAccessesInaccessibleMem
bool onlyAccessesInaccessibleMem() const
Whether this function only (at most) accesses inaccessible memory.
Definition: AliasAnalysis.h:342
llvm::AliasResult::hasOffset
constexpr bool hasOffset() const
Definition: AliasAnalysis.h:118
llvm::ms_demangle::QualifierMangleMode::Result
@ Result
llvm::AAResults::getModRefInfo
ModRefInfo getModRefInfo(const VAArgInst *I, const Value *P, LocationSize Size)
getModRefInfo (for va_args) - A convenience wrapper.
Definition: AliasAnalysis.h:750
llvm::AAQueryInfo::CI
CaptureInfo * CI
Definition: AliasAnalysis.h:483
false
Definition: StackSlotColoring.cpp:141
llvm::FunctionModRefBehavior::operator==
bool operator==(FunctionModRefBehavior Other) const
Check whether this is the same as another FunctionModRefBehavior.
Definition: AliasAnalysis.h:375
llvm::AAManager::Result
AAResults Result
Definition: AliasAnalysis.h:1262
llvm::AAResults::getModRefInfo
ModRefInfo getModRefInfo(const CatchReturnInst *I, const Value *P, LocationSize Size)
getModRefInfo (for catchrets) - A convenience wrapper.
Definition: AliasAnalysis.h:770
llvm::Instruction
Definition: Instruction.h:42
llvm::AAResults::Concept
A private abstract base class describing the concept of an individual alias analysis implementation.
Definition: AliasAnalysis.h:970
llvm::ExternalAAWrapperPass::CallbackT
std::function< void(Pass &, Function &, AAResults &)> CallbackT
Definition: AliasAnalysis.h:1327
llvm::AAManager::run
Result run(Function &F, FunctionAnalysisManager &AM)
Definition: AliasAnalysis.cpp:905
llvm::operator<<
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:230
llvm::AAQueryInfo::AssumptionBasedResults
SmallVector< AAQueryInfo::LocPair, 4 > AssumptionBasedResults
Location pairs for which an assumption based result is currently stored.
Definition: AliasAnalysis.h:494
llvm::LocationSize::precise
static LocationSize precise(uint64_t Value)
Definition: MemoryLocation.h:101
llvm::BatchAAResults::getArgModRefInfo
ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx)
Definition: AliasAnalysis.h:936
llvm::BatchAAResults::BatchAAResults
BatchAAResults(AAResults &AAR, CaptureInfo *CI)
Definition: AliasAnalysis.h:915
llvm::AnalysisManager::Invalidator
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:661
llvm::FunctionModRefBehavior::onlyAccessesInaccessibleOrArgMem
bool onlyAccessesInaccessibleOrArgMem() const
Whether this function only (at most) accesses argument and inaccessible memory.
Definition: AliasAnalysis.h:348
llvm::AAResultBase::AAResultsProxy::alias
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB, AAQueryInfo &AAQI)
Definition: AliasAnalysis.h:1120
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
llvm::DenseMapInfo< AACacheLoc >::getTombstoneKey
static AACacheLoc getTombstoneKey()
Definition: AliasAnalysis.h:448
llvm::createLegacyPMAAResults
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...
Definition: AliasAnalysis.cpp:912
llvm::AliasResult::getOffset
constexpr int32_t getOffset() const
Definition: AliasAnalysis.h:119
llvm::AAResults::getModRefInfo
ModRefInfo getModRefInfo(const CatchPadInst *I, const Value *P, LocationSize Size)
getModRefInfo (for catchpads) - A convenience wrapper.
Definition: AliasAnalysis.h:760
llvm::OutputFileType::Object
@ Object
llvm::AAResultBase::alias
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB, AAQueryInfo &AAQI)
Definition: AliasAnalysis.h:1179
llvm::AAQueryInfo::LocPair
std::pair< AACacheLoc, AACacheLoc > LocPair
Definition: AliasAnalysis.h:471
llvm::AAResults::onlyReadsMemory
bool onlyReadsMemory(const Function *F)
Checks if the specified function is known to only read from non-volatile memory (or not access memory...
Definition: AliasAnalysis.h:680
llvm::CaptureInfo::isNotCapturedBeforeOrAt
virtual bool isNotCapturedBeforeOrAt(const Value *Object, const Instruction *I)=0
llvm::ExternalAAWrapperPass::ID
static char ID
Definition: AliasAnalysis.h:1331
llvm::StoreInst
An instruction for storing to memory.
Definition: Instructions.h:298
llvm::AAResults::getModRefInfo
ModRefInfo getModRefInfo(const AtomicRMWInst *RMW, const Value *P, LocationSize Size)
getModRefInfo (for atomicrmws) - A convenience wrapper.
Definition: AliasAnalysis.h:740
llvm::BatchAAResults::alias
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
Definition: AliasAnalysis.h:917
llvm::intersectModRef
ModRefInfo intersectModRef(const ModRefInfo MRI1, const ModRefInfo MRI2)
Definition: AliasAnalysis.h:196
llvm::FunctionModRefBehavior::FunctionModRefBehavior
FunctionModRefBehavior(Location Loc, ModRefInfo MR)
Create FunctionModRefBehavior that can access only the given location with the given ModRefInfo.
Definition: AliasAnalysis.h:247
llvm::CatchReturnInst
Definition: Instructions.h:4582
llvm::isModAndRefSet
bool isModAndRefSet(const ModRefInfo MRI)
Definition: AliasAnalysis.h:165
llvm::AAResultBase::getModRefBehavior
FunctionModRefBehavior getModRefBehavior(const Function *F)
Definition: AliasAnalysis.h:1197
llvm::AAQueryInfo::NumAssumptionUses
int NumAssumptionUses
How many active NoAlias assumption uses there are.
Definition: AliasAnalysis.h:489
llvm::FunctionModRefBehavior::inaccessibleOrArgMemOnly
static FunctionModRefBehavior inaccessibleOrArgMemOnly(ModRefInfo MR)
Create FunctionModRefBehavior that can only access inaccessible or argument memory.
Definition: AliasAnalysis.h:288
MemoryLocation.h
llvm::DenseMap
Definition: DenseMap.h:714
llvm::AnalysisKey
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:69
llvm::AAResults::canInstructionRangeModRef
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)...
Definition: AliasAnalysis.cpp:769
llvm::FunctionModRefBehavior::writeOnly
static FunctionModRefBehavior writeOnly()
Create FunctionModRefBehavior that can write any memory.
Definition: AliasAnalysis.h:272
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::AAResults::Concept::getModRefBehavior
virtual FunctionModRefBehavior getModRefBehavior(const CallBase *Call)=0
Return the behavior of the given call site.
llvm::AAResults::getModRefInfo
ModRefInfo getModRefInfo(const Instruction *I, const Optional< MemoryLocation > &OptLoc)
Check whether or not an instruction may read or write the optionally specified memory location.
Definition: AliasAnalysis.h:785
llvm::FunctionModRefBehavior::getModRef
ModRefInfo getModRef(Location Loc) const
Get ModRefInfo for the given Location.
Definition: AliasAnalysis.h:296
llvm::createExternalAAWrapperPass
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...
llvm::ModRefInfo
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
Definition: AliasAnalysis.h:147
llvm::AAQueryInfo::CacheEntry
Definition: AliasAnalysis.h:472
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::AliasResult::setOffset
void setOffset(int32_t NewOffset)
Definition: AliasAnalysis.h:123
llvm::AAResults::getModRefInfo
ModRefInfo getModRefInfo(const FenceInst *S, const Value *P, LocationSize Size)
getModRefInfo (for fences) - A convenience wrapper.
Definition: AliasAnalysis.h:719
Ptr
@ Ptr
Definition: TargetLibraryInfo.cpp:60
llvm::ISD::BasicBlock
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
Mode
SI Whole Quad Mode
Definition: SIWholeQuadMode.cpp:262
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:82
llvm::EarliestEscapeInfo::EarliestEscapeInfo
EarliestEscapeInfo(DominatorTree &DT, const LoopInfo &LI, const SmallPtrSetImpl< const Value * > &EphValues)
Definition: AliasAnalysis.h:426
llvm::AAResults::getModRefInfo
ModRefInfo getModRefInfo(const CallBase *Call, const Value *P, LocationSize Size)
getModRefInfo (for call sites) - A convenience wrapper.
Definition: AliasAnalysis.h:689
llvm::AnalysisInfoMixin
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:394
llvm::AAResultBase::getArgModRefInfo
ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx)
Definition: AliasAnalysis.h:1189
llvm::AAResultBase::getModRefBehavior
FunctionModRefBehavior getModRefBehavior(const CallBase *Call)
Definition: AliasAnalysis.h:1193
llvm::isEscapeSource
bool isEscapeSource(const Value *V)
Returns true if the pointer is one which would have been considered an escape by isNonEscapingLocalOb...
Definition: AliasAnalysis.cpp:970
llvm::AAResultsWrapperPass::ID
static char ID
Definition: AliasAnalysis.h:1312
llvm::AAResults::canInstructionRangeModRef
bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2, const Value *Ptr, LocationSize Size, const ModRefInfo Mode)
A convenience wrapper synthesizing a memory location.
Definition: AliasAnalysis.h:847
llvm::AAResultBase::AAResultBase
AAResultBase(AAResultBase &&Arg)
Definition: AliasAnalysis.h:1164
llvm::AAResults::isMustAlias
bool isMustAlias(const Value *V1, const Value *V2)
A convenience wrapper around the isMustAlias helper interface.
Definition: AliasAnalysis.h:595
llvm::AliasResult::swap
void swap(bool DoSwap=true)
Helper for processing AliasResult for swapped memory location pairs.
Definition: AliasAnalysis.h:131
llvm::AAResultsWrapperPass::getAAResults
const AAResults & getAAResults() const
Definition: AliasAnalysis.h:1317
llvm::LoopInfo
Definition: LoopInfo.h:1105
llvm::AAManager::registerModuleAnalysis
void registerModuleAnalysis()
Register a specific AA result.
Definition: AliasAnalysis.h:1270
llvm::AAResults::isNoAlias
bool isNoAlias(const Value *V1, LocationSize V1Size, const Value *V2, LocationSize V2Size)
A convenience wrapper around the isNoAlias helper interface.
Definition: AliasAnalysis.h:577
llvm::AACacheLoc::Ptr
const Value * Ptr
Definition: AliasAnalysis.h:439
llvm::isNotVisibleOnUnwind
bool isNotVisibleOnUnwind(const Value *Object, bool &RequiresNoCaptureBeforeUnwind)
Return true if Object memory is not visible after an unwind, in the sense that program semantics cann...
Definition: AliasAnalysis.cpp:992
llvm::BatchAAResults::BatchAAResults
BatchAAResults(AAResults &AAR)
Definition: AliasAnalysis.h:914
llvm::AAResults::~AAResults
~AAResults()
Definition: AliasAnalysis.cpp:84
uint32_t
llvm::AliasResult::NoAlias
@ NoAlias
The two locations do not alias at all.
Definition: AliasAnalysis.h:100
llvm::AAResultBase::AAResultsProxy::getArgModRefInfo
ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx)
Definition: AliasAnalysis.h:1132
llvm::ModRefInfo::Mod
@ Mod
The access may modify the value stored in memory.
llvm::FunctionModRefBehavior::operator&
FunctionModRefBehavior operator&(FunctionModRefBehavior Other) const
Intersect with another FunctionModRefBehavior.
Definition: AliasAnalysis.h:353
llvm::isRefSet
bool isRefSet(const ModRefInfo MRI)
Definition: AliasAnalysis.h:171
llvm::AliasResult::MustAlias
@ MustAlias
The two locations precisely alias each other.
Definition: AliasAnalysis.h:107
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::BatchAAResults::getModRefInfo
ModRefInfo getModRefInfo(Instruction *I, const CallBase *Call2)
Definition: AliasAnalysis.h:933
llvm::AAResults::alias
AliasResult alias(const Value *V1, const Value *V2)
A convenience wrapper around the primary alias interface.
Definition: AliasAnalysis.h:565
llvm::LoadInst
An instruction for reading from memory.
Definition: Instructions.h:174
llvm::AAQueryInfo::CacheEntry::Result
AliasResult Result
Definition: AliasAnalysis.h:473
llvm::SimpleCaptureInfo::isNotCapturedBeforeOrAt
bool isNotCapturedBeforeOrAt(const Value *Object, const Instruction *I) override
Definition: BasicAliasAnalysis.cpp:198
llvm::AAResults::isNoAlias
bool isNoAlias(const Value *V1, const Value *V2)
A convenience wrapper around the isNoAlias helper interface.
Definition: AliasAnalysis.h:583
llvm::AAResults::getModRefBehavior
FunctionModRefBehavior getModRefBehavior(const CallBase *Call)
Return the behavior of the given call site.
Definition: AliasAnalysis.cpp:388
llvm::FunctionModRefBehavior::doesNotAccessMemory
bool doesNotAccessMemory() const
Whether this function accesses no memory.
Definition: AliasAnalysis.h:323
llvm::AtomicRMWInst
an instruction that atomically reads a memory location, combines it with another value,...
Definition: Instructions.h:715
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::AliasResult::AliasResult
AliasResult()=delete
llvm::FunctionModRefBehavior
Summary of how a function affects memory in the program.
Definition: AliasAnalysis.h:208
llvm::AAResultBase::getModRefInfo
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc, AAQueryInfo &AAQI)
Definition: AliasAnalysis.h:1201
llvm::AAResults::getModRefInfo
ModRefInfo getModRefInfo(const LoadInst *L, const Value *P, LocationSize Size)
getModRefInfo (for loads) - A convenience wrapper.
Definition: AliasAnalysis.h:699
llvm::AAQueryInfo::AAQueryInfo
AAQueryInfo(CaptureInfo *CI)
Definition: AliasAnalysis.h:496
llvm::AAResultBase::AAResultsProxy::getModRefBehavior
FunctionModRefBehavior getModRefBehavior(const CallBase *Call)
Definition: AliasAnalysis.h:1137
llvm::NVPTX::PTXLdStInstCode::V2
@ V2
Definition: NVPTX.h:123
llvm::BatchAAResults::isMustAlias
bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
Definition: AliasAnalysis.h:942
llvm::AAResultBase::AAResultsProxy::getModRefInfo
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc, AAQueryInfo &AAQI)
Definition: AliasAnalysis.h:1146
llvm::isIdentifiedObject
bool isIdentifiedObject(const Value *V)
Return true if this pointer refers to a distinct and identifiable object.
Definition: AliasAnalysis.cpp:954
llvm::AAResults::doesNotAccessMemory
bool doesNotAccessMemory(const Function *F)
Checks if the specified function is known to never read or write memory.
Definition: AliasAnalysis.h:654
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition: PassAnalysisSupport.h:130
llvm::AAResultBase::AAResultsProxy::AAResultsProxy
AAResultsProxy(AAResults *AAR, DerivedT &CurrentResult)
Definition: AliasAnalysis.h:1117
llvm::AACacheLoc
Reduced version of MemoryLocation that only stores a pointer and size.
Definition: AliasAnalysis.h:438
llvm::AAResultsWrapperPass::runOnFunction
bool runOnFunction(Function &F) override
Run the wrapper pass to rebuild an aggregation over known AA passes.
Definition: AliasAnalysis.cpp:842
llvm::AAQueryInfo::AliasCache
AliasCacheT AliasCache
Definition: AliasAnalysis.h:481
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
PassManager.h
llvm::BatchAAResults::isMustAlias
bool isMustAlias(const Value *V1, const Value *V2)
Definition: AliasAnalysis.h:945
llvm::FunctionModRefBehavior::Location
Location
The locations at which a function might access memory.
Definition: AliasAnalysis.h:211
llvm::TargetLibraryInfo
Provides information about what library functions are available for the current target.
Definition: TargetLibraryInfo.h:222
llvm::AAResultBase::AAResultsProxy::getModRefInfo
ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2, AAQueryInfo &AAQI)
Definition: AliasAnalysis.h:1152
llvm::AAResults::alias
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
The main low level interface to the alias analysis implementation.
Definition: AliasAnalysis.cpp:119
llvm::AAResults::callCapturesBefore
ModRefInfo callCapturesBefore(const Instruction *I, const Value *P, LocationSize Size, DominatorTree *DT)
A convenience wrapper to synthesize a memory location.
Definition: AliasAnalysis.h:817
llvm::AAResultBase::pointsToConstantMemory
bool pointsToConstantMemory(const MemoryLocation &Loc, AAQueryInfo &AAQI, bool OrLocal)
Definition: AliasAnalysis.h:1184
llvm::AAResults::pointsToConstantMemory
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 ...
Definition: AliasAnalysis.cpp:162
llvm::DenseMapInfo< AACacheLoc >::getEmptyKey
static AACacheLoc getEmptyKey()
Definition: AliasAnalysis.h:444
llvm::force_iteration_on_noniterable_enum
constexpr force_iteration_on_noniterable_enum_t force_iteration_on_noniterable_enum
Definition: Sequence.h:108
llvm::AAManager::registerFunctionAnalysis
void registerFunctionAnalysis()
Register a specific AA result.
Definition: AliasAnalysis.h:1265
llvm::AAQueryInfo::withEmptyCache
AAQueryInfo withEmptyCache()
Create a new AAQueryInfo based on this one, but with the cache cleared.
Definition: AliasAnalysis.h:501
llvm::AAResultsWrapperPass::getAAResults
AAResults & getAAResults()
Definition: AliasAnalysis.h:1316
llvm::AliasResult::AliasResult
constexpr AliasResult(const Kind &Alias)
Definition: AliasAnalysis.h:113
llvm::AliasResult::Kind
Kind
Definition: AliasAnalysis.h:94
AA
llvm::CatchPadInst
Definition: Instructions.h:4531
llvm::AAResultsWrapperPass::AAResultsWrapperPass
AAResultsWrapperPass()
Definition: AliasAnalysis.cpp:810
llvm::FunctionModRefBehavior::onlyAccessesArgPointees
bool onlyAccessesArgPointees() const
Whether this function only (at most) accesses argument memory.
Definition: AliasAnalysis.h:332
llvm::AAResults::getArgModRefInfo
ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx)
Get the ModRef info associated with a pointer argument of a call.
Definition: AliasAnalysis.cpp:177
llvm::AAResultBase::AAResultBase
AAResultBase(const AAResultBase &Arg)
Definition: AliasAnalysis.h:1163
llvm::AAResultBase::getBestAAResults
AAResultsProxy getBestAAResults()
Get a proxy for the best AA result set to query at this time.
Definition: AliasAnalysis.h:1176
llvm::Pass
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:91
llvm::FunctionModRefBehavior::onlyReadsMemory
bool onlyReadsMemory() const
Whether this function only (at most) reads memory.
Definition: AliasAnalysis.h:326
llvm::AAResults::doesNotAccessMemory
bool doesNotAccessMemory(const CallBase *Call)
Checks if the specified call is known to never read or write memory.
Definition: AliasAnalysis.h:639
SmallVector.h
llvm::FunctionAnalysisManager
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
Definition: PassManager.h:912
llvm::AAResults::alias
AliasResult alias(const Value *V1, LocationSize V1Size, const Value *V2, LocationSize V2Size)
A convenience wrapper around the primary alias interface.
Definition: AliasAnalysis.h:559
llvm::DenseMapInfo< AACacheLoc >::isEqual
static bool isEqual(const AACacheLoc &LHS, const AACacheLoc &RHS)
Definition: AliasAnalysis.h:456
llvm::setRef
ModRefInfo setRef(const ModRefInfo MRI)
Definition: AliasAnalysis.h:180
llvm::AAResultsWrapperPass
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
Definition: AliasAnalysis.h:1308
llvm::ExternalAAWrapperPass
A wrapper pass for external alias analyses.
Definition: AliasAnalysis.h:1326
llvm::BatchAAResults::callCapturesBefore
ModRefInfo callCapturesBefore(const Instruction *I, const MemoryLocation &MemLoc, DominatorTree *DT)
Definition: AliasAnalysis.h:950
llvm::clearRef
ModRefInfo clearRef(const ModRefInfo MRI)
Definition: AliasAnalysis.h:188
llvm::AAResults::isMustAlias
bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A trivial helper function to check to see if the specified pointers are must-alias.
Definition: AliasAnalysis.h:590
llvm::AAResults::canBasicBlockModify
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.
Definition: AliasAnalysis.cpp:759
llvm::FunctionModRefBehavior::operator|=
FunctionModRefBehavior & operator|=(FunctionModRefBehavior Other)
Union (in-place) with another FunctionModRefBehavior.
Definition: AliasAnalysis.h:369
llvm::setMod
ModRefInfo setMod(const ModRefInfo MRI)
Definition: AliasAnalysis.h:176
llvm::FunctionModRefBehavior::FunctionModRefBehavior
FunctionModRefBehavior(ModRefInfo MR)
Create FunctionModRefBehavior that can access any location with the given ModRefInfo.
Definition: AliasAnalysis.h:251
llvm::AAResults::callCapturesBefore
ModRefInfo callCapturesBefore(const Instruction *I, const MemoryLocation &MemLoc, DominatorTree *DT)
Return information about whether a particular call site modifies or reads the specified memory locati...
Definition: AliasAnalysis.h:809
llvm::isNoModRef
bool isNoModRef(const ModRefInfo MRI)
Definition: AliasAnalysis.h:159
llvm::MemoryLocation::getBeforeOrAfter
static MemoryLocation getBeforeOrAfter(const Value *Ptr, const AAMDNodes &AATags=AAMDNodes())
Return a location that may access any location before or after Ptr, while remaining within the underl...
Definition: MemoryLocation.h:278
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1174
llvm::SmallPtrSetImpl< const Value * >
llvm::ModRefInfo::LLVM_MARK_AS_BITMASK_ENUM
@ LLVM_MARK_AS_BITMASK_ENUM
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:308
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
llvm::AAResults::Concept::setAAResults
virtual void setAAResults(AAResults *NewAAR)=0
An update API used internally by the AAResults to provide a handle back to the top level aggregation.
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::AtomicCmpXchgInst
An instruction that atomically checks whether a specified value is in a memory location,...
Definition: Instructions.h:510
llvm::unionModRef
ModRefInfo unionModRef(const ModRefInfo MRI1, const ModRefInfo MRI2)
Definition: AliasAnalysis.h:192
llvm::AAResults::getModRefInfo
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc)
getModRefInfo (for call sites) - Return information about whether a particular call site modifies or ...
Definition: AliasAnalysis.cpp:217
llvm::AAResultBase
A CRTP-driven "mixin" base class to help implement the function alias analysis results concept.
Definition: AliasAnalysis.h:1091
llvm::ModRefInfo::ModRef
@ ModRef
The access may reference and may modify the value stored in memory.
llvm::SimpleAAQueryInfo::SimpleAAQueryInfo
SimpleAAQueryInfo()
Definition: AliasAnalysis.h:513
llvm::MemoryLocation
Representation for a specific memory location.
Definition: MemoryLocation.h:210
llvm::codeview::PublicSymFlags::Function
@ Function
llvm::AAResultBase::getModRefInfo
ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2, AAQueryInfo &AAQI)
Definition: AliasAnalysis.h:1206
llvm::AAQueryInfo::Depth
unsigned Depth
Query depth used to distinguish recursive queries.
Definition: AliasAnalysis.h:486
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1247
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38
llvm::FunctionModRefBehavior::ArgMem
@ ArgMem
Access to memory via argument pointers.
Definition: AliasAnalysis.h:213
llvm::AAResults::getModRefInfo
ModRefInfo getModRefInfo(const AtomicCmpXchgInst *CX, const Value *P, LocationSize Size)
getModRefInfo (for cmpxchges) - A convenience wrapper.
Definition: AliasAnalysis.h:730