LLVM 20.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"
43#include "llvm/IR/Function.h"
44#include "llvm/IR/PassManager.h"
45#include "llvm/Pass.h"
46#include "llvm/Support/ModRef.h"
47#include <cstdint>
48#include <functional>
49#include <memory>
50#include <optional>
51#include <vector>
52
53namespace llvm {
54
55class AtomicCmpXchgInst;
56class BasicBlock;
57class CatchPadInst;
58class CatchReturnInst;
59class DominatorTree;
60class FenceInst;
61class LoopInfo;
62class TargetLibraryInfo;
63
64/// The possible results of an alias query.
65///
66/// These results are always computed between two MemoryLocation objects as
67/// a query to some alias analysis.
68///
69/// Note that these are unscoped enumerations because we would like to support
70/// implicitly testing a result for the existence of any possible aliasing with
71/// a conversion to bool, but an "enum class" doesn't support this. The
72/// canonical names from the literature are suffixed and unique anyways, and so
73/// they serve as global constants in LLVM for these results.
74///
75/// See docs/AliasAnalysis.html for more information on the specific meanings
76/// of these values.
78private:
79 static const int OffsetBits = 23;
80 static const int AliasBits = 8;
81 static_assert(AliasBits + 1 + OffsetBits <= 32,
82 "AliasResult size is intended to be 4 bytes!");
83
84 unsigned int Alias : AliasBits;
85 unsigned int HasOffset : 1;
86 signed int Offset : OffsetBits;
87
88public:
89 enum Kind : uint8_t {
90 /// The two locations do not alias at all.
91 ///
92 /// This value is arranged to convert to false, while all other values
93 /// convert to true. This allows a boolean context to convert the result to
94 /// a binary flag indicating whether there is the possibility of aliasing.
96 /// The two locations may or may not alias. This is the least precise
97 /// result.
99 /// The two locations alias, but only due to a partial overlap.
101 /// The two locations precisely alias each other.
103 };
104 static_assert(MustAlias < (1 << AliasBits),
105 "Not enough bit field size for the enum!");
106
107 explicit AliasResult() = delete;
108 constexpr AliasResult(const Kind &Alias)
109 : Alias(Alias), HasOffset(false), Offset(0) {}
110
111 operator Kind() const { return static_cast<Kind>(Alias); }
112
113 bool operator==(const AliasResult &Other) const {
114 return Alias == Other.Alias && HasOffset == Other.HasOffset &&
115 Offset == Other.Offset;
116 }
117 bool operator!=(const AliasResult &Other) const { return !(*this == Other); }
118
119 bool operator==(Kind K) const { return Alias == K; }
120 bool operator!=(Kind K) const { return !(*this == K); }
121
122 constexpr bool hasOffset() const { return HasOffset; }
123 constexpr int32_t getOffset() const {
124 assert(HasOffset && "No offset!");
125 return Offset;
126 }
127 void setOffset(int32_t NewOffset) {
128 if (isInt<OffsetBits>(NewOffset)) {
129 HasOffset = true;
130 Offset = NewOffset;
131 }
132 }
133
134 /// Helper for processing AliasResult for swapped memory location pairs.
135 void swap(bool DoSwap = true) {
136 if (DoSwap && hasOffset())
138 }
139};
140
141static_assert(sizeof(AliasResult) == 4,
142 "AliasResult size is intended to be 4 bytes!");
143
144/// << operator for AliasResult.
145raw_ostream &operator<<(raw_ostream &OS, AliasResult AR);
146
147/// Virtual base class for providers of capture analysis.
149 virtual ~CaptureAnalysis() = 0;
150
151 /// Check whether Object is not captured before instruction I. If OrAt is
152 /// true, captures by instruction I itself are also considered.
153 ///
154 /// If I is nullptr, then captures at any point will be considered.
155 virtual bool isNotCapturedBefore(const Value *Object, const Instruction *I,
156 bool OrAt) = 0;
157};
158
159/// Context-free CaptureAnalysis provider, which computes and caches whether an
160/// object is captured in the function at all, but does not distinguish whether
161/// it was captured before or after the context instruction.
164
165public:
166 bool isNotCapturedBefore(const Value *Object, const Instruction *I,
167 bool OrAt) override;
168};
169
170/// Context-sensitive CaptureAnalysis provider, which computes and caches the
171/// earliest common dominator closure of all captures. It provides a good
172/// approximation to a precise "captures before" analysis.
174 DominatorTree &DT;
175 const LoopInfo *LI;
176
177 /// Map from identified local object to an instruction before which it does
178 /// not escape, or nullptr if it never escapes. The "earliest" instruction
179 /// may be a conservative approximation, e.g. the first instruction in the
180 /// function is always a legal choice.
182
183 /// Reverse map from instruction to the objects it is the earliest escape for.
184 /// This is used for cache invalidation purposes.
186
187public:
189 : DT(DT), LI(LI) {}
190
191 bool isNotCapturedBefore(const Value *Object, const Instruction *I,
192 bool OrAt) override;
193
195};
196
197/// Cache key for BasicAA results. It only includes the pointer and size from
198/// MemoryLocation, as BasicAA is AATags independent. Additionally, it includes
199/// the value of MayBeCrossIteration, which may affect BasicAA results.
204
206 AACacheLoc(const Value *Ptr, LocationSize Size, bool MayBeCrossIteration)
207 : Ptr(Ptr, MayBeCrossIteration), Size(Size) {}
208};
209
210template <> struct DenseMapInfo<AACacheLoc> {
211 static inline AACacheLoc getEmptyKey() {
214 }
215 static inline AACacheLoc getTombstoneKey() {
218 }
219 static unsigned getHashValue(const AACacheLoc &Val) {
222 }
223 static bool isEqual(const AACacheLoc &LHS, const AACacheLoc &RHS) {
224 return LHS.Ptr == RHS.Ptr && LHS.Size == RHS.Size;
225 }
226};
227
228class AAResults;
229
230/// This class stores info we want to provide to or retain within an alias
231/// query. By default, the root query is stateless and starts with a freshly
232/// constructed info object. Specific alias analyses can use this query info to
233/// store per-query state that is important for recursive or nested queries to
234/// avoid recomputing. To enable preserving this state across multiple queries
235/// where safe (due to the IR not changing), use a `BatchAAResults` wrapper.
236/// The information stored in an `AAQueryInfo` is currently limitted to the
237/// caches used by BasicAA, but can further be extended to fit other AA needs.
239public:
240 using LocPair = std::pair<AACacheLoc, AACacheLoc>;
241 struct CacheEntry {
242 /// Cache entry is neither an assumption nor does it use a (non-definitive)
243 /// assumption.
244 static constexpr int Definitive = -2;
245 /// Cache entry is not an assumption itself, but may be using an assumption
246 /// from higher up the stack.
247 static constexpr int AssumptionBased = -1;
248
250 /// Number of times a NoAlias assumption has been used, 0 for assumptions
251 /// that have not been used. Can also take one of the Definitive or
252 /// AssumptionBased values documented above.
254
255 /// Whether this is a definitive (non-assumption) result.
256 bool isDefinitive() const { return NumAssumptionUses == Definitive; }
257 /// Whether this is an assumption that has not been proven yet.
258 bool isAssumption() const { return NumAssumptionUses >= 0; }
259 };
260
261 // Alias analysis result aggregration using which this query is performed.
262 // Can be used to perform recursive queries.
264
267
269
270 /// Query depth used to distinguish recursive queries.
271 unsigned Depth = 0;
272
273 /// How many active NoAlias assumption uses there are.
275
276 /// Location pairs for which an assumption based result is currently stored.
277 /// Used to remove all potentially incorrect results from the cache if an
278 /// assumption is disproven.
280
281 /// Tracks whether the accesses may be on different cycle iterations.
282 ///
283 /// When interpret "Value" pointer equality as value equality we need to make
284 /// sure that the "Value" is not part of a cycle. Otherwise, two uses could
285 /// come from different "iterations" of a cycle and see different values for
286 /// the same "Value" pointer.
287 ///
288 /// The following example shows the problem:
289 /// %p = phi(%alloca1, %addr2)
290 /// %l = load %ptr
291 /// %addr1 = gep, %alloca2, 0, %l
292 /// %addr2 = gep %alloca2, 0, (%l + 1)
293 /// alias(%p, %addr1) -> MayAlias !
294 /// store %l, ...
296
297 /// Whether alias analysis is allowed to use the dominator tree, for use by
298 /// passes that lazily update the DT while performing AA queries.
299 bool UseDominatorTree = true;
300
302};
303
304/// AAQueryInfo that uses SimpleCaptureAnalysis.
307
308public:
310};
311
312class BatchAAResults;
313
315public:
316 // Make these results default constructable and movable. We have to spell
317 // these out because MSVC won't synthesize them.
318 AAResults(const TargetLibraryInfo &TLI);
319 AAResults(AAResults &&Arg);
320 ~AAResults();
321
322 /// Register a specific AA result.
323 template <typename AAResultT> void addAAResult(AAResultT &AAResult) {
324 // FIXME: We should use a much lighter weight system than the usual
325 // polymorphic pattern because we don't own AAResult. It should
326 // ideally involve two pointers and no separate allocation.
327 AAs.emplace_back(new Model<AAResultT>(AAResult, *this));
328 }
329
330 /// Register a function analysis ID that the results aggregation depends on.
331 ///
332 /// This is used in the new pass manager to implement the invalidation logic
333 /// where we must invalidate the results aggregation if any of our component
334 /// analyses become invalid.
335 void addAADependencyID(AnalysisKey *ID) { AADeps.push_back(ID); }
336
337 /// Handle invalidation events in the new pass manager.
338 ///
339 /// The aggregation is invalidated if any of the underlying analyses is
340 /// invalidated.
341 bool invalidate(Function &F, const PreservedAnalyses &PA,
343
344 //===--------------------------------------------------------------------===//
345 /// \name Alias Queries
346 /// @{
347
348 /// The main low level interface to the alias analysis implementation.
349 /// Returns an AliasResult indicating whether the two pointers are aliased to
350 /// each other. This is the interface that must be implemented by specific
351 /// alias analysis implementations.
352 AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
353
354 /// A convenience wrapper around the primary \c alias interface.
355 AliasResult alias(const Value *V1, LocationSize V1Size, const Value *V2,
356 LocationSize V2Size) {
357 return alias(MemoryLocation(V1, V1Size), MemoryLocation(V2, V2Size));
358 }
359
360 /// A convenience wrapper around the primary \c alias interface.
361 AliasResult alias(const Value *V1, const Value *V2) {
364 }
365
366 /// A trivial helper function to check to see if the specified pointers are
367 /// no-alias.
368 bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
369 return alias(LocA, LocB) == AliasResult::NoAlias;
370 }
371
372 /// A convenience wrapper around the \c isNoAlias helper interface.
373 bool isNoAlias(const Value *V1, LocationSize V1Size, const Value *V2,
374 LocationSize V2Size) {
375 return isNoAlias(MemoryLocation(V1, V1Size), MemoryLocation(V2, V2Size));
376 }
377
378 /// A convenience wrapper around the \c isNoAlias helper interface.
379 bool isNoAlias(const Value *V1, const Value *V2) {
382 }
383
384 /// A trivial helper function to check to see if the specified pointers are
385 /// must-alias.
386 bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
387 return alias(LocA, LocB) == AliasResult::MustAlias;
388 }
389
390 /// A convenience wrapper around the \c isMustAlias helper interface.
391 bool isMustAlias(const Value *V1, const Value *V2) {
392 return alias(V1, LocationSize::precise(1), V2, LocationSize::precise(1)) ==
394 }
395
396 /// Checks whether the given location points to constant memory, or if
397 /// \p OrLocal is true whether it points to a local alloca.
398 bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal = false) {
399 return isNoModRef(getModRefInfoMask(Loc, OrLocal));
400 }
401
402 /// A convenience wrapper around the primary \c pointsToConstantMemory
403 /// interface.
404 bool pointsToConstantMemory(const Value *P, bool OrLocal = false) {
406 }
407
408 /// @}
409 //===--------------------------------------------------------------------===//
410 /// \name Simple mod/ref information
411 /// @{
412
413 /// Returns a bitmask that should be unconditionally applied to the ModRef
414 /// info of a memory location. This allows us to eliminate Mod and/or Ref
415 /// from the ModRef info based on the knowledge that the memory location
416 /// points to constant and/or locally-invariant memory.
417 ///
418 /// If IgnoreLocals is true, then this method returns NoModRef for memory
419 /// that points to a local alloca.
421 bool IgnoreLocals = false);
422
423 /// A convenience wrapper around the primary \c getModRefInfoMask
424 /// interface.
425 ModRefInfo getModRefInfoMask(const Value *P, bool IgnoreLocals = false) {
427 }
428
429 /// Get the ModRef info associated with a pointer argument of a call. The
430 /// result's bits are set to indicate the allowed aliasing ModRef kinds. Note
431 /// that these bits do not necessarily account for the overall behavior of
432 /// the function, but rather only provide additional per-argument
433 /// information.
434 ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx);
435
436 /// Return the behavior of the given call site.
438
439 /// Return the behavior when calling the given function.
441
442 /// Checks if the specified call is known to never read or write memory.
443 ///
444 /// Note that if the call only reads from known-constant memory, it is also
445 /// legal to return true. Also, calls that unwind the stack are legal for
446 /// this predicate.
447 ///
448 /// Many optimizations (such as CSE and LICM) can be performed on such calls
449 /// without worrying about aliasing properties, and many calls have this
450 /// property (e.g. calls to 'sin' and 'cos').
451 ///
452 /// This property corresponds to the GCC 'const' attribute.
453 bool doesNotAccessMemory(const CallBase *Call) {
455 }
456
457 /// Checks if the specified function is known to never read or write memory.
458 ///
459 /// Note that if the function only reads from known-constant memory, it is
460 /// also legal to return true. Also, function that unwind the stack are legal
461 /// for this predicate.
462 ///
463 /// Many optimizations (such as CSE and LICM) can be performed on such calls
464 /// to such functions without worrying about aliasing properties, and many
465 /// functions have this property (e.g. 'sin' and 'cos').
466 ///
467 /// This property corresponds to the GCC 'const' attribute.
470 }
471
472 /// Checks if the specified call is known to only read from non-volatile
473 /// memory (or not access memory at all).
474 ///
475 /// Calls that unwind the stack are legal for this predicate.
476 ///
477 /// This property allows many common optimizations to be performed in the
478 /// absence of interfering store instructions, such as CSE of strlen calls.
479 ///
480 /// This property corresponds to the GCC 'pure' attribute.
481 bool onlyReadsMemory(const CallBase *Call) {
482 return getMemoryEffects(Call).onlyReadsMemory();
483 }
484
485 /// Checks if the specified function is known to only read from non-volatile
486 /// memory (or not access memory at all).
487 ///
488 /// Functions that unwind the stack are legal for this predicate.
489 ///
490 /// This property allows many common optimizations to be performed in the
491 /// absence of interfering store instructions, such as CSE of strlen calls.
492 ///
493 /// This property corresponds to the GCC 'pure' attribute.
496 }
497
498 /// Check whether or not an instruction may read or write the optionally
499 /// specified memory location.
500 ///
501 ///
502 /// An instruction that doesn't read or write memory may be trivially LICM'd
503 /// for example.
504 ///
505 /// For function calls, this delegates to the alias-analysis specific
506 /// call-site mod-ref behavior queries. Otherwise it delegates to the specific
507 /// helpers above.
509 const std::optional<MemoryLocation> &OptLoc) {
510 SimpleAAQueryInfo AAQIP(*this);
511 return getModRefInfo(I, OptLoc, AAQIP);
512 }
513
514 /// A convenience wrapper for constructing the memory location.
518 }
519
520 /// Return information about whether a call and an instruction may refer to
521 /// the same memory locations.
522 ModRefInfo getModRefInfo(const Instruction *I, const CallBase *Call);
523
524 /// Return information about whether a particular call site modifies
525 /// or reads the specified memory location \p MemLoc before instruction \p I
526 /// in a BasicBlock.
528 const MemoryLocation &MemLoc,
529 DominatorTree *DT) {
530 SimpleAAQueryInfo AAQIP(*this);
531 return callCapturesBefore(I, MemLoc, DT, AAQIP);
532 }
533
534 /// A convenience wrapper to synthesize a memory location.
538 }
539
540 /// @}
541 //===--------------------------------------------------------------------===//
542 /// \name Higher level methods for querying mod/ref information.
543 /// @{
544
545 /// Check if it is possible for execution of the specified basic block to
546 /// modify the location Loc.
547 bool canBasicBlockModify(const BasicBlock &BB, const MemoryLocation &Loc);
548
549 /// A convenience wrapper synthesizing a memory location.
550 bool canBasicBlockModify(const BasicBlock &BB, const Value *P,
553 }
554
555 /// Check if it is possible for the execution of the specified instructions
556 /// to mod\ref (according to the mode) the location Loc.
557 ///
558 /// The instructions to consider are all of the instructions in the range of
559 /// [I1,I2] INCLUSIVE. I1 and I2 must be in the same basic block.
560 bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2,
561 const MemoryLocation &Loc,
562 const ModRefInfo Mode);
563
564 /// A convenience wrapper synthesizing a memory location.
566 const Value *Ptr, LocationSize Size,
567 const ModRefInfo Mode) {
569 }
570
571 // CtxI can be nullptr, in which case the query is whether or not the aliasing
572 // relationship holds through the entire function.
573 AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
574 AAQueryInfo &AAQI, const Instruction *CtxI = nullptr);
575
577 bool IgnoreLocals = false);
578 ModRefInfo getModRefInfo(const Instruction *I, const CallBase *Call2,
579 AAQueryInfo &AAQIP);
580 ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
581 AAQueryInfo &AAQI);
582 ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
583 AAQueryInfo &AAQI);
585 AAQueryInfo &AAQI);
586 ModRefInfo getModRefInfo(const LoadInst *L, const MemoryLocation &Loc,
587 AAQueryInfo &AAQI);
589 AAQueryInfo &AAQI);
591 AAQueryInfo &AAQI);
593 const MemoryLocation &Loc, AAQueryInfo &AAQI);
595 AAQueryInfo &AAQI);
597 AAQueryInfo &AAQI);
599 AAQueryInfo &AAQI);
601 const std::optional<MemoryLocation> &OptLoc,
602 AAQueryInfo &AAQIP);
604 const MemoryLocation &MemLoc, DominatorTree *DT,
605 AAQueryInfo &AAQIP);
607
608private:
609 class Concept;
610
611 template <typename T> class Model;
612
613 friend class AAResultBase;
614
615 const TargetLibraryInfo &TLI;
616
617 std::vector<std::unique_ptr<Concept>> AAs;
618
619 std::vector<AnalysisKey *> AADeps;
620
621 friend class BatchAAResults;
622};
623
624/// This class is a wrapper over an AAResults, and it is intended to be used
625/// only when there are no IR changes inbetween queries. BatchAAResults is
626/// reusing the same `AAQueryInfo` to preserve the state across queries,
627/// esentially making AA work in "batch mode". The internal state cannot be
628/// cleared, so to go "out-of-batch-mode", the user must either use AAResults,
629/// or create a new BatchAAResults.
631 AAResults &AA;
632 AAQueryInfo AAQI;
633 SimpleCaptureAnalysis SimpleCA;
634
635public:
636 BatchAAResults(AAResults &AAR) : AA(AAR), AAQI(AAR, &SimpleCA) {}
638 : AA(AAR), AAQI(AAR, CA) {}
639
640 AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
641 return AA.alias(LocA, LocB, AAQI);
642 }
643 bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal = false) {
644 return isNoModRef(AA.getModRefInfoMask(Loc, AAQI, OrLocal));
645 }
647 bool IgnoreLocals = false) {
648 return AA.getModRefInfoMask(Loc, AAQI, IgnoreLocals);
649 }
651 const std::optional<MemoryLocation> &OptLoc) {
652 return AA.getModRefInfo(I, OptLoc, AAQI);
653 }
655 return AA.getModRefInfo(I, Call2, AAQI);
656 }
657 ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
658 return AA.getArgModRefInfo(Call, ArgIdx);
659 }
661 return AA.getMemoryEffects(Call, AAQI);
662 }
663 bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
664 return alias(LocA, LocB) == AliasResult::MustAlias;
665 }
666 bool isMustAlias(const Value *V1, const Value *V2) {
670 }
672 const MemoryLocation &MemLoc,
673 DominatorTree *DT) {
674 return AA.callCapturesBefore(I, MemLoc, DT, AAQI);
675 }
676
677 /// Assume that values may come from different cycle iterations.
679 AAQI.MayBeCrossIteration = true;
680 }
681
682 /// Disable the use of the dominator tree during alias analysis queries.
683 void disableDominatorTree() { AAQI.UseDominatorTree = false; }
684};
685
686/// Temporary typedef for legacy code that uses a generic \c AliasAnalysis
687/// pointer or reference.
689
690/// A private abstract base class describing the concept of an individual alias
691/// analysis implementation.
692///
693/// This interface is implemented by any \c Model instantiation. It is also the
694/// interface which a type used to instantiate the model must provide.
695///
696/// All of these methods model methods by the same name in the \c
697/// AAResults class. Only differences and specifics to how the
698/// implementations are called are documented here.
700public:
701 virtual ~Concept() = 0;
702
703 //===--------------------------------------------------------------------===//
704 /// \name Alias Queries
705 /// @{
706
707 /// The main low level interface to the alias analysis implementation.
708 /// Returns an AliasResult indicating whether the two pointers are aliased to
709 /// each other. This is the interface that must be implemented by specific
710 /// alias analysis implementations.
711 virtual AliasResult alias(const MemoryLocation &LocA,
712 const MemoryLocation &LocB, AAQueryInfo &AAQI,
713 const Instruction *CtxI) = 0;
714
715 /// @}
716 //===--------------------------------------------------------------------===//
717 /// \name Simple mod/ref information
718 /// @{
719
720 /// Returns a bitmask that should be unconditionally applied to the ModRef
721 /// info of a memory location. This allows us to eliminate Mod and/or Ref from
722 /// the ModRef info based on the knowledge that the memory location points to
723 /// constant and/or locally-invariant memory.
725 AAQueryInfo &AAQI,
726 bool IgnoreLocals) = 0;
727
728 /// Get the ModRef info associated with a pointer argument of a callsite. The
729 /// result's bits are set to indicate the allowed aliasing ModRef kinds. Note
730 /// that these bits do not necessarily account for the overall behavior of
731 /// the function, but rather only provide additional per-argument
732 /// information.
734 unsigned ArgIdx) = 0;
735
736 /// Return the behavior of the given call site.
738 AAQueryInfo &AAQI) = 0;
739
740 /// Return the behavior when calling the given function.
742
743 /// getModRefInfo (for call sites) - Return information about whether
744 /// a particular call site modifies or reads the specified memory location.
745 virtual ModRefInfo getModRefInfo(const CallBase *Call,
746 const MemoryLocation &Loc,
747 AAQueryInfo &AAQI) = 0;
748
749 /// Return information about whether two call sites may refer to the same set
750 /// of memory locations. See the AA documentation for details:
751 /// http://llvm.org/docs/AliasAnalysis.html#ModRefInfo
752 virtual ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
753 AAQueryInfo &AAQI) = 0;
754
755 /// @}
756};
757
758/// A private class template which derives from \c Concept and wraps some other
759/// type.
760///
761/// This models the concept by directly forwarding each interface point to the
762/// wrapped type which must implement a compatible interface. This provides
763/// a type erased binding.
764template <typename AAResultT> class AAResults::Model final : public Concept {
765 AAResultT &Result;
766
767public:
768 explicit Model(AAResultT &Result, AAResults &AAR) : Result(Result) {}
769 ~Model() override = default;
770
771 AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
772 AAQueryInfo &AAQI, const Instruction *CtxI) override {
773 return Result.alias(LocA, LocB, AAQI, CtxI);
774 }
775
776 ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, AAQueryInfo &AAQI,
777 bool IgnoreLocals) override {
778 return Result.getModRefInfoMask(Loc, AAQI, IgnoreLocals);
779 }
780
781 ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) override {
782 return Result.getArgModRefInfo(Call, ArgIdx);
783 }
784
785 MemoryEffects getMemoryEffects(const CallBase *Call,
786 AAQueryInfo &AAQI) override {
787 return Result.getMemoryEffects(Call, AAQI);
788 }
789
790 MemoryEffects getMemoryEffects(const Function *F) override {
791 return Result.getMemoryEffects(F);
792 }
793
794 ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
795 AAQueryInfo &AAQI) override {
796 return Result.getModRefInfo(Call, Loc, AAQI);
797 }
798
799 ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
800 AAQueryInfo &AAQI) override {
801 return Result.getModRefInfo(Call1, Call2, AAQI);
802 }
803};
804
805/// A base class to help implement the function alias analysis results concept.
806///
807/// Because of the nature of many alias analysis implementations, they often
808/// only implement a subset of the interface. This base class will attempt to
809/// implement the remaining portions of the interface in terms of simpler forms
810/// of the interface where possible, and otherwise provide conservatively
811/// correct fallback implementations.
812///
813/// Implementors of an alias analysis should derive from this class, and then
814/// override specific methods that they wish to customize. There is no need to
815/// use virtual anywhere.
817protected:
818 explicit AAResultBase() = default;
819
820 // Provide all the copy and move constructors so that derived types aren't
821 // constrained.
824
825public:
827 AAQueryInfo &AAQI, const Instruction *I) {
829 }
830
832 bool IgnoreLocals) {
833 return ModRefInfo::ModRef;
834 }
835
836 ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
837 return ModRefInfo::ModRef;
838 }
839
841 return MemoryEffects::unknown();
842 }
843
845 return MemoryEffects::unknown();
846 }
847
849 AAQueryInfo &AAQI) {
850 return ModRefInfo::ModRef;
851 }
852
853 ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
854 AAQueryInfo &AAQI) {
855 return ModRefInfo::ModRef;
856 }
857};
858
859/// Return true if this pointer is returned by a noalias function.
860bool isNoAliasCall(const Value *V);
861
862/// Return true if this pointer refers to a distinct and identifiable object.
863/// This returns true for:
864/// Global Variables and Functions (but not Global Aliases)
865/// Allocas
866/// ByVal and NoAlias Arguments
867/// NoAlias returns (e.g. calls to malloc)
868///
869bool isIdentifiedObject(const Value *V);
870
871/// Return true if V is umabigously identified at the function-level.
872/// Different IdentifiedFunctionLocals can't alias.
873/// Further, an IdentifiedFunctionLocal can not alias with any function
874/// arguments other than itself, which is not necessarily true for
875/// IdentifiedObjects.
876bool isIdentifiedFunctionLocal(const Value *V);
877
878/// Return true if we know V to the base address of the corresponding memory
879/// object. This implies that any address less than V must be out of bounds
880/// for the underlying object. Note that just being isIdentifiedObject() is
881/// not enough - For example, a negative offset from a noalias argument or call
882/// can be inbounds w.r.t the actual underlying object.
883bool isBaseOfObject(const Value *V);
884
885/// Returns true if the pointer is one which would have been considered an
886/// escape by isNonEscapingLocalObject.
887bool isEscapeSource(const Value *V);
888
889/// Return true if Object memory is not visible after an unwind, in the sense
890/// that program semantics cannot depend on Object containing any particular
891/// value on unwind. If the RequiresNoCaptureBeforeUnwind out parameter is set
892/// to true, then the memory is only not visible if the object has not been
893/// captured prior to the unwind. Otherwise it is not visible even if captured.
894bool isNotVisibleOnUnwind(const Value *Object,
895 bool &RequiresNoCaptureBeforeUnwind);
896
897/// Return true if the Object is writable, in the sense that any location based
898/// on this pointer that can be loaded can also be stored to without trapping.
899/// Additionally, at the point Object is declared, stores can be introduced
900/// without data races. At later points, this is only the case if the pointer
901/// can not escape to a different thread.
902///
903/// If ExplicitlyDereferenceableOnly is set to true, this property only holds
904/// for the part of Object that is explicitly marked as dereferenceable, e.g.
905/// using the dereferenceable(N) attribute. It does not necessarily hold for
906/// parts that are only known to be dereferenceable due to the presence of
907/// loads.
908bool isWritableObject(const Value *Object, bool &ExplicitlyDereferenceableOnly);
909
910/// A manager for alias analyses.
911///
912/// This class can have analyses registered with it and when run, it will run
913/// all of them and aggregate their results into single AA results interface
914/// that dispatches across all of the alias analysis results available.
915///
916/// Note that the order in which analyses are registered is very significant.
917/// That is the order in which the results will be aggregated and queried.
918///
919/// This manager effectively wraps the AnalysisManager for registering alias
920/// analyses. When you register your alias analysis with this manager, it will
921/// ensure the analysis itself is registered with its AnalysisManager.
922///
923/// The result of this analysis is only invalidated if one of the particular
924/// aggregated AA results end up being invalidated. This removes the need to
925/// explicitly preserve the results of `AAManager`. Note that analyses should no
926/// longer be registered once the `AAManager` is run.
927class AAManager : public AnalysisInfoMixin<AAManager> {
928public:
930
931 /// Register a specific AA result.
932 template <typename AnalysisT> void registerFunctionAnalysis() {
933 ResultGetters.push_back(&getFunctionAAResultImpl<AnalysisT>);
934 }
935
936 /// Register a specific AA result.
937 template <typename AnalysisT> void registerModuleAnalysis() {
938 ResultGetters.push_back(&getModuleAAResultImpl<AnalysisT>);
939 }
940
942
943private:
945
946 static AnalysisKey Key;
947
950 4> ResultGetters;
951
952 template <typename AnalysisT>
953 static void getFunctionAAResultImpl(Function &F,
956 AAResults.addAAResult(AM.template getResult<AnalysisT>(F));
957 AAResults.addAADependencyID(AnalysisT::ID());
958 }
959
960 template <typename AnalysisT>
961 static void getModuleAAResultImpl(Function &F, FunctionAnalysisManager &AM,
962 AAResults &AAResults) {
963 auto &MAMProxy = AM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
964 if (auto *R =
965 MAMProxy.template getCachedResult<AnalysisT>(*F.getParent())) {
966 AAResults.addAAResult(*R);
967 MAMProxy
968 .template registerOuterAnalysisInvalidation<AnalysisT, AAManager>();
969 }
970 }
971};
972
973/// A wrapper pass to provide the legacy pass manager access to a suitably
974/// prepared AAResults object.
976 std::unique_ptr<AAResults> AAR;
977
978public:
979 static char ID;
980
982
983 AAResults &getAAResults() { return *AAR; }
984 const AAResults &getAAResults() const { return *AAR; }
985
986 bool runOnFunction(Function &F) override;
987
988 void getAnalysisUsage(AnalysisUsage &AU) const override;
989};
990
991/// A wrapper pass for external alias analyses. This just squirrels away the
992/// callback used to run any analyses and register their results.
994 using CallbackT = std::function<void(Pass &, Function &, AAResults &)>;
995
997
998 static char ID;
999
1001
1003
1004 void getAnalysisUsage(AnalysisUsage &AU) const override {
1005 AU.setPreservesAll();
1006 }
1007};
1008
1009/// A wrapper pass around a callback which can be used to populate the
1010/// AAResults in the AAResultsWrapperPass from an external AA.
1011///
1012/// The callback provided here will be used each time we prepare an AAResults
1013/// object, and will receive a reference to the function wrapper pass, the
1014/// function, and the AAResults object to populate. This should be used when
1015/// setting up a custom pass pipeline to inject a hook into the AA results.
1017 std::function<void(Pass &, Function &, AAResults &)> Callback);
1018
1019} // end namespace llvm
1020
1021#endif // LLVM_ANALYSIS_ALIASANALYSIS_H
This file defines the DenseMap class.
uint64_t Size
This header defines various interfaces for pass management in LLVM.
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
This file provides utility analysis objects describing memory locations.
#define P(N)
static cl::opt< RegAllocEvictionAdvisorAnalysis::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Development, "development", "for training")))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
This file defines the SmallVector class.
Value * RHS
Value * LHS
A manager for alias analyses.
void registerFunctionAnalysis()
Register a specific AA result.
AAResults Result
Result run(Function &F, FunctionAnalysisManager &AM)
void registerModuleAnalysis()
Register a specific AA result.
This class stores info we want to provide to or retain within an alias query.
AAQueryInfo(AAResults &AAR, CaptureAnalysis *CA)
SmallVector< AAQueryInfo::LocPair, 4 > AssumptionBasedResults
Location pairs for which an assumption based result is currently stored.
unsigned Depth
Query depth used to distinguish recursive queries.
bool UseDominatorTree
Whether alias analysis is allowed to use the dominator tree, for use by passes that lazily update the...
int NumAssumptionUses
How many active NoAlias assumption uses there are.
std::pair< AACacheLoc, AACacheLoc > LocPair
AliasCacheT AliasCache
bool MayBeCrossIteration
Tracks whether the accesses may be on different cycle iterations.
CaptureAnalysis * CA
A base class to help implement the function alias analysis results concept.
ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2, AAQueryInfo &AAQI)
MemoryEffects getMemoryEffects(const CallBase *Call, AAQueryInfo &AAQI)
ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, AAQueryInfo &AAQI, bool IgnoreLocals)
MemoryEffects getMemoryEffects(const Function *F)
AAResultBase(const AAResultBase &Arg)
AAResultBase(AAResultBase &&Arg)
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc, AAQueryInfo &AAQI)
AAResultBase()=default
ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx)
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB, AAQueryInfo &AAQI, const Instruction *I)
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
const AAResults & getAAResults() const
bool runOnFunction(Function &F) override
Run the wrapper pass to rebuild an aggregation over known AA passes.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
A private abstract base class describing the concept of an individual alias analysis implementation.
virtual AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB, AAQueryInfo &AAQI, const Instruction *CtxI)=0
The main low level interface to the alias analysis implementation.
virtual MemoryEffects getMemoryEffects(const CallBase *Call, AAQueryInfo &AAQI)=0
Return the behavior of the given call site.
virtual ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2, AAQueryInfo &AAQI)=0
Return information about whether two call sites may refer to the same set of memory locations.
virtual ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, AAQueryInfo &AAQI, bool IgnoreLocals)=0
Returns a bitmask that should be unconditionally applied to the ModRef info of a memory location.
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 ...
virtual ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx)=0
Get the ModRef info associated with a pointer argument of a callsite.
virtual MemoryEffects getMemoryEffects(const Function *F)=0
Return the behavior when calling the given function.
bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2, const Value *Ptr, LocationSize Size, const ModRefInfo Mode)
A convenience wrapper synthesizing a memory location.
bool pointsToConstantMemory(const Value *P, bool OrLocal=false)
A convenience wrapper around the primary pointsToConstantMemory interface.
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 ...
ModRefInfo getModRefInfo(const Instruction *I, const std::optional< MemoryLocation > &OptLoc)
Check whether or not an instruction may read or write the optionally specified memory location.
bool doesNotAccessMemory(const Function *F)
Checks if the specified function is known to never read or write memory.
AliasResult alias(const Value *V1, const Value *V2)
A convenience wrapper around the primary alias interface.
AliasResult alias(const Value *V1, LocationSize V1Size, const Value *V2, LocationSize V2Size)
A convenience wrapper around the primary alias interface.
bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A trivial helper function to check to see if the specified pointers are must-alias.
bool doesNotAccessMemory(const CallBase *Call)
Checks if the specified call is known to never read or write memory.
bool isNoAlias(const Value *V1, LocationSize V1Size, const Value *V2, LocationSize V2Size)
A convenience wrapper around the isNoAlias helper interface.
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
The main low level interface to the alias analysis implementation.
ModRefInfo getModRefInfo(const Instruction *I, const Value *P, LocationSize Size)
A convenience wrapper for constructing the memory location.
bool canBasicBlockModify(const BasicBlock &BB, const Value *P, LocationSize Size)
A convenience wrapper synthesizing a memory location.
ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, bool IgnoreLocals=false)
Returns a bitmask that should be unconditionally applied to the ModRef info of a memory location.
bool isNoAlias(const Value *V1, const Value *V2)
A convenience wrapper around the isNoAlias helper interface.
bool onlyReadsMemory(const Function *F)
Checks if the specified function is known to only read from non-volatile memory (or not access memory...
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...
MemoryEffects getMemoryEffects(const CallBase *Call)
Return the behavior of the given call site.
bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A trivial helper function to check to see if the specified pointers are no-alias.
ModRefInfo getModRefInfoMask(const Value *P, bool IgnoreLocals=false)
A convenience wrapper around the primary getModRefInfoMask interface.
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)
Handle invalidation events in the new pass manager.
ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx)
Get the ModRef info associated with a pointer argument of a call.
bool onlyReadsMemory(const CallBase *Call)
Checks if the specified call is known to only read from non-volatile memory (or not access memory at ...
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)...
bool isMustAlias(const Value *V1, const Value *V2)
A convenience wrapper around the isMustAlias helper interface.
void addAAResult(AAResultT &AAResult)
Register a specific AA result.
void addAADependencyID(AnalysisKey *ID)
Register a function analysis ID that the results aggregation depends on.
ModRefInfo callCapturesBefore(const Instruction *I, const Value *P, LocationSize Size, DominatorTree *DT)
A convenience wrapper to synthesize 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.
The possible results of an alias query.
Definition: AliasAnalysis.h:77
constexpr AliasResult(const Kind &Alias)
bool operator==(const AliasResult &Other) const
bool operator!=(Kind K) const
AliasResult()=delete
void swap(bool DoSwap=true)
Helper for processing AliasResult for swapped memory location pairs.
bool operator==(Kind K) const
@ MayAlias
The two locations may or may not alias.
Definition: AliasAnalysis.h:98
@ NoAlias
The two locations do not alias at all.
Definition: AliasAnalysis.h:95
@ PartialAlias
The two locations alias, but only due to a partial overlap.
@ MustAlias
The two locations precisely alias each other.
void setOffset(int32_t NewOffset)
bool operator!=(const AliasResult &Other) const
constexpr int32_t getOffset() const
constexpr bool hasOffset() const
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:292
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
An instruction that atomically checks whether a specified value is in a memory location,...
Definition: Instructions.h:501
an instruction that atomically reads a memory location, combines it with another value,...
Definition: Instructions.h:704
LLVM Basic Block Representation.
Definition: BasicBlock.h:61
This class is a wrapper over an AAResults, and it is intended to be used only when there are no IR ch...
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
BatchAAResults(AAResults &AAR)
ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx)
void disableDominatorTree()
Disable the use of the dominator tree during alias analysis queries.
BatchAAResults(AAResults &AAR, CaptureAnalysis *CA)
void enableCrossIterationMode()
Assume that values may come from different cycle iterations.
bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
ModRefInfo getModRefInfo(const Instruction *I, const CallBase *Call2)
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal=false)
MemoryEffects getMemoryEffects(const CallBase *Call)
bool isMustAlias(const Value *V1, const Value *V2)
ModRefInfo getModRefInfo(const Instruction *I, const std::optional< MemoryLocation > &OptLoc)
ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, bool IgnoreLocals=false)
ModRefInfo callCapturesBefore(const Instruction *I, const MemoryLocation &MemLoc, DominatorTree *DT)
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1120
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:162
Context-sensitive CaptureAnalysis provider, which computes and caches the earliest common dominator c...
void removeInstruction(Instruction *I)
bool isNotCapturedBefore(const Value *Object, const Instruction *I, bool OrAt) override
Check whether Object is not captured before instruction I.
EarliestEscapeAnalysis(DominatorTree &DT, const LoopInfo *LI=nullptr)
An instruction for ordering other memory operations.
Definition: Instructions.h:424
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:310
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:281
An instruction for reading from memory.
Definition: Instructions.h:176
static LocationSize precise(uint64_t Value)
bool doesNotAccessMemory() const
Whether this function accesses no memory.
Definition: ModRef.h:192
bool onlyReadsMemory() const
Whether this function only (at most) reads memory.
Definition: ModRef.h:195
static MemoryEffectsBase unknown()
Create MemoryEffectsBase that can read and write any memory.
Definition: ModRef.h:112
Representation for a specific memory location.
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...
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:94
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:111
AAQueryInfo that uses SimpleCaptureAnalysis.
SimpleAAQueryInfo(AAResults &AAR)
Context-free CaptureAnalysis provider, which computes and caches whether an object is captured in the...
bool isNotCapturedBefore(const Value *Object, const Instruction *I, bool OrAt) override
Check whether Object is not captured before instruction I.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
An instruction for storing to memory.
Definition: Instructions.h:292
Provides information about what library functions are available for the current target.
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
LLVM Value Representation.
Definition: Value.h:74
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool isBaseOfObject(const Value *V)
Return true if we know V to the base address of the corresponding memory object.
bool isNoAliasCall(const Value *V)
Return true if this pointer is returned by a noalias function.
OuterAnalysisManagerProxy< ModuleAnalysisManager, Function > ModuleAnalysisManagerFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
Definition: PassManager.h:802
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
Definition: PassManager.h:546
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
Definition: ModRef.h:268
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...
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
Definition: ModRef.h:27
@ ModRef
The access may reference and may modify the value stored in memory.
@ Other
Any other memory.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:303
bool isIdentifiedFunctionLocal(const Value *V)
Return true if V is umabigously identified at the function-level.
bool isEscapeSource(const Value *V)
Returns true if the pointer is one which would have been considered an escape by isNonEscapingLocalOb...
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...
bool isNoModRef(const ModRefInfo MRI)
Definition: ModRef.h:39
bool isIdentifiedObject(const Value *V)
Return true if this pointer refers to a distinct and identifiable object.
bool isWritableObject(const Value *Object, bool &ExplicitlyDereferenceableOnly)
Return true if the Object is writable, in the sense that any location based on this pointer that can ...
Cache key for BasicAA results.
AACacheLoc(const Value *Ptr, LocationSize Size, bool MayBeCrossIteration)
LocationSize Size
AACacheLoc(PtrTy Ptr, LocationSize Size)
bool isAssumption() const
Whether this is an assumption that has not been proven yet.
bool isDefinitive() const
Whether this is a definitive (non-assumption) result.
static constexpr int Definitive
Cache entry is neither an assumption nor does it use a (non-definitive) assumption.
static constexpr int AssumptionBased
Cache entry is not an assumption itself, but may be using an assumption from higher up the stack.
int NumAssumptionUses
Number of times a NoAlias assumption has been used, 0 for assumptions that have not been used.
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:92
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: Analysis.h:28
Virtual base class for providers of capture analysis.
virtual ~CaptureAnalysis()=0
virtual bool isNotCapturedBefore(const Value *Object, const Instruction *I, bool OrAt)=0
Check whether Object is not captured before instruction I.
static AACacheLoc getEmptyKey()
static bool isEqual(const AACacheLoc &LHS, const AACacheLoc &RHS)
static unsigned getHashValue(const AACacheLoc &Val)
static AACacheLoc getTombstoneKey()
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: DenseMapInfo.h:52
A wrapper pass for external alias analyses.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
std::function< void(Pass &, Function &, AAResults &)> CallbackT