LLVM 23.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"
47#include "llvm/Support/ModRef.h"
48#include <cstdint>
49#include <functional>
50#include <memory>
51#include <optional>
52#include <vector>
53
54namespace llvm {
55
57class BasicBlock;
58class CatchPadInst;
59class CatchReturnInst;
60class CycleInfo;
61class DominatorTree;
62class FenceInst;
63class LoopInfo;
65
66/// The possible results of an alias query.
67///
68/// These results are always computed between two MemoryLocation objects as
69/// a query to some alias analysis.
70///
71/// Note that these are unscoped enumerations because we would like to support
72/// implicitly testing a result for the existence of any possible aliasing with
73/// a conversion to bool, but an "enum class" doesn't support this. The
74/// canonical names from the literature are suffixed and unique anyways, and so
75/// they serve as global constants in LLVM for these results.
76///
77/// See docs/AliasAnalysis.html for more information on the specific meanings
78/// of these values.
80private:
81 static const int OffsetBits = 23;
82 static const int AliasBits = 8;
83 static_assert(AliasBits + 1 + OffsetBits <= 32,
84 "AliasResult size is intended to be 4 bytes!");
85
86 unsigned int Alias : AliasBits;
87 unsigned int HasOffset : 1;
88 signed int Offset : OffsetBits;
89
90public:
91 enum Kind : uint8_t {
92 /// The two locations do not alias at all.
93 ///
94 /// This value is arranged to convert to false, while all other values
95 /// convert to true. This allows a boolean context to convert the result to
96 /// a binary flag indicating whether there is the possibility of aliasing.
98 /// The two locations may or may not alias. This is the least precise
99 /// result.
101 /// The two locations alias, but only due to a partial overlap.
103 /// The two locations precisely alias each other.
105 };
106 static_assert(MustAlias < (1 << AliasBits),
107 "Not enough bit field size for the enum!");
108
109 explicit AliasResult() = delete;
110 constexpr AliasResult(const Kind &Alias)
111 : Alias(Alias), HasOffset(false), Offset(0) {}
112
113 operator Kind() const { return static_cast<Kind>(Alias); }
114
115 bool operator==(const AliasResult &Other) const {
116 return Alias == Other.Alias && HasOffset == Other.HasOffset &&
117 Offset == Other.Offset;
118 }
119 bool operator!=(const AliasResult &Other) const { return !(*this == Other); }
120
121 bool operator==(Kind K) const { return Alias == K; }
122 bool operator!=(Kind K) const { return !(*this == K); }
123
124 constexpr bool hasOffset() const { return HasOffset; }
125 constexpr int32_t getOffset() const {
126 assert(HasOffset && "No offset!");
127 return Offset;
128 }
129 void setOffset(int32_t NewOffset) {
130 if (isInt<OffsetBits>(NewOffset)) {
131 HasOffset = true;
132 Offset = NewOffset;
133 }
134 }
135
136 /// Helper for processing AliasResult for swapped memory location pairs.
137 void swap(bool DoSwap = true) {
138 if (DoSwap && hasOffset())
140 }
141};
142
143static_assert(sizeof(AliasResult) == 4,
144 "AliasResult size is intended to be 4 bytes!");
145
146/// << operator for AliasResult.
147LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, AliasResult AR);
148
149/// Virtual base class for providers of capture analysis.
151 virtual ~CaptureAnalysis() = 0;
152
153 /// Return how Object may be captured before instruction I, considering only
154 /// provenance captures. If OrAt is true, captures by instruction I itself
155 /// are also considered.
156 ///
157 /// If I is nullptr, then captures at any point will be considered.
158 virtual CaptureComponents
159 getCapturesBefore(const Value *Object, const Instruction *I, bool OrAt) = 0;
160};
161
162/// Context-free CaptureAnalysis provider, which computes and caches whether an
163/// object is captured in the function at all, but does not distinguish whether
164/// it was captured before or after the context instruction.
167
168public:
170 bool OrAt) override;
171};
172
173/// Context-sensitive CaptureAnalysis provider, which computes and caches the
174/// earliest common dominator closure of all captures. It provides a good
175/// approximation to a precise "captures before" analysis.
177 DominatorTree &DT;
178 const LoopInfo *LI;
179 const CycleInfo *CI;
180
181 /// Map from identified local object to an instruction before which it does
182 /// not escape (or nullptr if it never escapes) and the possible components
183 /// that may be captured (by any instruction, not necessarily the earliest
184 /// one). The "earliest" instruction may be a conservative approximation,
185 /// e.g. the first instruction in the function is always a legal choice.
187 EarliestEscapes;
188
189 /// Reverse map from instruction to the objects it is the earliest escape for.
190 /// This is used for cache invalidation purposes.
192
193public:
195 const CycleInfo *CI = nullptr)
196 : DT(DT), LI(LI), CI(CI) {}
197
198 CaptureComponents getCapturesBefore(const Value *Object, const Instruction *I,
199 bool OrAt) override;
200
201 void removeInstruction(Instruction *I);
202};
203
204/// Cache key for BasicAA results. It only includes the pointer and size from
205/// MemoryLocation, as BasicAA is AATags independent. Additionally, it includes
206/// the value of MayBeCrossIteration, which may affect BasicAA results.
211
213 AACacheLoc(const Value *Ptr, LocationSize Size, bool MayBeCrossIteration)
214 : Ptr(Ptr, MayBeCrossIteration), Size(Size) {}
215};
216
217template <> struct DenseMapInfo<AACacheLoc> {
230 static bool isEqual(const AACacheLoc &LHS, const AACacheLoc &RHS) {
231 return LHS.Ptr == RHS.Ptr && LHS.Size == RHS.Size;
232 }
233};
234
235class AAResults;
236
237/// This class stores info we want to provide to or retain within an alias
238/// query. By default, the root query is stateless and starts with a freshly
239/// constructed info object. Specific alias analyses can use this query info to
240/// store per-query state that is important for recursive or nested queries to
241/// avoid recomputing. To enable preserving this state across multiple queries
242/// where safe (due to the IR not changing), use a `BatchAAResults` wrapper.
243/// The information stored in an `AAQueryInfo` is currently limitted to the
244/// caches used by BasicAA, but can further be extended to fit other AA needs.
246public:
247 using LocPair = std::pair<AACacheLoc, AACacheLoc>;
248 struct CacheEntry {
249 /// Cache entry is neither an assumption nor does it use a (non-definitive)
250 /// assumption.
251 static constexpr int Definitive = -2;
252 /// Cache entry is not an assumption itself, but may be using an assumption
253 /// from higher up the stack.
254 static constexpr int AssumptionBased = -1;
255
257 /// Number of times a NoAlias assumption has been used, 0 for assumptions
258 /// that have not been used. Can also take one of the Definitive or
259 /// AssumptionBased values documented above.
261
262 /// Whether this is a definitive (non-assumption) result.
263 bool isDefinitive() const { return NumAssumptionUses == Definitive; }
264 /// Whether this is an assumption that has not been proven yet.
265 bool isAssumption() const { return NumAssumptionUses >= 0; }
266 };
267
268 // Alias analysis result aggregration using which this query is performed.
269 // Can be used to perform recursive queries.
271
274
276
277 /// Query depth used to distinguish recursive queries.
278 unsigned Depth = 0;
279
280 /// How many active NoAlias assumption uses there are.
282
283 /// Location pairs for which an assumption based result is currently stored.
284 /// Used to remove all potentially incorrect results from the cache if an
285 /// assumption is disproven.
287
288 /// Tracks whether the accesses may be on different cycle iterations.
289 ///
290 /// When interpret "Value" pointer equality as value equality we need to make
291 /// sure that the "Value" is not part of a cycle. Otherwise, two uses could
292 /// come from different "iterations" of a cycle and see different values for
293 /// the same "Value" pointer.
294 ///
295 /// The following example shows the problem:
296 /// %p = phi(%alloca1, %addr2)
297 /// %l = load %ptr
298 /// %addr1 = gep, %alloca2, 0, %l
299 /// %addr2 = gep %alloca2, 0, (%l + 1)
300 /// alias(%p, %addr1) -> MayAlias !
301 /// store %l, ...
303
304 /// Whether alias analysis is allowed to use the dominator tree, for use by
305 /// passes that lazily update the DT while performing AA queries.
306 bool UseDominatorTree = true;
307
309};
310
311/// AAQueryInfo that uses SimpleCaptureAnalysis.
314
315public:
317};
318
319class BatchAAResults;
320
322public:
323 // Make these results default constructable and movable. We have to spell
324 // these out because MSVC won't synthesize them.
328
329 /// Register a specific AA result.
330 template <typename AAResultT> void addAAResult(AAResultT &AAResult) {
331 // FIXME: We should use a much lighter weight system than the usual
332 // polymorphic pattern because we don't own AAResult. It should
333 // ideally involve two pointers and no separate allocation.
334 AAs.emplace_back(new Model<AAResultT>(AAResult, *this));
335 }
336
337 /// Register a function analysis ID that the results aggregation depends on.
338 ///
339 /// This is used in the new pass manager to implement the invalidation logic
340 /// where we must invalidate the results aggregation if any of our component
341 /// analyses become invalid.
342 void addAADependencyID(AnalysisKey *ID) { AADeps.push_back(ID); }
343
344 /// Handle invalidation events in the new pass manager.
345 ///
346 /// The aggregation is invalidated if any of the underlying analyses is
347 /// invalidated.
349 FunctionAnalysisManager::Invalidator &Inv);
350
351 //===--------------------------------------------------------------------===//
352 /// \name Alias Queries
353 /// @{
354
355 /// The main low level interface to the alias analysis implementation.
356 /// Returns an AliasResult indicating whether the two pointers are aliased to
357 /// each other. This is the interface that must be implemented by specific
358 /// alias analysis implementations.
360 const MemoryLocation &LocB);
361
362 /// A convenience wrapper around the primary \c alias interface.
363 AliasResult alias(const Value *V1, LocationSize V1Size, const Value *V2,
364 LocationSize V2Size) {
365 return alias(MemoryLocation(V1, V1Size), MemoryLocation(V2, V2Size));
366 }
367
368 /// A convenience wrapper around the primary \c alias interface.
373
374 /// A trivial helper function to check to see if the specified pointers are
375 /// no-alias.
376 bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
377 return alias(LocA, LocB) == AliasResult::NoAlias;
378 }
379
380 /// A convenience wrapper around the \c isNoAlias helper interface.
381 bool isNoAlias(const Value *V1, LocationSize V1Size, const Value *V2,
382 LocationSize V2Size) {
383 return isNoAlias(MemoryLocation(V1, V1Size), MemoryLocation(V2, V2Size));
384 }
385
386 /// A convenience wrapper around the \c isNoAlias helper interface.
387 bool isNoAlias(const Value *V1, const Value *V2) {
390 }
391
392 /// A trivial helper function to check to see if the specified pointers are
393 /// must-alias.
394 bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
395 return alias(LocA, LocB) == AliasResult::MustAlias;
396 }
397
398 /// A convenience wrapper around the \c isMustAlias helper interface.
399 bool isMustAlias(const Value *V1, const Value *V2) {
400 return alias(V1, LocationSize::precise(1), V2, LocationSize::precise(1)) ==
402 }
403
404 /// Checks whether the given location points to constant memory, or if
405 /// \p OrLocal is true whether it points to a local alloca.
406 bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal = false) {
407 return isNoModRef(getModRefInfoMask(Loc, OrLocal));
408 }
409
410 /// A convenience wrapper around the primary \c pointsToConstantMemory
411 /// interface.
412 bool pointsToConstantMemory(const Value *P, bool OrLocal = false) {
414 }
415
416 /// @}
417 //===--------------------------------------------------------------------===//
418 /// \name Simple mod/ref information
419 /// @{
420
421 /// Returns a bitmask that should be unconditionally applied to the ModRef
422 /// info of a memory location. This allows us to eliminate Mod and/or Ref
423 /// from the ModRef info based on the knowledge that the memory location
424 /// points to constant and/or locally-invariant memory.
425 ///
426 /// If IgnoreLocals is true, then this method returns NoModRef for memory
427 /// that points to a local alloca.
429 bool IgnoreLocals = false);
430
431 /// A convenience wrapper around the primary \c getModRefInfoMask
432 /// interface.
433 ModRefInfo getModRefInfoMask(const Value *P, bool IgnoreLocals = false) {
435 }
436
437 /// Get the ModRef info associated with a pointer argument of a call. The
438 /// result's bits are set to indicate the allowed aliasing ModRef kinds. Note
439 /// that these bits do not necessarily account for the overall behavior of
440 /// the function, but rather only provide additional per-argument
441 /// information.
442 LLVM_ABI ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx);
443
444 /// Return the behavior of the given call site.
446
447 /// Return the behavior when calling the given function.
449
450 /// Checks if the specified call is known to never read or write memory.
451 ///
452 /// Note that if the call only reads from known-constant memory, it is also
453 /// legal to return true. Also, calls that unwind the stack are legal for
454 /// this predicate.
455 ///
456 /// Many optimizations (such as CSE and LICM) can be performed on such calls
457 /// without worrying about aliasing properties, and many calls have this
458 /// property (e.g. calls to 'sin' and 'cos').
459 ///
460 /// This property corresponds to the GCC 'const' attribute.
464
465 /// Checks if the specified function is known to never read or write memory.
466 ///
467 /// Note that if the function only reads from known-constant memory, it is
468 /// also legal to return true. Also, function that unwind the stack are legal
469 /// for this predicate.
470 ///
471 /// Many optimizations (such as CSE and LICM) can be performed on such calls
472 /// to such functions without worrying about aliasing properties, and many
473 /// functions have this property (e.g. 'sin' and 'cos').
474 ///
475 /// This property corresponds to the GCC 'const' attribute.
479
480 /// Checks if the specified call is known to only read from non-volatile
481 /// memory (or not access memory at all).
482 ///
483 /// Calls that unwind the stack are legal for this predicate.
484 ///
485 /// This property allows many common optimizations to be performed in the
486 /// absence of interfering store instructions, such as CSE of strlen calls.
487 ///
488 /// This property corresponds to the GCC 'pure' attribute.
492
493 /// Checks if the specified function is known to only read from non-volatile
494 /// memory (or not access memory at all).
495 ///
496 /// Functions that unwind the stack are legal for this predicate.
497 ///
498 /// This property allows many common optimizations to be performed in the
499 /// absence of interfering store instructions, such as CSE of strlen calls.
500 ///
501 /// This property corresponds to the GCC 'pure' attribute.
504 }
505
506 /// Check whether or not an instruction may read or write the optionally
507 /// specified memory location.
508 ///
509 ///
510 /// An instruction that doesn't read or write memory may be trivially LICM'd
511 /// for example.
512 ///
513 /// For function calls, this delegates to the alias-analysis specific
514 /// call-site mod-ref behavior queries. Otherwise it delegates to the specific
515 /// helpers above.
517 const std::optional<MemoryLocation> &OptLoc) {
518 SimpleAAQueryInfo AAQIP(*this);
519 return getModRefInfo(I, OptLoc, AAQIP);
520 }
521
522 /// A convenience wrapper for constructing the memory location.
527
528 /// Return information about whether a call and an instruction may refer to
529 /// the same memory locations.
531
532 /// Return information about whether two instructions may refer to the same
533 /// memory locations.
535 const Instruction *I2);
536
537 /// Return information about whether a particular call site modifies
538 /// or reads the specified memory location \p MemLoc before instruction \p I
539 /// in a BasicBlock.
541 const MemoryLocation &MemLoc,
542 DominatorTree *DT) {
543 SimpleAAQueryInfo AAQIP(*this);
544 return callCapturesBefore(I, MemLoc, DT, AAQIP);
545 }
546
547 /// A convenience wrapper to synthesize a memory location.
552
553 /// @}
554 //===--------------------------------------------------------------------===//
555 /// \name Higher level methods for querying mod/ref information.
556 /// @{
557
558 /// Check if it is possible for execution of the specified basic block to
559 /// modify the location Loc.
561 const MemoryLocation &Loc);
562
563 /// A convenience wrapper synthesizing a memory location.
564 bool canBasicBlockModify(const BasicBlock &BB, const Value *P,
567 }
568
569 /// Check if it is possible for the execution of the specified instructions
570 /// to mod\ref (according to the mode) the location Loc.
571 ///
572 /// The instructions to consider are all of the instructions in the range of
573 /// [I1,I2] INCLUSIVE. I1 and I2 must be in the same basic block.
575 const Instruction &I2,
576 const MemoryLocation &Loc,
577 const ModRefInfo Mode);
578
579 /// A convenience wrapper synthesizing a memory location.
581 const Value *Ptr, LocationSize Size,
582 const ModRefInfo Mode) {
583 return canInstructionRangeModRef(I1, I2, MemoryLocation(Ptr, Size), Mode);
584 }
585
586 // CtxI can be nullptr, in which case the query is whether or not the aliasing
587 // relationship holds through the entire function.
589 const MemoryLocation &LocB, AAQueryInfo &AAQI,
590 const Instruction *CtxI = nullptr);
592
594 AAQueryInfo &AAQI,
595 bool IgnoreLocals = false);
597 AAQueryInfo &AAQIP);
599 const MemoryLocation &Loc,
600 AAQueryInfo &AAQI);
602 const CallBase *Call2, AAQueryInfo &AAQI);
604 const MemoryLocation &Loc,
605 AAQueryInfo &AAQI);
607 const MemoryLocation &Loc,
608 AAQueryInfo &AAQI);
610 const MemoryLocation &Loc,
611 AAQueryInfo &AAQI);
613 const MemoryLocation &Loc,
614 AAQueryInfo &AAQI);
616 const MemoryLocation &Loc,
617 AAQueryInfo &AAQI);
619 const MemoryLocation &Loc,
620 AAQueryInfo &AAQI);
622 const MemoryLocation &Loc,
623 AAQueryInfo &AAQI);
625 const MemoryLocation &Loc,
626 AAQueryInfo &AAQI);
628 const std::optional<MemoryLocation> &OptLoc,
629 AAQueryInfo &AAQIP);
631 const Instruction *I2, AAQueryInfo &AAQI);
633 const MemoryLocation &MemLoc,
634 DominatorTree *DT, AAQueryInfo &AAQIP);
636 AAQueryInfo &AAQI);
637
638private:
639 class Concept;
640
641 template <typename T> class Model;
642
643 friend class AAResultBase;
644
645 const TargetLibraryInfo &TLI;
646
647 std::vector<std::unique_ptr<Concept>> AAs;
648
649 std::vector<AnalysisKey *> AADeps;
650
651 friend class BatchAAResults;
652};
653
654/// This class is a wrapper over an AAResults, and it is intended to be used
655/// only when there are no IR changes inbetween queries. BatchAAResults is
656/// reusing the same `AAQueryInfo` to preserve the state across queries,
657/// esentially making AA work in "batch mode". The internal state cannot be
658/// cleared, so to go "out-of-batch-mode", the user must either use AAResults,
659/// or create a new BatchAAResults.
661 AAResults &AA;
662 AAQueryInfo AAQI;
663 SimpleCaptureAnalysis SimpleCA;
664
666
667public:
668 BatchAAResults(AAResults &AAR) : AA(AAR), AAQI(AAR, &SimpleCA) {}
670 : AA(AAR), AAQI(AAR, CA) {}
671
672 AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
673 return AA.alias(LocA, LocB, AAQI);
674 }
675 bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal = false) {
676 return isNoModRef(AA.getModRefInfoMask(Loc, AAQI, OrLocal));
677 }
678 bool pointsToConstantMemory(const Value *P, bool OrLocal = false) {
680 }
682 bool IgnoreLocals = false) {
683 return AA.getModRefInfoMask(Loc, AAQI, IgnoreLocals);
684 }
686 const std::optional<MemoryLocation> &OptLoc) {
687 return AA.getModRefInfo(I, OptLoc, AAQI);
688 }
690 return AA.getModRefInfo(I, Call2, AAQI);
691 }
692 ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
693 return AA.getArgModRefInfo(Call, ArgIdx);
694 }
696 return AA.getMemoryEffects(Call, AAQI);
697 }
698 bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
699 return alias(LocA, LocB) == AliasResult::MustAlias;
700 }
701 bool isMustAlias(const Value *V1, const Value *V2) {
705 }
706 bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
707 return alias(LocA, LocB) == AliasResult::NoAlias;
708 }
710 const MemoryLocation &MemLoc,
711 DominatorTree *DT) {
712 return AA.callCapturesBefore(I, MemLoc, DT, AAQI);
713 }
714
715 /// Assume that values may come from different cycle iterations.
717 AAQI.MayBeCrossIteration = true;
718 }
719
720 /// Disable the use of the dominator tree during alias analysis queries.
721 void disableDominatorTree() { AAQI.UseDominatorTree = false; }
722};
723
724/// Temporarily set the cross iteration mode on a BatchAA instance.
726 BatchAAResults &BAA;
727 bool OrigCrossIteration;
728
729public:
731 : BAA(BAA), OrigCrossIteration(BAA.AAQI.MayBeCrossIteration) {
732 BAA.AAQI.MayBeCrossIteration = CrossIteration;
733 }
735 BAA.AAQI.MayBeCrossIteration = OrigCrossIteration;
736 }
737};
738
739/// Temporary typedef for legacy code that uses a generic \c AliasAnalysis
740/// pointer or reference.
742
743/// A private abstract base class describing the concept of an individual alias
744/// analysis implementation.
745///
746/// This interface is implemented by any \c Model instantiation. It is also the
747/// interface which a type used to instantiate the model must provide.
748///
749/// All of these methods model methods by the same name in the \c
750/// AAResults class. Only differences and specifics to how the
751/// implementations are called are documented here.
753public:
754 virtual ~Concept() = 0;
755
756 //===--------------------------------------------------------------------===//
757 /// \name Alias Queries
758 /// @{
759
760 /// The main low level interface to the alias analysis implementation.
761 /// Returns an AliasResult indicating whether the two pointers are aliased to
762 /// each other. This is the interface that must be implemented by specific
763 /// alias analysis implementations.
764 virtual AliasResult alias(const MemoryLocation &LocA,
765 const MemoryLocation &LocB, AAQueryInfo &AAQI,
766 const Instruction *CtxI) = 0;
767
768 /// Returns an AliasResult indicating whether a specific memory location
769 /// aliases errno.
771 const Module *M) = 0;
772
773 /// @}
774 //===--------------------------------------------------------------------===//
775 /// \name Simple mod/ref information
776 /// @{
777
778 /// Returns a bitmask that should be unconditionally applied to the ModRef
779 /// info of a memory location. This allows us to eliminate Mod and/or Ref from
780 /// the ModRef info based on the knowledge that the memory location points to
781 /// constant and/or locally-invariant memory.
783 AAQueryInfo &AAQI,
784 bool IgnoreLocals) = 0;
785
786 /// Get the ModRef info associated with a pointer argument of a callsite. The
787 /// result's bits are set to indicate the allowed aliasing ModRef kinds. Note
788 /// that these bits do not necessarily account for the overall behavior of
789 /// the function, but rather only provide additional per-argument
790 /// information.
792 unsigned ArgIdx) = 0;
793
794 /// Return the behavior of the given call site.
796 AAQueryInfo &AAQI) = 0;
797
798 /// Return the behavior when calling the given function.
800
801 /// getModRefInfo (for call sites) - Return information about whether
802 /// a particular call site modifies or reads the specified memory location.
804 const MemoryLocation &Loc,
805 AAQueryInfo &AAQI) = 0;
806
807 /// Return information about whether two call sites may refer to the same set
808 /// of memory locations. See the AA documentation for details:
809 /// http://llvm.org/docs/AliasAnalysis.html#ModRefInfo
810 virtual ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
811 AAQueryInfo &AAQI) = 0;
812
813 /// @}
814};
815
816/// A private class template which derives from \c Concept and wraps some other
817/// type.
818///
819/// This models the concept by directly forwarding each interface point to the
820/// wrapped type which must implement a compatible interface. This provides
821/// a type erased binding.
822template <typename AAResultT> class AAResults::Model final : public Concept {
823 AAResultT &Result;
824
825public:
826 explicit Model(AAResultT &Result, AAResults &AAR) : Result(Result) {}
827 ~Model() override = default;
828
829 AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
830 AAQueryInfo &AAQI, const Instruction *CtxI) override {
831 return Result.alias(LocA, LocB, AAQI, CtxI);
832 }
833
834 AliasResult aliasErrno(const MemoryLocation &Loc, const Module *M) override {
835 return Result.aliasErrno(Loc, M);
836 }
837
838 ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, AAQueryInfo &AAQI,
839 bool IgnoreLocals) override {
840 return Result.getModRefInfoMask(Loc, AAQI, IgnoreLocals);
841 }
842
843 ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) override {
844 return Result.getArgModRefInfo(Call, ArgIdx);
845 }
846
847 MemoryEffects getMemoryEffects(const CallBase *Call,
848 AAQueryInfo &AAQI) override {
849 return Result.getMemoryEffects(Call, AAQI);
850 }
851
852 MemoryEffects getMemoryEffects(const Function *F) override {
853 return Result.getMemoryEffects(F);
854 }
855
856 ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
857 AAQueryInfo &AAQI) override {
858 return Result.getModRefInfo(Call, Loc, AAQI);
859 }
860
861 ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
862 AAQueryInfo &AAQI) override {
863 return Result.getModRefInfo(Call1, Call2, AAQI);
864 }
865};
866
867/// A base class to help implement the function alias analysis results concept.
868///
869/// Because of the nature of many alias analysis implementations, they often
870/// only implement a subset of the interface. This base class will attempt to
871/// implement the remaining portions of the interface in terms of simpler forms
872/// of the interface where possible, and otherwise provide conservatively
873/// correct fallback implementations.
874///
875/// Implementors of an alias analysis should derive from this class, and then
876/// override specific methods that they wish to customize. There is no need to
877/// use virtual anywhere.
879protected:
880 explicit AAResultBase() = default;
881
882 // Provide all the copy and move constructors so that derived types aren't
883 // constrained.
884 AAResultBase(const AAResultBase &Arg) = default;
886
887public:
889 AAQueryInfo &AAQI, const Instruction *I) {
891 }
892
896
898 bool IgnoreLocals) {
899 return ModRefInfo::ModRef;
900 }
901
902 ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
903 return ModRefInfo::ModRef;
904 }
905
909
913
918
919 ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
920 AAQueryInfo &AAQI) {
921 return ModRefInfo::ModRef;
922 }
923};
924
925/// Return true if this pointer is returned by a noalias function.
926LLVM_ABI bool isNoAliasCall(const Value *V);
927
928/// Return true if this pointer refers to a distinct and identifiable object.
929/// This returns true for:
930/// Global Variables and Functions (but not Global Aliases)
931/// Allocas
932/// ByVal and NoAlias Arguments
933/// NoAlias returns (e.g. calls to malloc)
934///
935LLVM_ABI bool isIdentifiedObject(const Value *V);
936
937/// Return true if V is umabigously identified at the function-level.
938/// Different IdentifiedFunctionLocals can't alias.
939/// Further, an IdentifiedFunctionLocal can not alias with any function
940/// arguments other than itself, which is not necessarily true for
941/// IdentifiedObjects.
942LLVM_ABI bool isIdentifiedFunctionLocal(const Value *V);
943
944/// Return true if we know V to the base address of the corresponding memory
945/// object. This implies that any address less than V must be out of bounds
946/// for the underlying object. Note that just being isIdentifiedObject() is
947/// not enough - For example, a negative offset from a noalias argument or call
948/// can be inbounds w.r.t the actual underlying object.
949LLVM_ABI bool isBaseOfObject(const Value *V);
950
951/// Returns true if the pointer is one which would have been considered an
952/// escape by isNotCapturedBefore.
953LLVM_ABI bool isEscapeSource(const Value *V);
954
955/// Return true if Object memory is not visible after an unwind, in the sense
956/// that program semantics cannot depend on Object containing any particular
957/// value on unwind. If the RequiresNoCaptureBeforeUnwind out parameter is set
958/// to true, then the memory is only not visible if the object has not been
959/// captured prior to the unwind. Otherwise it is not visible even if captured.
960LLVM_ABI bool isNotVisibleOnUnwind(const Value *Object,
961 bool &RequiresNoCaptureBeforeUnwind);
962
963/// Return true if the Object is writable, in the sense that any location based
964/// on this pointer that can be loaded can also be stored to without trapping.
965/// Additionally, at the point Object is declared, stores can be introduced
966/// without data races. At later points, this is only the case if the pointer
967/// can not escape to a different thread.
968///
969/// If ExplicitlyDereferenceableOnly is set to true, this property only holds
970/// for the part of Object that is explicitly marked as dereferenceable, e.g.
971/// using the dereferenceable(N) attribute. It does not necessarily hold for
972/// parts that are only known to be dereferenceable due to the presence of
973/// loads.
974LLVM_ABI bool isWritableObject(const Value *Object,
975 bool &ExplicitlyDereferenceableOnly);
976
977/// A manager for alias analyses.
978///
979/// This class can have analyses registered with it and when run, it will run
980/// all of them and aggregate their results into single AA results interface
981/// that dispatches across all of the alias analysis results available.
982///
983/// Note that the order in which analyses are registered is very significant.
984/// That is the order in which the results will be aggregated and queried.
985///
986/// This manager effectively wraps the AnalysisManager for registering alias
987/// analyses. When you register your alias analysis with this manager, it will
988/// ensure the analysis itself is registered with its AnalysisManager.
989///
990/// The result of this analysis is only invalidated if one of the particular
991/// aggregated AA results end up being invalidated. This removes the need to
992/// explicitly preserve the results of `AAManager`. Note that analyses should no
993/// longer be registered once the `AAManager` is run.
994class AAManager : public AnalysisInfoMixin<AAManager> {
995public:
997
998 /// Register a specific AA result.
999 template <typename AnalysisT> void registerFunctionAnalysis() {
1000 ResultGetters.push_back(&getFunctionAAResultImpl<AnalysisT>);
1001 }
1002
1003 /// Register a specific AA result.
1004 template <typename AnalysisT> void registerModuleAnalysis() {
1005 ResultGetters.push_back(&getModuleAAResultImpl<AnalysisT>);
1006 }
1007
1009
1010private:
1012
1013 LLVM_ABI static AnalysisKey Key;
1014
1017 4> ResultGetters;
1018
1019 template <typename AnalysisT>
1020 static void getFunctionAAResultImpl(Function &F,
1023 AAResults.addAAResult(AM.template getResult<AnalysisT>(F));
1024 AAResults.addAADependencyID(AnalysisT::ID());
1025 }
1026
1027 template <typename AnalysisT>
1028 static void getModuleAAResultImpl(Function &F, FunctionAnalysisManager &AM,
1029 AAResults &AAResults) {
1030 auto &MAMProxy = AM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
1031 if (auto *R =
1032 MAMProxy.template getCachedResult<AnalysisT>(*F.getParent())) {
1033 AAResults.addAAResult(*R);
1034 MAMProxy
1035 .template registerOuterAnalysisInvalidation<AnalysisT, AAManager>();
1036 }
1037 }
1038};
1039
1040/// A wrapper pass to provide the legacy pass manager access to a suitably
1041/// prepared AAResults object.
1043 std::unique_ptr<AAResults> AAR;
1044
1045public:
1046 static char ID;
1047
1049
1050 AAResults &getAAResults() { return *AAR; }
1051 const AAResults &getAAResults() const { return *AAR; }
1052
1053 bool runOnFunction(Function &F) override;
1054
1055 void getAnalysisUsage(AnalysisUsage &AU) const override;
1056};
1057
1058/// A wrapper pass for external alias analyses. This just squirrels away the
1059/// callback used to run any analyses and register their results.
1061 using CallbackT = std::function<void(Pass &, Function &, AAResults &)>;
1062
1064
1065 LLVM_ABI static char ID;
1066
1068
1069 LLVM_ABI explicit ExternalAAWrapperPass(CallbackT CB, bool RunEarly = false);
1070
1071 /// Flag indicating whether this external AA should run before Basic AA.
1072 ///
1073 /// This flag is for LegacyPassManager only. To run an external AA early
1074 /// with the NewPassManager, override the registerEarlyDefaultAliasAnalyses
1075 /// method on the target machine.
1076 ///
1077 /// By default, external AA passes are run after Basic AA. If this flag is
1078 /// set to true, the external AA will be run before Basic AA during alias
1079 /// analysis.
1080 ///
1081 /// For some targets, we prefer to run the external AA early to improve
1082 /// compile time as it has more target-specific information. This is
1083 /// particularly useful when the external AA can provide more precise results
1084 /// than Basic AA so that Basic AA does not need to spend time recomputing
1085 /// them.
1086 bool RunEarly = false;
1087
1088 void getAnalysisUsage(AnalysisUsage &AU) const override {
1089 AU.setPreservesAll();
1090 }
1091};
1092
1093/// A wrapper pass around a callback which can be used to populate the
1094/// AAResults in the AAResultsWrapperPass from an external AA.
1095///
1096/// The callback provided here will be used each time we prepare an AAResults
1097/// object, and will receive a reference to the function wrapper pass, the
1098/// function, and the AAResults object to populate. This should be used when
1099/// setting up a custom pass pipeline to inject a hook into the AA results.
1101 std::function<void(Pass &, Function &, AAResults &)> Callback);
1102
1103} // end namespace llvm
1104
1105#endif // LLVM_ANALYSIS_ALIASANALYSIS_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI
Definition Compiler.h:213
This file defines the DenseMap class.
static bool runOnFunction(Function &F, bool PostInlining)
This header defines various interfaces for pass management in LLVM.
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
Machine Check Debug Module
This file provides utility analysis objects describing memory locations.
#define P(N)
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
This file defines the SmallVector class.
Value * RHS
Value * LHS
A manager for alias analyses.
void registerFunctionAnalysis()
Register a specific AA result.
LLVM_ABI 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
SmallDenseMap< LocPair, CacheEntry, 8 > AliasCacheT
bool MayBeCrossIteration
Tracks whether the accesses may be on different cycle iterations.
CaptureAnalysis * CA
ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2, AAQueryInfo &AAQI)
AAResultBase(const AAResultBase &Arg)=default
MemoryEffects getMemoryEffects(const CallBase *Call, AAQueryInfo &AAQI)
ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, AAQueryInfo &AAQI, bool IgnoreLocals)
MemoryEffects getMemoryEffects(const Function *F)
AliasResult aliasErrno(const MemoryLocation &Loc, const Module *M)
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)
const AAResults & getAAResults() const
A private abstract base class describing the concept of an individual alias analysis implementation.
virtual AliasResult aliasErrno(const MemoryLocation &Loc, const Module *M)=0
Returns an AliasResult indicating whether a specific memory location aliases errno.
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.
friend class AAResultBase
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.
LLVM_ABI AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
The main low level interface to the alias analysis implementation.
friend class BatchAAResults
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.
LLVM_ABI 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...
LLVM_ABI AAResults(const TargetLibraryInfo &TLI)
LLVM_ABI 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.
LLVM_ABI bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)
Handle invalidation events in the new pass manager.
LLVM_ABI 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 ...
LLVM_ABI 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.
LLVM_ABI AliasResult aliasErrno(const MemoryLocation &Loc, const Module *M)
void addAAResult(AAResultT &AAResult)
Register a specific AA result.
void addAADependencyID(AnalysisKey *ID)
Register a function analysis ID that the results aggregation depends on.
LLVM_ABI ~AAResults()
ModRefInfo callCapturesBefore(const Instruction *I, const Value *P, LocationSize Size, DominatorTree *DT)
A convenience wrapper to synthesize a memory location.
LLVM_ABI 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.
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.
@ NoAlias
The two locations do not alias at all.
@ 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
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,...
an instruction that atomically reads a memory location, combines it with another value,...
LLVM Basic Block Representation.
Definition BasicBlock.h:62
BatchAACrossIterationScope(BatchAAResults &BAA, bool CrossIteration)
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)
friend class BatchAACrossIterationScope
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)
bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
MemoryEffects getMemoryEffects(const CallBase *Call)
bool isMustAlias(const Value *V1, const Value *V2)
ModRefInfo getModRefInfo(const Instruction *I, const std::optional< MemoryLocation > &OptLoc)
bool pointsToConstantMemory(const Value *P, bool OrLocal=false)
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...
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition Dominators.h:159
EarliestEscapeAnalysis(DominatorTree &DT, const LoopInfo *LI=nullptr, const CycleInfo *CI=nullptr)
An instruction for ordering other memory operations.
FunctionPass(char &pid)
Definition Pass.h:316
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition Pass.h:285
ImmutablePass(char &pid)
Definition Pass.h:287
An instruction for reading from memory.
static LocationSize precise(uint64_t Value)
bool doesNotAccessMemory() const
Whether this function accesses no memory.
Definition ModRef.h:246
bool onlyReadsMemory() const
Whether this function only (at most) reads memory.
Definition ModRef.h:249
static MemoryEffectsBase unknown()
Definition ModRef.h:123
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...
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
Pass interface - Implemented by all 'passes'.
Definition Pass.h:99
PointerIntPair - This class implements a pair of a pointer and small integer.
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
AAQueryInfo that uses SimpleCaptureAnalysis.
SimpleAAQueryInfo(AAResults &AAR)
Context-free CaptureAnalysis provider, which computes and caches whether an object is captured in the...
CaptureComponents getCapturesBefore(const Value *Object, const Instruction *I, bool OrAt) override
Return how Object may be captured before instruction I, considering only provenance captures.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
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:75
CallInst * Call
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
This is an optimization pass for GlobalISel generic memory operations.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
Definition MathExtras.h:165
OuterAnalysisManagerProxy< ModuleAnalysisManager, Function > ModuleAnalysisManagerFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
LLVM_ABI bool isBaseOfObject(const Value *V)
Return true if we know V to the base address of the corresponding memory object.
LLVM_ABI bool isNoAliasCall(const Value *V)
Return true if this pointer is returned by a noalias function.
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
Definition ModRef.h:356
LLVM_ABI 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...
CaptureComponents
Components of the pointer that may be captured.
Definition ModRef.h:365
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
Definition ModRef.h:28
@ ModRef
The access may reference and may modify the value stored in memory.
Definition ModRef.h:36
@ Other
Any other memory.
Definition ModRef.h:68
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
LLVM_ABI bool isIdentifiedFunctionLocal(const Value *V)
Return true if V is umabigously identified at the function-level.
LLVM_ABI bool isEscapeSource(const Value *V)
Returns true if the pointer is one which would have been considered an escape by isNotCapturedBefore.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
AAResults AliasAnalysis
Temporary typedef for legacy code that uses a generic AliasAnalysis pointer or reference.
bool isNoModRef(const ModRefInfo MRI)
Definition ModRef.h:40
LLVM_ABI bool isIdentifiedObject(const Value *V)
Return true if this pointer refers to a distinct and identifiable object.
LLVM_ABI 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 ...
LLVM_ABI 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...
Cache key for BasicAA results.
PointerIntPair< const Value *, 1, bool > PtrTy
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:93
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition Analysis.h:29
Virtual base class for providers of capture analysis.
virtual CaptureComponents getCapturesBefore(const Value *Object, const Instruction *I, bool OrAt)=0
Return how Object may be captured before instruction I, considering only provenance captures.
virtual ~CaptureAnalysis()=0
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...
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
static LLVM_ABI char ID
bool RunEarly
Flag indicating whether this external AA should run before Basic AA.