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.
178///
179/// Users must call removeInstruction() and insertPotentialCapture() on IR
180/// changes. The CFG must not gain paths between existing blocks and blocks
181/// must not be renumbered.
183 DominatorTree &DT;
184 const LoopInfo *LI;
185 const CycleInfo *CI;
186
187 /// Map from identified local object to an instruction before which it does
188 /// not escape (or nullptr if it never escapes) and the possible components
189 /// that may be captured (by any instruction, not necessarily the earliest
190 /// one). The "earliest" instruction may be a conservative approximation,
191 /// e.g. the first instruction in the function is always a legal choice.
193 EarliestEscapes;
194
195 /// Reverse map from instruction to the objects it is the earliest escape for.
196 /// This is used for cache invalidation purposes.
198
199 /// Cached result of Function::callsFunctionThatReturnsTwice(), used to
200 /// account for longjmp re-entry paths not visible to the forward CFG.
201 std::optional<bool> CallsReturnsTwiceFn;
202
203 /// Cached reachability between block numbers.
204 DenseMap<std::pair<unsigned, unsigned>, bool> IsReachableCache;
205
206 /// Block number epoch on construction.
207 unsigned BlockNumberEpoch;
208
209 /// Whether the function contains a call that may return twice (e.g., setjmp).
210 bool callsReturnsTwiceFn();
211
212public:
213 EarliestEscapeAnalysis(DominatorTree &DT, const LoopInfo *LI = nullptr,
214 const CycleInfo *CI = nullptr);
215
217 bool OrAt, bool ReturnCaptures) override;
218
220
221 /// Notify the analysis that \p I is about to be inserted or moved.
222 /// If \p I may capture a pointer, any cached earliest escape may no longer
223 /// precede all captures, so the whole cache is dropped.
225};
226
227/// Cache key for BasicAA results. It only includes the pointer and size from
228/// MemoryLocation, as BasicAA is AATags independent. Additionally, it includes
229/// the value of MayBeCrossIteration, which may affect BasicAA results.
234
236 AACacheLoc(const Value *Ptr, LocationSize Size, bool MayBeCrossIteration)
237 : Ptr(Ptr, MayBeCrossIteration), Size(Size) {}
238};
239
240template <> struct DenseMapInfo<AACacheLoc> {
245 static bool isEqual(const AACacheLoc &LHS, const AACacheLoc &RHS) {
246 return LHS.Ptr == RHS.Ptr && LHS.Size == RHS.Size;
247 }
248};
249
250class AAResults;
251
252/// This class stores info we want to provide to or retain within an alias
253/// query. By default, the root query is stateless and starts with a freshly
254/// constructed info object. Specific alias analyses can use this query info to
255/// store per-query state that is important for recursive or nested queries to
256/// avoid recomputing. To enable preserving this state across multiple queries
257/// where safe (due to the IR not changing), use a `BatchAAResults` wrapper.
258/// The information stored in an `AAQueryInfo` is currently limitted to the
259/// caches used by BasicAA, but can further be extended to fit other AA needs.
261public:
262 using LocPair = std::pair<AACacheLoc, AACacheLoc>;
263 struct CacheEntry {
264 /// Cache entry is neither an assumption nor does it use a (non-definitive)
265 /// assumption.
266 static constexpr int Definitive = -2;
267 /// Cache entry is not an assumption itself, but may be using an assumption
268 /// from higher up the stack.
269 static constexpr int AssumptionBased = -1;
270
272 /// Number of times a NoAlias assumption has been used, 0 for assumptions
273 /// that have not been used. Can also take one of the Definitive or
274 /// AssumptionBased values documented above.
276
277 /// Whether this is a definitive (non-assumption) result.
278 bool isDefinitive() const { return NumAssumptionUses == Definitive; }
279 /// Whether this is an assumption that has not been proven yet.
280 bool isAssumption() const { return NumAssumptionUses >= 0; }
281 };
282
283 // Alias analysis result aggregration using which this query is performed.
284 // Can be used to perform recursive queries.
286
289
291
292 /// Query depth used to distinguish recursive queries.
293 unsigned Depth = 0;
294
295 /// How many active NoAlias assumption uses there are.
297
298 /// Location pairs for which an assumption based result is currently stored.
299 /// Used to remove all potentially incorrect results from the cache if an
300 /// assumption is disproven.
302
303 /// Tracks whether the accesses may be on different cycle iterations.
304 ///
305 /// When interpret "Value" pointer equality as value equality we need to make
306 /// sure that the "Value" is not part of a cycle. Otherwise, two uses could
307 /// come from different "iterations" of a cycle and see different values for
308 /// the same "Value" pointer.
309 ///
310 /// The following example shows the problem:
311 /// %p = phi(%alloca1, %addr2)
312 /// %l = load %ptr
313 /// %addr1 = gep, %alloca2, 0, %l
314 /// %addr2 = gep %alloca2, 0, (%l + 1)
315 /// alias(%p, %addr1) -> MayAlias !
316 /// store %l, ...
318
319 /// Whether alias analysis is allowed to use the dominator tree, for use by
320 /// passes that lazily update the DT while performing AA queries.
321 bool UseDominatorTree = true;
322
323 /// Whether ephemeral values should be allowed when checking assumes.
324 bool AllowEphemerals = true;
325
327};
328
329/// AAQueryInfo that uses SimpleCaptureAnalysis.
332
333public:
335};
336
337class BatchAAResults;
338
340public:
341 // Make these results default constructable and movable. We have to spell
342 // these out because MSVC won't synthesize them.
346
347 /// Register a specific AA result.
348 template <typename AAResultT> void addAAResult(AAResultT &AAResult) {
349 // FIXME: We should use a much lighter weight system than the usual
350 // polymorphic pattern because we don't own AAResult. It should
351 // ideally involve two pointers and no separate allocation.
352 AAs.emplace_back(new Model<AAResultT>(AAResult, *this));
353 }
354
355 /// Register a function analysis ID that the results aggregation depends on.
356 ///
357 /// This is used in the new pass manager to implement the invalidation logic
358 /// where we must invalidate the results aggregation if any of our component
359 /// analyses become invalid.
360 void addAADependencyID(AnalysisKey *ID) { AADeps.push_back(ID); }
361
362 /// Handle invalidation events in the new pass manager.
363 ///
364 /// The aggregation is invalidated if any of the underlying analyses is
365 /// invalidated.
367 FunctionAnalysisManager::Invalidator &Inv);
368
369 //===--------------------------------------------------------------------===//
370 /// \name Alias Queries
371 /// @{
372
373 /// The main low level interface to the alias analysis implementation.
374 /// Returns an AliasResult indicating whether the two pointers are aliased to
375 /// each other. This is the interface that must be implemented by specific
376 /// alias analysis implementations.
378 const MemoryLocation &LocB);
379
380 /// A convenience wrapper around the primary \c alias interface.
381 AliasResult alias(const Value *V1, LocationSize V1Size, const Value *V2,
382 LocationSize V2Size) {
383 return alias(MemoryLocation(V1, V1Size), MemoryLocation(V2, V2Size));
384 }
385
386 /// A convenience wrapper around the primary \c alias interface.
391
392 /// A trivial helper function to check to see if the specified pointers are
393 /// no-alias.
394 bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
395 return alias(LocA, LocB) == AliasResult::NoAlias;
396 }
397
398 /// A convenience wrapper around the \c isNoAlias helper interface.
399 bool isNoAlias(const Value *V1, LocationSize V1Size, const Value *V2,
400 LocationSize V2Size) {
401 return isNoAlias(MemoryLocation(V1, V1Size), MemoryLocation(V2, V2Size));
402 }
403
404 /// A convenience wrapper around the \c isNoAlias helper interface.
409
410 /// A trivial helper function to check to see if the specified pointers are
411 /// must-alias.
412 bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
413 return alias(LocA, LocB) == AliasResult::MustAlias;
414 }
415
416 /// A convenience wrapper around the \c isMustAlias helper interface.
417 bool isMustAlias(const Value *V1, const Value *V2) {
420 }
421
422 /// Checks whether the given location points to constant memory, or if
423 /// \p OrLocal is true whether it points to a local alloca.
424 bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal = false) {
425 return isNoModRef(getModRefInfoMask(Loc, OrLocal));
426 }
427
428 /// A convenience wrapper around the primary \c pointsToConstantMemory
429 /// interface.
430 bool pointsToConstantMemory(const Value *P, bool OrLocal = false) {
432 }
433
434 /// @}
435 //===--------------------------------------------------------------------===//
436 /// \name Simple mod/ref information
437 /// @{
438
439 /// Returns a bitmask that should be unconditionally applied to the ModRef
440 /// info of a memory location. This allows us to eliminate Mod and/or Ref
441 /// from the ModRef info based on the knowledge that the memory location
442 /// points to constant and/or locally-invariant memory.
443 ///
444 /// If IgnoreLocals is true, then this method returns NoModRef for memory
445 /// that points to a local alloca.
447 bool IgnoreLocals = false);
448
449 /// A convenience wrapper around the primary \c getModRefInfoMask
450 /// interface.
451 ModRefInfo getModRefInfoMask(const Value *P, bool IgnoreLocals = false) {
453 }
454
455 /// Get the ModRef info associated with a pointer argument of a call. The
456 /// result's bits are set to indicate the allowed aliasing ModRef kinds. Note
457 /// that these bits do not necessarily account for the overall behavior of
458 /// the function, but rather only provide additional per-argument
459 /// information.
460 LLVM_ABI ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx);
461
462 /// Return the behavior of the given call site.
464
465 /// Return the behavior when calling the given function.
467
468 /// Checks if the specified call is known to never read or write memory.
469 ///
470 /// Note that if the call only reads from known-constant memory, it is also
471 /// legal to return true. Also, calls that unwind the stack are legal for
472 /// this predicate.
473 ///
474 /// Many optimizations (such as CSE and LICM) can be performed on such calls
475 /// without worrying about aliasing properties, and many calls have this
476 /// property (e.g. calls to 'sin' and 'cos').
477 ///
478 /// This property corresponds to the GCC 'const' attribute.
482
483 /// Checks if the specified call is known to only read from non-volatile
484 /// memory (or not access memory at all).
485 ///
486 /// Calls that unwind the stack are legal for this predicate.
487 ///
488 /// This property allows many common optimizations to be performed in the
489 /// absence of interfering store instructions, such as CSE of strlen calls.
490 ///
491 /// This property corresponds to the GCC 'pure' attribute.
495
496 /// Check whether or not an instruction may read or write the optionally
497 /// specified memory location.
498 ///
499 ///
500 /// An instruction that doesn't read or write memory may be trivially LICM'd
501 /// for example.
502 ///
503 /// For function calls, this delegates to the alias-analysis specific
504 /// call-site mod-ref behavior queries. Otherwise it delegates to the specific
505 /// helpers above.
507 const std::optional<MemoryLocation> &OptLoc) {
508 SimpleAAQueryInfo AAQIP(*this);
509 return getModRefInfo(I, OptLoc, AAQIP);
510 }
511
512 /// A convenience wrapper for constructing the memory location.
517
518 /// Return information about whether a call and an instruction may refer to
519 /// the same memory locations.
521
522 /// Return information about whether two instructions may refer to the same
523 /// memory locations.
525 const Instruction *I2);
526
527 /// @}
528 //===--------------------------------------------------------------------===//
529 /// \name Higher level methods for querying mod/ref information.
530 /// @{
531
532 /// Check if it is possible for execution of the specified basic block to
533 /// modify the location Loc.
535 const MemoryLocation &Loc);
536
537 /// Check if it is possible for the execution of the specified instructions
538 /// to mod\ref (according to the mode) the location Loc.
539 ///
540 /// The instructions to consider are all of the instructions in the range of
541 /// [I1,I2] INCLUSIVE. I1 and I2 must be in the same basic block.
543 const Instruction &I2,
544 const MemoryLocation &Loc,
545 const ModRefInfo Mode);
546
547 // CtxI can be nullptr, in which case the query is whether or not the aliasing
548 // relationship holds through the entire function.
550 const MemoryLocation &LocB, AAQueryInfo &AAQI,
551 const Instruction *CtxI = nullptr);
553 const Instruction *CtxI);
554
556 AAQueryInfo &AAQI,
557 bool IgnoreLocals = false);
559 AAQueryInfo &AAQIP);
561 const MemoryLocation &Loc,
562 AAQueryInfo &AAQI);
564 const CallBase *Call2, AAQueryInfo &AAQI);
566 const MemoryLocation &Loc,
567 AAQueryInfo &AAQI);
569 const MemoryLocation &Loc,
570 AAQueryInfo &AAQI);
572 const MemoryLocation &Loc,
573 AAQueryInfo &AAQI);
575 const MemoryLocation &Loc,
576 AAQueryInfo &AAQI);
578 const MemoryLocation &Loc,
579 AAQueryInfo &AAQI);
581 const MemoryLocation &Loc,
582 AAQueryInfo &AAQI);
584 const MemoryLocation &Loc,
585 AAQueryInfo &AAQI);
587 const MemoryLocation &Loc,
588 AAQueryInfo &AAQI);
590 const std::optional<MemoryLocation> &OptLoc,
591 AAQueryInfo &AAQIP);
593 const Instruction *I2, AAQueryInfo &AAQI);
595 const MemoryLocation &MemLoc,
596 DominatorTree *DT, AAQueryInfo &AAQIP);
598 AAQueryInfo &AAQI);
599
600private:
601 class Concept;
602
603 template <typename T> class Model;
604
605 friend class AAResultBase;
606
607 const TargetLibraryInfo &TLI;
608
610
612
613 friend class BatchAAResults;
614};
615
616/// This class is a wrapper over an AAResults, and it is intended to be used
617/// only when there are no IR changes inbetween queries. BatchAAResults is
618/// reusing the same `AAQueryInfo` to preserve the state across queries,
619/// esentially making AA work in "batch mode". The internal state cannot be
620/// cleared, so to go "out-of-batch-mode", the user must either use AAResults,
621/// or create a new BatchAAResults.
623 AAResults &AA;
624 AAQueryInfo AAQI;
625 SimpleCaptureAnalysis SimpleCA;
626
628
629public:
630 BatchAAResults(AAResults &AAR) : AA(AAR), AAQI(AAR, &SimpleCA) {}
632 : AA(AAR), AAQI(AAR, CA) {}
633
634 AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
635 return AA.alias(LocA, LocB, AAQI);
636 }
637 bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal = false) {
638 return isNoModRef(AA.getModRefInfoMask(Loc, AAQI, OrLocal));
639 }
640 bool pointsToConstantMemory(const Value *P, bool OrLocal = false) {
642 }
644 bool IgnoreLocals = false) {
645 return AA.getModRefInfoMask(Loc, AAQI, IgnoreLocals);
646 }
648 const std::optional<MemoryLocation> &OptLoc) {
649 return AA.getModRefInfo(I, OptLoc, AAQI);
650 }
652 return AA.getModRefInfo(I, Call2, AAQI);
653 }
655 return AA.getModRefInfo(I, I2, AAQI);
656 }
657 ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
658 return AA.getArgModRefInfo(Call, ArgIdx);
659 }
661 return AA.getMemoryEffects(Call, AAQI);
662 }
663 bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
664 return alias(LocA, LocB) == AliasResult::MustAlias;
665 }
671 bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) {
672 return alias(LocA, LocB) == AliasResult::NoAlias;
673 }
675 const MemoryLocation &MemLoc,
676 DominatorTree *DT) {
677 return AA.callCapturesBefore(I, MemLoc, DT, AAQI);
678 }
679
680 /// Assume that values may come from different cycle iterations.
682 AAQI.MayBeCrossIteration = true;
683 }
684
685 /// Disable the use of the dominator tree during alias analysis queries.
686 void disableDominatorTree() { AAQI.UseDominatorTree = false; }
687};
688
689/// Temporarily set the cross iteration mode on a BatchAA instance.
691 BatchAAResults &BAA;
692 bool OrigCrossIteration;
693
694public:
696 : BAA(BAA), OrigCrossIteration(BAA.AAQI.MayBeCrossIteration) {
697 BAA.AAQI.MayBeCrossIteration = CrossIteration;
698 }
700 BAA.AAQI.MayBeCrossIteration = OrigCrossIteration;
701 }
702};
703
704/// Temporary typedef for legacy code that uses a generic \c AliasAnalysis
705/// pointer or reference.
707
708/// A private abstract base class describing the concept of an individual alias
709/// analysis implementation.
710///
711/// This interface is implemented by any \c Model instantiation. It is also the
712/// interface which a type used to instantiate the model must provide.
713///
714/// All of these methods model methods by the same name in the \c
715/// AAResults class. Only differences and specifics to how the
716/// implementations are called are documented here.
718public:
719 virtual ~Concept() = 0;
720
721 //===--------------------------------------------------------------------===//
722 /// \name Alias Queries
723 /// @{
724
725 /// The main low level interface to the alias analysis implementation.
726 /// Returns an AliasResult indicating whether the two pointers are aliased to
727 /// each other. This is the interface that must be implemented by specific
728 /// alias analysis implementations.
729 virtual AliasResult alias(const MemoryLocation &LocA,
730 const MemoryLocation &LocB, AAQueryInfo &AAQI,
731 const Instruction *CtxI) = 0;
732
733 /// Returns an AliasResult indicating whether a specific memory location
734 /// aliases errno.
736 const Instruction *CtxI) = 0;
737
738 /// @}
739 //===--------------------------------------------------------------------===//
740 /// \name Simple mod/ref information
741 /// @{
742
743 /// Returns a bitmask that should be unconditionally applied to the ModRef
744 /// info of a memory location. This allows us to eliminate Mod and/or Ref from
745 /// the ModRef info based on the knowledge that the memory location points to
746 /// constant and/or locally-invariant memory.
748 AAQueryInfo &AAQI,
749 bool IgnoreLocals) = 0;
750
751 /// Get the ModRef info associated with a pointer argument of a callsite. The
752 /// result's bits are set to indicate the allowed aliasing ModRef kinds. Note
753 /// that these bits do not necessarily account for the overall behavior of
754 /// the function, but rather only provide additional per-argument
755 /// information.
757 unsigned ArgIdx) = 0;
758
759 /// Return the behavior of the given call site.
761 AAQueryInfo &AAQI) = 0;
762
763 /// Return the behavior when calling the given function.
765
766 /// getModRefInfo (for call sites) - Return information about whether
767 /// a particular call site modifies or reads the specified memory location.
769 const MemoryLocation &Loc,
770 AAQueryInfo &AAQI) = 0;
771
772 /// Return information about whether two call sites may refer to the same set
773 /// of memory locations. See the AA documentation for details:
774 /// http://llvm.org/docs/AliasAnalysis.html#ModRefInfo
775 virtual ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
776 AAQueryInfo &AAQI) = 0;
777
778 /// getModRefInfo (for fences) - Return information about whether
779 /// a particular fence modifies or reads the specified memory location.
781 const MemoryLocation &Loc,
782 AAQueryInfo &AAQI) = 0;
783
784 /// @}
785};
786
787/// A private class template which derives from \c Concept and wraps some other
788/// type.
789///
790/// This models the concept by directly forwarding each interface point to the
791/// wrapped type which must implement a compatible interface. This provides
792/// a type erased binding.
793template <typename AAResultT> class AAResults::Model final : public Concept {
794 AAResultT &Result;
795
796public:
797 explicit Model(AAResultT &Result, AAResults &AAR) : Result(Result) {}
798 ~Model() override = default;
799
800 AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
801 AAQueryInfo &AAQI, const Instruction *CtxI) override {
802 return Result.alias(LocA, LocB, AAQI, CtxI);
803 }
804
805 AliasResult aliasErrno(const MemoryLocation &Loc,
806 const Instruction *CtxI) override {
807 return Result.aliasErrno(Loc, CtxI);
808 }
809
810 ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, AAQueryInfo &AAQI,
811 bool IgnoreLocals) override {
812 return Result.getModRefInfoMask(Loc, AAQI, IgnoreLocals);
813 }
814
815 ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) override {
816 return Result.getArgModRefInfo(Call, ArgIdx);
817 }
818
819 MemoryEffects getMemoryEffects(const CallBase *Call,
820 AAQueryInfo &AAQI) override {
821 return Result.getMemoryEffects(Call, AAQI);
822 }
823
824 MemoryEffects getMemoryEffects(const Function *F) override {
825 return Result.getMemoryEffects(F);
826 }
827
828 ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
829 AAQueryInfo &AAQI) override {
830 return Result.getModRefInfo(Call, Loc, AAQI);
831 }
832
833 ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
834 AAQueryInfo &AAQI) override {
835 return Result.getModRefInfo(Call1, Call2, AAQI);
836 }
837
838 ModRefInfo getModRefInfo(const FenceInst *F, const MemoryLocation &Loc,
839 AAQueryInfo &AAQI) override {
840 return Result.getModRefInfo(F, Loc, AAQI);
841 }
842};
843
844/// A base class to help implement the function alias analysis results concept.
845///
846/// Because of the nature of many alias analysis implementations, they often
847/// only implement a subset of the interface. This base class will attempt to
848/// implement the remaining portions of the interface in terms of simpler forms
849/// of the interface where possible, and otherwise provide conservatively
850/// correct fallback implementations.
851///
852/// Implementors of an alias analysis should derive from this class, and then
853/// override specific methods that they wish to customize. There is no need to
854/// use virtual anywhere.
856protected:
857 explicit AAResultBase() = default;
858
859 // Provide all the copy and move constructors so that derived types aren't
860 // constrained.
861 AAResultBase(const AAResultBase &Arg) = default;
863
864public:
866 AAQueryInfo &AAQI, const Instruction *I) {
868 }
869
873
875 bool IgnoreLocals) {
876 return ModRefInfo::ModRef;
877 }
878
879 ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
880 return ModRefInfo::ModRef;
881 }
882
886
890
895
896 ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
897 AAQueryInfo &AAQI) {
898 return ModRefInfo::ModRef;
899 }
900
902 AAQueryInfo &AAQI) {
903 return ModRefInfo::ModRef;
904 }
905};
906
907/// Return true if this pointer is returned by a noalias function.
908LLVM_ABI bool isNoAliasCall(const Value *V);
909
910/// Return true if this pointer refers to a distinct and identifiable object.
911/// This returns true for:
912/// Global Variables and Functions (but not Global Aliases)
913/// Allocas
914/// ByVal and NoAlias Arguments
915/// NoAlias returns (e.g. calls to malloc)
916///
917LLVM_ABI bool isIdentifiedObject(const Value *V);
918
919/// Return true if V is umabigously identified at the function-level.
920/// Different IdentifiedFunctionLocals can't alias.
921/// Further, an IdentifiedFunctionLocal can not alias with any function
922/// arguments other than itself, which is not necessarily true for
923/// IdentifiedObjects.
924LLVM_ABI bool isIdentifiedFunctionLocal(const Value *V);
925
926/// Return true if we know V to the base address of the corresponding memory
927/// object. This implies that any address less than V must be out of bounds
928/// for the underlying object. Note that just being isIdentifiedObject() is
929/// not enough - For example, a negative offset from a noalias argument or call
930/// can be inbounds w.r.t the actual underlying object.
931LLVM_ABI bool isBaseOfObject(const Value *V);
932
933/// Returns true if the pointer is one which would have been considered an
934/// escape by isNotCapturedBefore.
935LLVM_ABI bool isEscapeSource(const Value *V);
936
937/// Return true if Object memory is not visible after an unwind, in the sense
938/// that program semantics cannot depend on Object containing any particular
939/// value on unwind. If the RequiresNoCaptureBeforeUnwind out parameter is set
940/// to true, then the memory is only not visible if the object has not been
941/// captured prior to the unwind. Otherwise it is not visible even if captured.
942LLVM_ABI bool isNotVisibleOnUnwind(const Value *Object,
943 bool &RequiresNoCaptureBeforeUnwind);
944
945/// Return true if the Object is writable, in the sense that any location based
946/// on this pointer that can be loaded can also be stored to without trapping.
947/// Additionally, at the point Object is declared, stores can be introduced
948/// without data races. At later points, this is only the case if the pointer
949/// can not escape to a different thread.
950///
951/// If ExplicitlyDereferenceableOnly is set to true, this property only holds
952/// for the part of Object that is explicitly marked as dereferenceable, e.g.
953/// using the dereferenceable(N) attribute. It does not necessarily hold for
954/// parts that are only known to be dereferenceable due to the presence of
955/// loads.
956LLVM_ABI bool isWritableObject(const Value *Object,
957 bool &ExplicitlyDereferenceableOnly);
958
959/// Get ModRefInfo for a synchronizing operation, such as a fence or stronger
960/// than monotonic atomic load/store.
961LLVM_ABI ModRefInfo getSyncEffects(AAResults *AA, const MemoryLocation &Loc,
962 AAQueryInfo &AAQI);
963
964/// A manager for alias analyses.
965///
966/// This class can have analyses registered with it and when run, it will run
967/// all of them and aggregate their results into single AA results interface
968/// that dispatches across all of the alias analysis results available.
969///
970/// Note that the order in which analyses are registered is very significant.
971/// That is the order in which the results will be aggregated and queried.
972///
973/// This manager effectively wraps the AnalysisManager for registering alias
974/// analyses. When you register your alias analysis with this manager, it will
975/// ensure the analysis itself is registered with its AnalysisManager.
976///
977/// The result of this analysis is only invalidated if one of the particular
978/// aggregated AA results end up being invalidated. This removes the need to
979/// explicitly preserve the results of `AAManager`. Note that analyses should no
980/// longer be registered once the `AAManager` is run.
981class AAManager : public AnalysisInfoMixin<AAManager> {
982public:
984
985 /// Register a specific AA result.
986 template <typename AnalysisT> void registerFunctionAnalysis() {
987 ResultGetters.push_back(&getFunctionAAResultImpl<AnalysisT>);
988 }
989
990 /// Register a specific AA result.
991 template <typename AnalysisT> void registerModuleAnalysis() {
992 ResultGetters.push_back(&getModuleAAResultImpl<AnalysisT>);
993 }
994
996
997private:
999
1000 LLVM_ABI static AnalysisKey Key;
1001
1004 4> ResultGetters;
1005
1006 template <typename AnalysisT>
1007 static void getFunctionAAResultImpl(Function &F,
1010 AAResults.addAAResult(AM.template getResult<AnalysisT>(F));
1011 AAResults.addAADependencyID(AnalysisT::ID());
1012 }
1013
1014 template <typename AnalysisT>
1015 static void getModuleAAResultImpl(Function &F, FunctionAnalysisManager &AM,
1016 AAResults &AAResults) {
1017 auto &MAMProxy = AM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
1018 if (auto *R =
1019 MAMProxy.template getCachedResult<AnalysisT>(*F.getParent())) {
1020 AAResults.addAAResult(*R);
1021 MAMProxy
1022 .template registerOuterAnalysisInvalidation<AnalysisT, AAManager>();
1023 }
1024 }
1025};
1026
1027/// A wrapper pass to provide the legacy pass manager access to a suitably
1028/// prepared AAResults object.
1030 std::unique_ptr<AAResults> AAR;
1031
1032public:
1033 static char ID;
1034
1036
1037 AAResults &getAAResults() { return *AAR; }
1038 const AAResults &getAAResults() const { return *AAR; }
1039
1040 bool runOnFunction(Function &F) override;
1041
1042 void getAnalysisUsage(AnalysisUsage &AU) const override;
1043};
1044
1045/// A wrapper pass for external alias analyses. This just squirrels away the
1046/// callback used to run any analyses and register their results.
1048 using CallbackT = std::function<void(Pass &, Function &, AAResults &)>;
1049
1051
1052 LLVM_ABI static char ID;
1053
1055
1056 LLVM_ABI explicit ExternalAAWrapperPass(CallbackT CB, bool RunEarly = false);
1057
1058 /// Flag indicating whether this external AA should run before Basic AA.
1059 ///
1060 /// This flag is for LegacyPassManager only. To run an external AA early
1061 /// with the NewPassManager, override the registerEarlyDefaultAliasAnalyses
1062 /// method on the target machine.
1063 ///
1064 /// By default, external AA passes are run after Basic AA. If this flag is
1065 /// set to true, the external AA will be run before Basic AA during alias
1066 /// analysis.
1067 ///
1068 /// For some targets, we prefer to run the external AA early to improve
1069 /// compile time as it has more target-specific information. This is
1070 /// particularly useful when the external AA can provide more precise results
1071 /// than Basic AA so that Basic AA does not need to spend time recomputing
1072 /// them.
1073 bool RunEarly = false;
1074
1075 void getAnalysisUsage(AnalysisUsage &AU) const override {
1076 AU.setPreservesAll();
1077 }
1078};
1079
1080/// A wrapper pass around a callback which can be used to populate the
1081/// AAResults in the AAResultsWrapperPass from an external AA.
1082///
1083/// The callback provided here will be used each time we prepare an AAResults
1084/// object, and will receive a reference to the function wrapper pass, the
1085/// function, and the AAResults object to populate. This should be used when
1086/// setting up a custom pass pipeline to inject a hook into the AA results.
1088 std::function<void(Pass &, Function &, AAResults &)> Callback,
1089 bool RunEarly = false);
1090
1091} // end namespace llvm
1092
1093#endif // LLVM_ANALYSIS_ALIASANALYSIS_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI
Definition Compiler.h:211
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
bool AllowEphemerals
Whether ephemeral values should be allowed when checking assumes.
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)
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.
LLVM_ABI ModRefInfo callCapturesBefore(const Instruction *I, const MemoryLocation &MemLoc, DominatorTree *DT, AAQueryInfo &AAQIP)
Return information about whether a particular call site modifies or reads the specified memory locati...
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
void removeInstruction(Instruction *I)
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.
void insertPotentialCapture(const Instruction *I)
Notify the analysis that I is about to be inserted or moved.
EarliestEscapeAnalysis(DominatorTree &DT, const LoopInfo *LI=nullptr, const CycleInfo *CI=nullptr)
An instruction for ordering other memory operations.
FunctionPass(char &pid)
Definition Pass.h:314
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition Pass.h:283
ImmutablePass(char &pid)
Definition Pass.h:285
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:97
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.