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