LLVM 24.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"
44#include "llvm/IR/Function.h"
45#include "llvm/IR/PassManager.h"
46#include "llvm/Pass.h"
48#include "llvm/Support/ModRef.h"
49#include <cstdint>
50#include <functional>
51#include <memory>
52#include <optional>
53#include <vector>
54
55namespace llvm {
56
58class BasicBlock;
59class CatchPadInst;
60class CatchReturnInst;
61class CycleInfo;
62class DominatorTree;
63class FenceInst;
64class LoopInfo;
66
67/// The possible results of an alias query.
68///
69/// These results are always computed between two MemoryLocation objects as
70/// a query to some alias analysis.
71///
72/// Note that these are unscoped enumerations because we would like to support
73/// implicitly testing a result for the existence of any possible aliasing with
74/// a conversion to bool, but an "enum class" doesn't support this. The
75/// canonical names from the literature are suffixed and unique anyways, and so
76/// they serve as global constants in LLVM for these results.
77///
78/// See docs/AliasAnalysis.html for more information on the specific meanings
79/// of these values.
81private:
82 static const int OffsetBits = 23;
83 static const int AliasBits = 8;
84 static_assert(AliasBits + 1 + OffsetBits <= 32,
85 "AliasResult size is intended to be 4 bytes!");
86
87 unsigned int Alias : AliasBits;
88 unsigned int HasOffset : 1;
89 signed int Offset : OffsetBits;
90
91public:
92 enum Kind : uint8_t {
93 /// The two locations do not alias at all.
94 ///
95 /// This value is arranged to convert to false, while all other values
96 /// convert to true. This allows a boolean context to convert the result to
97 /// a binary flag indicating whether there is the possibility of aliasing.
99 /// The two locations may or may not alias. This is the least precise
100 /// result.
102 /// The two locations alias, but only due to a partial overlap.
104 /// The two locations precisely alias each other.
106 };
107 static_assert(MustAlias < (1 << AliasBits),
108 "Not enough bit field size for the enum!");
109
110 explicit AliasResult() = delete;
111 constexpr AliasResult(const Kind &Alias)
112 : Alias(Alias), HasOffset(false), Offset(0) {}
113
114 operator Kind() const { return static_cast<Kind>(Alias); }
115
116 bool operator==(const AliasResult &Other) const {
117 return Alias == Other.Alias && HasOffset == Other.HasOffset &&
118 Offset == Other.Offset;
119 }
120 bool operator!=(const AliasResult &Other) const { return !(*this == Other); }
121
122 bool operator==(Kind K) const { return Alias == K; }
123 bool operator!=(Kind K) const { return !(*this == K); }
124
125 constexpr bool hasOffset() const { return HasOffset; }
126 constexpr int32_t getOffset() const {
127 assert(HasOffset && "No offset!");
128 return Offset;
129 }
130 void setOffset(int32_t NewOffset) {
131 if (isInt<OffsetBits>(NewOffset)) {
132 HasOffset = true;
133 Offset = NewOffset;
134 }
135 }
136
137 /// Helper for processing AliasResult for swapped memory location pairs.
138 void swap(bool DoSwap = true) {
139 if (DoSwap && hasOffset())
141 }
142};
143
144static_assert(sizeof(AliasResult) == 4,
145 "AliasResult size is intended to be 4 bytes!");
146
147/// << operator for AliasResult.
148LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, AliasResult AR);
149
150/// Virtual base class for providers of capture analysis.
152 virtual ~CaptureAnalysis() = 0;
153
154 /// Return how Object may be captured before instruction I, considering only
155 /// provenance captures. If OrAt is true, captures by instruction I itself
156 /// are also considered.
157 ///
158 /// If I is nullptr, then captures at any point will be considered.
160 const Instruction *I, bool OrAt,
161 bool ReturnCaptures) = 0;
162};
163
164/// Context-free CaptureAnalysis provider, which computes and caches whether an
165/// object is captured in the function at all, but does not distinguish whether
166/// it was captured before or after the context instruction.
169
170public:
172 bool OrAt, bool ReturnCaptures) override;
173};
174
175/// Context-sensitive CaptureAnalysis provider, which computes and caches the
176/// earliest common dominator closure of all captures. It provides a good
177/// approximation to a precise "captures before" analysis.
179 DominatorTree &DT;
180 const LoopInfo *LI;
181 const CycleInfo *CI;
182
183 /// Map from identified local object to an instruction before which it does
184 /// not escape (or nullptr if it never escapes) and the possible components
185 /// that may be captured (by any instruction, not necessarily the earliest
186 /// one). The "earliest" instruction may be a conservative approximation,
187 /// e.g. the first instruction in the function is always a legal choice.
189 EarliestEscapes;
190
191 /// Reverse map from instruction to the objects it is the earliest escape for.
192 /// This is used for cache invalidation purposes.
194
195public:
197 const CycleInfo *CI = nullptr)
198 : DT(DT), LI(LI), CI(CI) {}
199
200 CaptureComponents getCapturesBefore(const Value *Object, const Instruction *I,
201 bool OrAt, bool ReturnCaptures) override;
202
203 void removeInstruction(Instruction *I);
204};
205
206/// Cache key for BasicAA results. It only includes the pointer and size from
207/// MemoryLocation, as BasicAA is AATags independent. Additionally, it includes
208/// the value of MayBeCrossIteration, which may affect BasicAA results.
213
215 AACacheLoc(const Value *Ptr, LocationSize Size, bool MayBeCrossIteration)
216 : Ptr(Ptr, MayBeCrossIteration), Size(Size) {}
217};
218
219template <> struct DenseMapInfo<AACacheLoc> {
224 static bool isEqual(const AACacheLoc &LHS, const AACacheLoc &RHS) {
225 return LHS.Ptr == RHS.Ptr && LHS.Size == RHS.Size;
226 }
227};
228
229class AAResults;
230
231/// This class stores info we want to provide to or retain within an alias
232/// query. By default, the root query is stateless and starts with a freshly
233/// constructed info object. Specific alias analyses can use this query info to
234/// store per-query state that is important for recursive or nested queries to
235/// avoid recomputing. To enable preserving this state across multiple queries
236/// where safe (due to the IR not changing), use a `BatchAAResults` wrapper.
237/// The information stored in an `AAQueryInfo` is currently limitted to the
238/// caches used by BasicAA, but can further be extended to fit other AA needs.
240public:
241 using LocPair = std::pair<AACacheLoc, AACacheLoc>;
242 struct CacheEntry {
243 /// Cache entry is neither an assumption nor does it use a (non-definitive)
244 /// assumption.
245 static constexpr int Definitive = -2;
246 /// Cache entry is not an assumption itself, but may be using an assumption
247 /// from higher up the stack.
248 static constexpr int AssumptionBased = -1;
249
251 /// Number of times a NoAlias assumption has been used, 0 for assumptions
252 /// that have not been used. Can also take one of the Definitive or
253 /// AssumptionBased values documented above.
255
256 /// Whether this is a definitive (non-assumption) result.
257 bool isDefinitive() const { return NumAssumptionUses == Definitive; }
258 /// Whether this is an assumption that has not been proven yet.
259 bool isAssumption() const { return NumAssumptionUses >= 0; }
260 };
261
262 // Alias analysis result aggregration using which this query is performed.
263 // Can be used to perform recursive queries.
265
268
270
271 /// Query depth used to distinguish recursive queries.
272 unsigned Depth = 0;
273
274 /// How many active NoAlias assumption uses there are.
276
277 /// Location pairs for which an assumption based result is currently stored.
278 /// Used to remove all potentially incorrect results from the cache if an
279 /// assumption is disproven.
281
282 /// Tracks whether the accesses may be on different cycle iterations.
283 ///
284 /// When interpret "Value" pointer equality as value equality we need to make
285 /// sure that the "Value" is not part of a cycle. Otherwise, two uses could
286 /// come from different "iterations" of a cycle and see different values for
287 /// the same "Value" pointer.
288 ///
289 /// The following example shows the problem:
290 /// %p = phi(%alloca1, %addr2)
291 /// %l = load %ptr
292 /// %addr1 = gep, %alloca2, 0, %l
293 /// %addr2 = gep %alloca2, 0, (%l + 1)
294 /// alias(%p, %addr1) -> MayAlias !
295 /// store %l, ...
297
298 /// Whether alias analysis is allowed to use the dominator tree, for use by
299 /// passes that lazily update the DT while performing AA queries.
300 bool UseDominatorTree = true;
301
303};
304
305/// AAQueryInfo that uses SimpleCaptureAnalysis.
308
309public:
311};
312
313class BatchAAResults;
314
316public:
317 // Make these results default constructable and movable. We have to spell
318 // these out because MSVC won't synthesize them.
322
323 /// Register a specific AA result.
324 template <typename AAResultT> void addAAResult(AAResultT &AAResult) {
325 // FIXME: We should use a much lighter weight system than the usual
326 // polymorphic pattern because we don't own AAResult. It should
327 // ideally involve two pointers and no separate allocation.
328 AAs.emplace_back(new Model<AAResultT>(AAResult, *this));
329 }
330
331 /// Register a function analysis ID that the results aggregation depends on.
332 ///
333 /// This is used in the new pass manager to implement the invalidation logic
334 /// where we must invalidate the results aggregation if any of our component
335 /// analyses become invalid.
336 void addAADependencyID(AnalysisKey *ID) { AADeps.push_back(ID); }
337
338 /// Handle invalidation events in the new pass manager.
339 ///
340 /// The aggregation is invalidated if any of the underlying analyses is
341 /// invalidated.
343 FunctionAnalysisManager::Invalidator &Inv);
344
345 //===--------------------------------------------------------------------===//
346 /// \name Alias Queries
347 /// @{
348
349 /// The main low level interface to the alias analysis implementation.
350 /// Returns an AliasResult indicating whether the two pointers are aliased to
351 /// each other. This is the interface that must be implemented by specific
352 /// alias analysis implementations.
354 const MemoryLocation &LocB);
355
356 /// A convenience wrapper around the primary \c alias interface.
357 AliasResult alias(const Value *V1, LocationSize V1Size, const Value *V2,
358 LocationSize V2Size) {
359 return alias(MemoryLocation(V1, V1Size), MemoryLocation(V2, V2Size));
360 }
361
362 /// A convenience wrapper around the primary \c alias interface.
367
368 /// A trivial helper function to check to see if the specified pointers are
369 /// no-alias.
370 bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
371 return alias(LocA, LocB) == AliasResult::NoAlias;
372 }
373
374 /// A convenience wrapper around the \c isNoAlias helper interface.
375 bool isNoAlias(const Value *V1, LocationSize V1Size, const Value *V2,
376 LocationSize V2Size) {
377 return isNoAlias(MemoryLocation(V1, V1Size), MemoryLocation(V2, V2Size));
378 }
379
380 /// A convenience wrapper around the \c isNoAlias helper interface.
385
386 /// A trivial helper function to check to see if the specified pointers are
387 /// must-alias.
388 bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
389 return alias(LocA, LocB) == AliasResult::MustAlias;
390 }
391
392 /// A convenience wrapper around the \c isMustAlias helper interface.
393 bool isMustAlias(const Value *V1, const Value *V2) {
396 }
397
398 /// Checks whether the given location points to constant memory, or if
399 /// \p OrLocal is true whether it points to a local alloca.
400 bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal = false) {
401 return isNoModRef(getModRefInfoMask(Loc, OrLocal));
402 }
403
404 /// A convenience wrapper around the primary \c pointsToConstantMemory
405 /// interface.
406 bool pointsToConstantMemory(const Value *P, bool OrLocal = false) {
408 }
409
410 /// @}
411 //===--------------------------------------------------------------------===//
412 /// \name Simple mod/ref information
413 /// @{
414
415 /// Returns a bitmask that should be unconditionally applied to the ModRef
416 /// info of a memory location. This allows us to eliminate Mod and/or Ref
417 /// from the ModRef info based on the knowledge that the memory location
418 /// points to constant and/or locally-invariant memory.
419 ///
420 /// If IgnoreLocals is true, then this method returns NoModRef for memory
421 /// that points to a local alloca.
423 bool IgnoreLocals = false);
424
425 /// A convenience wrapper around the primary \c getModRefInfoMask
426 /// interface.
427 ModRefInfo getModRefInfoMask(const Value *P, bool IgnoreLocals = false) {
429 }
430
431 /// Get the ModRef info associated with a pointer argument of a call. The
432 /// result's bits are set to indicate the allowed aliasing ModRef kinds. Note
433 /// that these bits do not necessarily account for the overall behavior of
434 /// the function, but rather only provide additional per-argument
435 /// information.
436 LLVM_ABI ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx);
437
438 /// Return the behavior of the given call site.
440
441 /// Return the behavior when calling the given function.
443
444 /// Checks if the specified call is known to never read or write memory.
445 ///
446 /// Note that if the call only reads from known-constant memory, it is also
447 /// legal to return true. Also, calls that unwind the stack are legal for
448 /// this predicate.
449 ///
450 /// Many optimizations (such as CSE and LICM) can be performed on such calls
451 /// without worrying about aliasing properties, and many calls have this
452 /// property (e.g. calls to 'sin' and 'cos').
453 ///
454 /// This property corresponds to the GCC 'const' attribute.
458
459 /// Checks if the specified call is known to only read from non-volatile
460 /// memory (or not access memory at all).
461 ///
462 /// Calls that unwind the stack are legal for this predicate.
463 ///
464 /// This property allows many common optimizations to be performed in the
465 /// absence of interfering store instructions, such as CSE of strlen calls.
466 ///
467 /// This property corresponds to the GCC 'pure' attribute.
471
472 /// Check whether or not an instruction may read or write the optionally
473 /// specified memory location.
474 ///
475 ///
476 /// An instruction that doesn't read or write memory may be trivially LICM'd
477 /// for example.
478 ///
479 /// For function calls, this delegates to the alias-analysis specific
480 /// call-site mod-ref behavior queries. Otherwise it delegates to the specific
481 /// helpers above.
483 const std::optional<MemoryLocation> &OptLoc) {
484 SimpleAAQueryInfo AAQIP(*this);
485 return getModRefInfo(I, OptLoc, AAQIP);
486 }
487
488 /// A convenience wrapper for constructing the memory location.
493
494 /// Return information about whether a call and an instruction may refer to
495 /// the same memory locations.
497
498 /// Return information about whether two instructions may refer to the same
499 /// memory locations.
501 const Instruction *I2);
502
503 /// Return information about whether a particular call site modifies
504 /// or reads the specified memory location \p MemLoc before instruction \p I
505 /// in a BasicBlock.
507 const MemoryLocation &MemLoc,
508 DominatorTree *DT) {
509 SimpleAAQueryInfo AAQIP(*this);
510 return callCapturesBefore(I, MemLoc, DT, AAQIP);
511 }
512
513 /// @}
514 //===--------------------------------------------------------------------===//
515 /// \name Higher level methods for querying mod/ref information.
516 /// @{
517
518 /// Check if it is possible for execution of the specified basic block to
519 /// modify the location Loc.
521 const MemoryLocation &Loc);
522
523 /// Check if it is possible for the execution of the specified instructions
524 /// to mod\ref (according to the mode) the location Loc.
525 ///
526 /// The instructions to consider are all of the instructions in the range of
527 /// [I1,I2] INCLUSIVE. I1 and I2 must be in the same basic block.
529 const Instruction &I2,
530 const MemoryLocation &Loc,
531 const ModRefInfo Mode);
532
533 // CtxI can be nullptr, in which case the query is whether or not the aliasing
534 // relationship holds through the entire function.
536 const MemoryLocation &LocB, AAQueryInfo &AAQI,
537 const Instruction *CtxI = nullptr);
539 const Instruction *CtxI);
540
542 AAQueryInfo &AAQI,
543 bool IgnoreLocals = false);
545 AAQueryInfo &AAQIP);
547 const MemoryLocation &Loc,
548 AAQueryInfo &AAQI);
550 const CallBase *Call2, AAQueryInfo &AAQI);
552 const MemoryLocation &Loc,
553 AAQueryInfo &AAQI);
555 const MemoryLocation &Loc,
556 AAQueryInfo &AAQI);
558 const MemoryLocation &Loc,
559 AAQueryInfo &AAQI);
561 const MemoryLocation &Loc,
562 AAQueryInfo &AAQI);
564 const MemoryLocation &Loc,
565 AAQueryInfo &AAQI);
567 const MemoryLocation &Loc,
568 AAQueryInfo &AAQI);
570 const MemoryLocation &Loc,
571 AAQueryInfo &AAQI);
573 const MemoryLocation &Loc,
574 AAQueryInfo &AAQI);
576 const std::optional<MemoryLocation> &OptLoc,
577 AAQueryInfo &AAQIP);
579 const Instruction *I2, AAQueryInfo &AAQI);
581 const MemoryLocation &MemLoc,
582 DominatorTree *DT, AAQueryInfo &AAQIP);
584 AAQueryInfo &AAQI);
585
586private:
587 class Concept;
588
589 template <typename T> class Model;
590
591 friend class AAResultBase;
592
593 const TargetLibraryInfo &TLI;
594
595 std::vector<std::unique_ptr<Concept>> AAs;
596
597 std::vector<AnalysisKey *> AADeps;
598
599 friend class BatchAAResults;
600};
601
602/// This class is a wrapper over an AAResults, and it is intended to be used
603/// only when there are no IR changes inbetween queries. BatchAAResults is
604/// reusing the same `AAQueryInfo` to preserve the state across queries,
605/// esentially making AA work in "batch mode". The internal state cannot be
606/// cleared, so to go "out-of-batch-mode", the user must either use AAResults,
607/// or create a new BatchAAResults.
609 AAResults &AA;
610 AAQueryInfo AAQI;
611 SimpleCaptureAnalysis SimpleCA;
612
614
615public:
616 BatchAAResults(AAResults &AAR) : AA(AAR), AAQI(AAR, &SimpleCA) {}
618 : AA(AAR), AAQI(AAR, CA) {}
619
620 AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
621 return AA.alias(LocA, LocB, AAQI);
622 }
623 bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal = false) {
624 return isNoModRef(AA.getModRefInfoMask(Loc, AAQI, OrLocal));
625 }
626 bool pointsToConstantMemory(const Value *P, bool OrLocal = false) {
628 }
630 bool IgnoreLocals = false) {
631 return AA.getModRefInfoMask(Loc, AAQI, IgnoreLocals);
632 }
634 const std::optional<MemoryLocation> &OptLoc) {
635 return AA.getModRefInfo(I, OptLoc, AAQI);
636 }
638 return AA.getModRefInfo(I, Call2, AAQI);
639 }
641 return AA.getModRefInfo(I, I2, AAQI);
642 }
643 ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
644 return AA.getArgModRefInfo(Call, ArgIdx);
645 }
647 return AA.getMemoryEffects(Call, AAQI);
648 }
649 bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
650 return alias(LocA, LocB) == AliasResult::MustAlias;
651 }
657 bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
658 return alias(LocA, LocB) == AliasResult::NoAlias;
659 }
661 const MemoryLocation &MemLoc,
662 DominatorTree *DT) {
663 return AA.callCapturesBefore(I, MemLoc, DT, AAQI);
664 }
665
666 /// Assume that values may come from different cycle iterations.
668 AAQI.MayBeCrossIteration = true;
669 }
670
671 /// Disable the use of the dominator tree during alias analysis queries.
672 void disableDominatorTree() { AAQI.UseDominatorTree = false; }
673};
674
675/// Temporarily set the cross iteration mode on a BatchAA instance.
677 BatchAAResults &BAA;
678 bool OrigCrossIteration;
679
680public:
682 : BAA(BAA), OrigCrossIteration(BAA.AAQI.MayBeCrossIteration) {
683 BAA.AAQI.MayBeCrossIteration = CrossIteration;
684 }
686 BAA.AAQI.MayBeCrossIteration = OrigCrossIteration;
687 }
688};
689
690/// Temporary typedef for legacy code that uses a generic \c AliasAnalysis
691/// pointer or reference.
693
694/// A private abstract base class describing the concept of an individual alias
695/// analysis implementation.
696///
697/// This interface is implemented by any \c Model instantiation. It is also the
698/// interface which a type used to instantiate the model must provide.
699///
700/// All of these methods model methods by the same name in the \c
701/// AAResults class. Only differences and specifics to how the
702/// implementations are called are documented here.
704public:
705 virtual ~Concept() = 0;
706
707 //===--------------------------------------------------------------------===//
708 /// \name Alias Queries
709 /// @{
710
711 /// The main low level interface to the alias analysis implementation.
712 /// Returns an AliasResult indicating whether the two pointers are aliased to
713 /// each other. This is the interface that must be implemented by specific
714 /// alias analysis implementations.
715 virtual AliasResult alias(const MemoryLocation &LocA,
716 const MemoryLocation &LocB, AAQueryInfo &AAQI,
717 const Instruction *CtxI) = 0;
718
719 /// Returns an AliasResult indicating whether a specific memory location
720 /// aliases errno.
722 const Instruction *CtxI) = 0;
723
724 /// @}
725 //===--------------------------------------------------------------------===//
726 /// \name Simple mod/ref information
727 /// @{
728
729 /// Returns a bitmask that should be unconditionally applied to the ModRef
730 /// info of a memory location. This allows us to eliminate Mod and/or Ref from
731 /// the ModRef info based on the knowledge that the memory location points to
732 /// constant and/or locally-invariant memory.
734 AAQueryInfo &AAQI,
735 bool IgnoreLocals) = 0;
736
737 /// Get the ModRef info associated with a pointer argument of a callsite. The
738 /// result's bits are set to indicate the allowed aliasing ModRef kinds. Note
739 /// that these bits do not necessarily account for the overall behavior of
740 /// the function, but rather only provide additional per-argument
741 /// information.
743 unsigned ArgIdx) = 0;
744
745 /// Return the behavior of the given call site.
747 AAQueryInfo &AAQI) = 0;
748
749 /// Return the behavior when calling the given function.
751
752 /// getModRefInfo (for call sites) - Return information about whether
753 /// a particular call site modifies or reads the specified memory location.
755 const MemoryLocation &Loc,
756 AAQueryInfo &AAQI) = 0;
757
758 /// Return information about whether two call sites may refer to the same set
759 /// of memory locations. See the AA documentation for details:
760 /// http://llvm.org/docs/AliasAnalysis.html#ModRefInfo
761 virtual ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
762 AAQueryInfo &AAQI) = 0;
763
764 /// getModRefInfo (for fences) - Return information about whether
765 /// a particular fence modifies or reads the specified memory location.
767 const MemoryLocation &Loc,
768 AAQueryInfo &AAQI) = 0;
769
770 /// @}
771};
772
773/// A private class template which derives from \c Concept and wraps some other
774/// type.
775///
776/// This models the concept by directly forwarding each interface point to the
777/// wrapped type which must implement a compatible interface. This provides
778/// a type erased binding.
779template <typename AAResultT> class AAResults::Model final : public Concept {
780 AAResultT &Result;
781
782public:
783 explicit Model(AAResultT &Result, AAResults &AAR) : Result(Result) {}
784 ~Model() override = default;
785
786 AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
787 AAQueryInfo &AAQI, const Instruction *CtxI) override {
788 return Result.alias(LocA, LocB, AAQI, CtxI);
789 }
790
791 AliasResult aliasErrno(const MemoryLocation &Loc,
792 const Instruction *CtxI) override {
793 return Result.aliasErrno(Loc, CtxI);
794 }
795
796 ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, AAQueryInfo &AAQI,
797 bool IgnoreLocals) override {
798 return Result.getModRefInfoMask(Loc, AAQI, IgnoreLocals);
799 }
800
801 ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) override {
802 return Result.getArgModRefInfo(Call, ArgIdx);
803 }
804
805 MemoryEffects getMemoryEffects(const CallBase *Call,
806 AAQueryInfo &AAQI) override {
807 return Result.getMemoryEffects(Call, AAQI);
808 }
809
810 MemoryEffects getMemoryEffects(const Function *F) override {
811 return Result.getMemoryEffects(F);
812 }
813
814 ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
815 AAQueryInfo &AAQI) override {
816 return Result.getModRefInfo(Call, Loc, AAQI);
817 }
818
819 ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
820 AAQueryInfo &AAQI) override {
821 return Result.getModRefInfo(Call1, Call2, AAQI);
822 }
823
824 ModRefInfo getModRefInfo(const FenceInst *F, const MemoryLocation &Loc,
825 AAQueryInfo &AAQI) override {
826 return Result.getModRefInfo(F, Loc, AAQI);
827 }
828};
829
830/// A base class to help implement the function alias analysis results concept.
831///
832/// Because of the nature of many alias analysis implementations, they often
833/// only implement a subset of the interface. This base class will attempt to
834/// implement the remaining portions of the interface in terms of simpler forms
835/// of the interface where possible, and otherwise provide conservatively
836/// correct fallback implementations.
837///
838/// Implementors of an alias analysis should derive from this class, and then
839/// override specific methods that they wish to customize. There is no need to
840/// use virtual anywhere.
842protected:
843 explicit AAResultBase() = default;
844
845 // Provide all the copy and move constructors so that derived types aren't
846 // constrained.
847 AAResultBase(const AAResultBase &Arg) = default;
849
850public:
852 AAQueryInfo &AAQI, const Instruction *I) {
854 }
855
859
861 bool IgnoreLocals) {
862 return ModRefInfo::ModRef;
863 }
864
865 ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
866 return ModRefInfo::ModRef;
867 }
868
872
876
881
882 ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
883 AAQueryInfo &AAQI) {
884 return ModRefInfo::ModRef;
885 }
886
888 AAQueryInfo &AAQI) {
889 return ModRefInfo::ModRef;
890 }
891};
892
893/// Return true if this pointer is returned by a noalias function.
894LLVM_ABI bool isNoAliasCall(const Value *V);
895
896/// Return true if this pointer refers to a distinct and identifiable object.
897/// This returns true for:
898/// Global Variables and Functions (but not Global Aliases)
899/// Allocas
900/// ByVal and NoAlias Arguments
901/// NoAlias returns (e.g. calls to malloc)
902///
903LLVM_ABI bool isIdentifiedObject(const Value *V);
904
905/// Return true if V is umabigously identified at the function-level.
906/// Different IdentifiedFunctionLocals can't alias.
907/// Further, an IdentifiedFunctionLocal can not alias with any function
908/// arguments other than itself, which is not necessarily true for
909/// IdentifiedObjects.
910LLVM_ABI bool isIdentifiedFunctionLocal(const Value *V);
911
912/// Return true if we know V to the base address of the corresponding memory
913/// object. This implies that any address less than V must be out of bounds
914/// for the underlying object. Note that just being isIdentifiedObject() is
915/// not enough - For example, a negative offset from a noalias argument or call
916/// can be inbounds w.r.t the actual underlying object.
917LLVM_ABI bool isBaseOfObject(const Value *V);
918
919/// Returns true if the pointer is one which would have been considered an
920/// escape by isNotCapturedBefore.
921LLVM_ABI bool isEscapeSource(const Value *V);
922
923/// Return true if Object memory is not visible after an unwind, in the sense
924/// that program semantics cannot depend on Object containing any particular
925/// value on unwind. If the RequiresNoCaptureBeforeUnwind out parameter is set
926/// to true, then the memory is only not visible if the object has not been
927/// captured prior to the unwind. Otherwise it is not visible even if captured.
928LLVM_ABI bool isNotVisibleOnUnwind(const Value *Object,
929 bool &RequiresNoCaptureBeforeUnwind);
930
931/// Return true if the Object is writable, in the sense that any location based
932/// on this pointer that can be loaded can also be stored to without trapping.
933/// Additionally, at the point Object is declared, stores can be introduced
934/// without data races. At later points, this is only the case if the pointer
935/// can not escape to a different thread.
936///
937/// If ExplicitlyDereferenceableOnly is set to true, this property only holds
938/// for the part of Object that is explicitly marked as dereferenceable, e.g.
939/// using the dereferenceable(N) attribute. It does not necessarily hold for
940/// parts that are only known to be dereferenceable due to the presence of
941/// loads.
942LLVM_ABI bool isWritableObject(const Value *Object,
943 bool &ExplicitlyDereferenceableOnly);
944
945/// Get ModRefInfo for a synchronizing operation, such as a fence or stronger
946/// than monotonic atomic load/store.
947LLVM_ABI ModRefInfo getSyncEffects(AAResults *AA, const MemoryLocation &Loc,
948 AAQueryInfo &AAQI);
949
950/// A manager for alias analyses.
951///
952/// This class can have analyses registered with it and when run, it will run
953/// all of them and aggregate their results into single AA results interface
954/// that dispatches across all of the alias analysis results available.
955///
956/// Note that the order in which analyses are registered is very significant.
957/// That is the order in which the results will be aggregated and queried.
958///
959/// This manager effectively wraps the AnalysisManager for registering alias
960/// analyses. When you register your alias analysis with this manager, it will
961/// ensure the analysis itself is registered with its AnalysisManager.
962///
963/// The result of this analysis is only invalidated if one of the particular
964/// aggregated AA results end up being invalidated. This removes the need to
965/// explicitly preserve the results of `AAManager`. Note that analyses should no
966/// longer be registered once the `AAManager` is run.
967class AAManager : public AnalysisInfoMixin<AAManager> {
968public:
970
971 /// Register a specific AA result.
972 template <typename AnalysisT> void registerFunctionAnalysis() {
973 ResultGetters.push_back(&getFunctionAAResultImpl<AnalysisT>);
974 }
975
976 /// Register a specific AA result.
977 template <typename AnalysisT> void registerModuleAnalysis() {
978 ResultGetters.push_back(&getModuleAAResultImpl<AnalysisT>);
979 }
980
982
983private:
985
986 LLVM_ABI static AnalysisKey Key;
987
990 4> ResultGetters;
991
992 template <typename AnalysisT>
993 static void getFunctionAAResultImpl(Function &F,
996 AAResults.addAAResult(AM.template getResult<AnalysisT>(F));
997 AAResults.addAADependencyID(AnalysisT::ID());
998 }
999
1000 template <typename AnalysisT>
1001 static void getModuleAAResultImpl(Function &F, FunctionAnalysisManager &AM,
1002 AAResults &AAResults) {
1003 auto &MAMProxy = AM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
1004 if (auto *R =
1005 MAMProxy.template getCachedResult<AnalysisT>(*F.getParent())) {
1006 AAResults.addAAResult(*R);
1007 MAMProxy
1008 .template registerOuterAnalysisInvalidation<AnalysisT, AAManager>();
1009 }
1010 }
1011};
1012
1013/// A wrapper pass to provide the legacy pass manager access to a suitably
1014/// prepared AAResults object.
1016 std::unique_ptr<AAResults> AAR;
1017
1018public:
1019 static char ID;
1020
1022
1023 AAResults &getAAResults() { return *AAR; }
1024 const AAResults &getAAResults() const { return *AAR; }
1025
1026 bool runOnFunction(Function &F) override;
1027
1028 void getAnalysisUsage(AnalysisUsage &AU) const override;
1029};
1030
1031/// A wrapper pass for external alias analyses. This just squirrels away the
1032/// callback used to run any analyses and register their results.
1034 using CallbackT = std::function<void(Pass &, Function &, AAResults &)>;
1035
1037
1038 LLVM_ABI static char ID;
1039
1041
1042 LLVM_ABI explicit ExternalAAWrapperPass(CallbackT CB, bool RunEarly = false);
1043
1044 /// Flag indicating whether this external AA should run before Basic AA.
1045 ///
1046 /// This flag is for LegacyPassManager only. To run an external AA early
1047 /// with the NewPassManager, override the registerEarlyDefaultAliasAnalyses
1048 /// method on the target machine.
1049 ///
1050 /// By default, external AA passes are run after Basic AA. If this flag is
1051 /// set to true, the external AA will be run before Basic AA during alias
1052 /// analysis.
1053 ///
1054 /// For some targets, we prefer to run the external AA early to improve
1055 /// compile time as it has more target-specific information. This is
1056 /// particularly useful when the external AA can provide more precise results
1057 /// than Basic AA so that Basic AA does not need to spend time recomputing
1058 /// them.
1059 bool RunEarly = false;
1060
1061 void getAnalysisUsage(AnalysisUsage &AU) const override {
1062 AU.setPreservesAll();
1063 }
1064};
1065
1066/// A wrapper pass around a callback which can be used to populate the
1067/// AAResults in the AAResultsWrapperPass from an external AA.
1068///
1069/// The callback provided here will be used each time we prepare an AAResults
1070/// object, and will receive a reference to the function wrapper pass, the
1071/// function, and the AAResults object to populate. This should be used when
1072/// setting up a custom pass pipeline to inject a hook into the AA results.
1074 std::function<void(Pass &, Function &, AAResults &)> Callback,
1075 bool RunEarly = false);
1076
1077} // end namespace llvm
1078
1079#endif // LLVM_ANALYSIS_ALIASANALYSIS_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI
Definition Compiler.h:215
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
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)
ModRefInfo getModRefInfo(const FenceInst *F, const MemoryLocation &Loc, 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)
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)
AliasResult aliasErrno(const MemoryLocation &Loc, const Instruction *CtxI)
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 Instruction *CtxI)=0
Returns an AliasResult indicating whether a specific memory location aliases errno.
virtual ModRefInfo getModRefInfo(const FenceInst *F, const MemoryLocation &Loc, AAQueryInfo &AAQI)=0
getModRefInfo (for fences) - Return information about whether a particular fence modifies or reads th...
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 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.
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.
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.
LLVM_ABI AliasResult aliasErrno(const MemoryLocation &Loc, const Instruction *CtxI)
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.
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()
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)
ModRefInfo getModRefInfo(const Instruction *I, const Instruction *I2)
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:122
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...
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, bool ReturnCaptures) 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
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:166
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 ModRefInfo getSyncEffects(AAResults *AA, const MemoryLocation &Loc, AAQueryInfo &AAQI)
Get ModRefInfo for a synchronizing operation, such as a fence or stronger than monotonic atomic load/...
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
LLVM_ABI ImmutablePass * createExternalAAWrapperPass(std::function< void(Pass &, Function &, AAResults &)> Callback, bool RunEarly=false)
A wrapper pass around a callback which can be used to populate the AAResults in the AAResultsWrapperP...
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 ...
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.
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, bool ReturnCaptures)=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)
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.