18#ifndef LLVM_ANALYSIS_ALIASSETTRACKER_H
19#define LLVM_ANALYSIS_ALIASSETTRACKER_H
39class AnyMemTransferInst;
54 PointerRec **PrevInList =
nullptr;
55 PointerRec *NextInList =
nullptr;
68 Value *getValue()
const {
return Val; }
70 PointerRec *getNext()
const {
return NextInList; }
71 bool hasAliasSet()
const {
return AS !=
nullptr; }
73 PointerRec** setPrevInList(PointerRec **PIL) {
78 bool updateSizeAndAAInfo(LocationSize NewSize,
const AAMDNodes &NewAAInfo) {
79 bool SizeChanged =
false;
80 if (NewSize != Size) {
81 LocationSize OldSize =
Size;
82 Size = isSizeSet() ?
Size.unionWith(NewSize) : NewSize;
83 SizeChanged = OldSize !=
Size;
86 if (AAInfo == DenseMapInfo<AAMDNodes>::getEmptyKey())
90 AAMDNodes Intersection(AAInfo.
intersect(NewAAInfo));
91 SizeChanged |= Intersection != AAInfo;
92 AAInfo = Intersection;
97 LocationSize getSize()
const {
98 assert(isSizeSet() &&
"Getting an unset size!");
104 AAMDNodes getAAInfo()
const {
106 if (AAInfo == DenseMapInfo<AAMDNodes>::getEmptyKey() ||
107 AAInfo == DenseMapInfo<AAMDNodes>::getTombstoneKey())
113 assert(AS &&
"No AliasSet yet!");
115 AliasSet *OldAS = AS;
116 AS = OldAS->getForwardedTarget(AST);
123 void setAliasSet(AliasSet *as) {
124 assert(!AS &&
"Already have an alias set!");
128 void eraseFromList() {
129 if (NextInList) NextInList->PrevInList = PrevInList;
130 *PrevInList = NextInList;
131 if (AS->PtrListEnd == &NextInList) {
132 AS->PtrListEnd = PrevInList;
133 assert(*AS->PtrListEnd ==
nullptr &&
"List not terminated right!");
140 PointerRec *PtrList =
nullptr;
141 PointerRec **PtrListEnd;
146 std::vector<AssertingVH<Instruction>> UnknownInsts;
150 unsigned RefCount : 27;
154 unsigned AliasAny : 1;
166 ModRefAccess = RefAccess | ModAccess
177 SetMustAlias = 0, SetMayAlias = 1
181 unsigned SetSize = 0;
183 void addRef() { ++RefCount; }
186 assert(RefCount >= 1 &&
"Invalid reference count detected!");
188 removeFromTracker(AST);
196 bool isRef()
const {
return Access & RefAccess; }
197 bool isMod()
const {
return Access & ModAccess; }
213 bool empty()
const {
return PtrList ==
nullptr; }
217 unsigned size() {
return SetSize; }
233 explicit iterator(PointerRec *CN =
nullptr) : CurNode(CN) {}
236 return CurNode == x.CurNode;
241 assert(CurNode &&
"Dereferencing AliasSet.end()!");
251 assert(CurNode &&
"Advancing past AliasSet.end()!");
252 CurNode = CurNode->getNext();
256 iterator tmp = *
this; ++*
this;
return tmp;
263 : PtrListEnd(&PtrList), RefCount(0), AliasAny(
false), Access(NoAccess),
264 Alias(SetMustAlias) {}
266 PointerRec *getSomePointer()
const {
274 if (!Forward)
return this;
276 AliasSet *Dest = Forward->getForwardedTarget(AST);
277 if (Dest != Forward) {
279 Forward->dropRef(AST);
288 const AAMDNodes &AAInfo,
bool KnownMustAlias =
false,
289 bool SkipSizeUpdate =
false);
290 void addUnknownInst(Instruction *
I, BatchAAResults &AA);
296 const AAMDNodes &AAInfo, BatchAAResults &AA)
const;
298 BatchAAResults &AA)
const;
374 unsigned TotalMayAliasSetSize = 0;
384 AliasSet::PointerRec &getEntryFor(
Value *V) {
385 AliasSet::PointerRec *&Entry = PointerMap[V];
387 Entry =
new AliasSet::PointerRec(V);
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines DenseMapInfo traits for DenseMap.
This file defines the DenseMap class.
This file provides utility analysis objects describing memory locations.
This header defines various interfaces for pass management in LLVM.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const ilist< AliasSet > & getAliasSets() const
Return the alias sets that are active.
BatchAAResults & getAliasAnalysis() const
Return the underlying alias analysis object used by this tracker.
AliasSet & getAliasSetFor(const MemoryLocation &MemLoc)
Return the alias set which contains the specified memory location.
void addUnknown(Instruction *I)
AliasSetTracker(BatchAAResults &AA)
Create an empty collection of AliasSets, and use the specified alias analysis object to disambiguate ...
const_iterator end() const
const_iterator begin() const
void print(raw_ostream &OS) const
void add(Value *Ptr, LocationSize Size, const AAMDNodes &AAInfo)
These methods are used to add different types of instructions to the alias sets.
Define an iterator for alias sets... this is just a forward iterator.
value_type * operator->() const
iterator(PointerRec *CN=nullptr)
std::forward_iterator_tag iterator_category
AAMDNodes getAAInfo() const
Value * getPointer() const
value_type & operator*() const
bool operator==(const iterator &x) const
LocationSize getSize() const
std::ptrdiff_t difference_type
bool operator!=(const iterator &x) const
void mergeSetIn(AliasSet &AS, AliasSetTracker &AST, BatchAAResults &BatchAA)
Merge the specified alias set into this alias set.
void print(raw_ostream &OS) const
AliasSet(const AliasSet &)=delete
bool isForwardingAliasSet() const
Return true if this alias set should be ignored as part of the AliasSetTracker object.
AliasSet & operator=(const AliasSet &)=delete
ModRefInfo aliasesUnknownInst(const Instruction *Inst, BatchAAResults &AA) const
AliasResult aliasesPointer(const Value *Ptr, LocationSize Size, const AAMDNodes &AAInfo, BatchAAResults &AA) const
If the specified pointer "may" (or must) alias one of the members in the set return the appropriate A...
friend class AliasSetTracker
bool isRef() const
Accessors...
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
A container for analyses that lazily runs them and caches their results.
This class represents any memset intrinsic.
LLVM Basic Block Representation.
This class is a wrapper over an AAResults, and it is intended to be used only when there are no IR ch...
An instruction for reading from memory.
static constexpr LocationSize mapEmpty()
Representation for a specific memory location.
A set of analyses that are preserved following a run of a transformation pass.
An instruction for storing to memory.
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
LLVM Value Representation.
Iterator for intrusive lists based on ilist_node.
An intrusive list with ownership and callbacks specified/controlled by ilist_traits,...
This class implements an extremely fast bulk output stream that can only output to a stream.
This file defines classes to implement an intrusive doubly linked list class (i.e.
This file defines the ilist_node class template, which is a convenient base class for creating classe...
@ BasicBlock
Various leaf nodes.
This is an optimization pass for GlobalISel generic memory operations.
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
AAMDNodes intersect(const AAMDNodes &Other) const
Given two sets of AAMDNodes that apply to the same pointer, give the best AAMDNodes that are compatib...
An information struct used to provide DenseMap with the various necessary components for a given valu...
A CRTP mix-in to automatically provide informational APIs needed for passes.