16 #ifndef LLVM_ANALYSIS_ALIASSETTRACKER_H 17 #define LLVM_ANALYSIS_ALIASSETTRACKER_H 36 class AliasSetTracker;
42 class AnyMemTransferInst;
53 PointerRec **PrevInList =
nullptr;
54 PointerRec *NextInList =
nullptr;
67 Value *getValue()
const {
return Val; }
69 PointerRec *getNext()
const {
return NextInList; }
70 bool hasAliasSet()
const {
return AS !=
nullptr; }
72 PointerRec** setPrevInList(PointerRec **PIL) {
78 bool SizeChanged =
false;
79 if (NewSize != Size) {
81 Size = isSizeSet() ? Size.
unionWith(NewSize) : NewSize;
82 SizeChanged = OldSize !=
Size;
95 AAInfo = Intersection;
101 assert(isSizeSet() &&
"Getting an unset size!");
116 assert(AS &&
"No AliasSet yet!");
119 AS = OldAS->getForwardedTarget(AST);
127 assert(!AS &&
"Already have an alias set!");
131 void eraseFromList() {
132 if (NextInList) NextInList->PrevInList = PrevInList;
133 *PrevInList = NextInList;
134 if (AS->PtrListEnd == &NextInList) {
135 AS->PtrListEnd = PrevInList;
136 assert(*AS->PtrListEnd ==
nullptr &&
"List not terminated right!");
143 PointerRec *PtrList =
nullptr;
144 PointerRec **PtrListEnd;
152 std::vector<WeakVH> UnknownInsts;
156 unsigned RefCount : 27;
160 unsigned AliasAny : 1;
172 ModRefAccess = RefAccess | ModAccess
183 SetMustAlias = 0, SetMayAlias = 1
187 unsigned SetSize = 0;
189 void addRef() { ++RefCount; }
192 assert(RefCount >= 1 &&
"Invalid reference count detected!");
194 removeFromTracker(AST);
198 assert(i < UnknownInsts.size());
199 return cast_or_null<Instruction>(UnknownInsts[i]);
207 bool isRef()
const {
return Access & RefAccess; }
208 bool isMod()
const {
return Access & ModAccess; }
224 bool empty()
const {
return PtrList ==
nullptr; }
228 unsigned size() {
return SetSize; }
238 class iterator :
public std::iterator<std::forward_iterator_tag,
239 PointerRec, ptrdiff_t> {
243 explicit iterator(PointerRec *CN =
nullptr) : CurNode(CN) {}
246 return CurNode == x.CurNode;
251 assert(CurNode &&
"Dereferencing AliasSet.end()!");
261 assert(CurNode &&
"Advancing past AliasSet.end()!");
262 CurNode = CurNode->getNext();
266 iterator tmp = *
this; ++*
this;
return tmp;
273 : PtrListEnd(&PtrList), RefCount(0), AliasAny(
false), Access(NoAccess),
274 Alias(SetMustAlias) {}
276 PointerRec *getSomePointer()
const {
284 if (!Forward)
return this;
286 AliasSet *Dest = Forward->getForwardedTarget(AST);
287 if (Dest != Forward) {
289 Forward->dropRef(AST);
298 const AAMDNodes &AAInfo,
bool KnownMustAlias =
false,
299 bool SkipSizeUpdate =
false);
303 bool WasEmpty = UnknownInsts.empty();
304 for (
size_t i = 0, e = UnknownInsts.size(); i != e; ++i)
305 if (UnknownInsts[i] == I) {
306 UnknownInsts[i] = UnknownInsts.back();
307 UnknownInsts.pop_back();
310 if (!WasEmpty && UnknownInsts.empty())
330 class ASTCallbackVH final :
public CallbackVH {
333 void deleted()
override;
334 void allUsesReplacedWith(
Value *)
override;
343 struct ASTCallbackVHDenseMapInfo :
public DenseMapInfo<Value *> {};
351 ASTCallbackVHDenseMapInfo>;
361 : AA(aa), MSSA(mssa), L(l) {}
386 void addAllInstructionsInLoopUsingMSSA();
406 void deleteValue(
Value *PtrVal);
430 unsigned TotalMayAliasSetSize = 0;
440 AliasSet::PointerRec &getEntryFor(
Value *V) {
441 AliasSet::PointerRec *&Entry = PointerMap[ASTCallbackVH(V,
this)];
443 Entry =
new AliasSet::PointerRec(V);
466 #endif // LLVM_ANALYSIS_ALIASSETTRACKER_H void mergeSetIn(AliasSet &AS, AliasSetTracker &AST)
Merge the specified alias set into this alias set.
This class represents lattice values for constants.
const_iterator end() const
Define an iterator for alias sets... this is just a forward iterator.
bool operator!=(const iterator &x) const
An instruction for reading from memory.
AAMDNodes getAAInfo() const
value_type & operator*() const
LocationSize getSize() const
Encapsulates MemorySSA, including all data associated with memory accesses.
Value * getPointer() const
APInt operator*(APInt a, uint64_t RHS)
bool aliasesUnknownInst(const Instruction *Inst, AliasAnalysis &AA) const
Instruction * getUniqueInstruction()
If this alias set is known to contain a single instruction and only a single unique instruction...
An instruction for storing to memory.
AliasResult
The possible results of an alias query.
void print(raw_ostream &OS) const
LLVM Basic Block Representation.
AliasAnalysis & getAliasAnalysis() const
Return the underlying alias analysis object used by this tracker.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
LocationSize unionWith(LocationSize Other) const
early cse Early CSE w MemorySSA
AliasSetTracker(AliasAnalysis &aa)
Create an empty collection of AliasSets, and use the specified alias analysis object to disambiguate ...
static constexpr LocationSize mapEmpty()
This class represents any memset intrinsic.
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
bool operator==(const iterator &x) const
An intrusive list with ownership and callbacks specified/controlled by ilist_traits, only with API safe for polymorphic types.
Representation for a specific memory location.
AliasResult aliasesPointer(const Value *Ptr, LocationSize Size, const AAMDNodes &AAInfo, AliasAnalysis &AA) const
If the specified pointer "may" (or must) alias one of the members in the set return the appropriate A...
Iterator for intrusive lists based on ilist_node.
BlockVerifier::State From
void print(raw_ostream &OS) const
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
bool isRef() const
Accessors...
static void clear(coro::Shape &Shape)
const ilist< AliasSet > & getAliasSets() const
Return the alias sets that are active.
Represents a single loop in the control flow graph.
value_type * operator->() const
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
const_iterator begin() const
iterator(PointerRec *CN=nullptr)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
AAMDNodes intersect(const AAMDNodes &Other)
Given two sets of AAMDNodes that apply to the same pointer, give the best AAMDNodes that are compatib...
This class implements an extremely fast bulk output stream that can only output to a stream...
AliasSetTracker(AliasAnalysis &aa, MemorySSA *mssa, Loop *l)
Value handle with callbacks on RAUW and destruction.
AliasSet & operator=(const AliasSet &)=delete
bool operator==(uint64_t V1, const APInt &V2)
bool isForwardingAliasSet() const
Return true if this alias set should be ignored as part of the AliasSetTracker object.