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;
90 if (!Intersection.TBAA || !Intersection.Scope ||
91 !Intersection.NoAlias) {
96 AAInfo = Intersection;
102 assert(isSizeSet() &&
"Getting an unset size!");
117 assert(AS &&
"No AliasSet yet!");
120 AS = OldAS->getForwardedTarget(AST);
128 assert(!AS &&
"Already have an alias set!");
132 void eraseFromList() {
133 if (NextInList) NextInList->PrevInList = PrevInList;
134 *PrevInList = NextInList;
135 if (AS->PtrListEnd == &NextInList) {
136 AS->PtrListEnd = PrevInList;
137 assert(*AS->PtrListEnd ==
nullptr &&
"List not terminated right!");
144 PointerRec *PtrList =
nullptr;
145 PointerRec **PtrListEnd;
153 std::vector<WeakVH> UnknownInsts;
157 unsigned RefCount : 27;
161 unsigned AliasAny : 1;
173 ModRefAccess = RefAccess | ModAccess
184 SetMustAlias = 0, SetMayAlias = 1
188 unsigned SetSize = 0;
190 void addRef() { ++RefCount; }
193 assert(RefCount >= 1 &&
"Invalid reference count detected!");
195 removeFromTracker(AST);
199 assert(i < UnknownInsts.size());
200 return cast_or_null<Instruction>(UnknownInsts[i]);
208 bool isRef()
const {
return Access & RefAccess; }
209 bool isMod()
const {
return Access & ModAccess; }
225 bool empty()
const {
return PtrList ==
nullptr; }
229 unsigned size() {
return SetSize; }
239 class iterator :
public std::iterator<std::forward_iterator_tag,
240 PointerRec, ptrdiff_t> {
244 explicit iterator(PointerRec *CN =
nullptr) : CurNode(CN) {}
247 return CurNode == x.CurNode;
252 assert(CurNode &&
"Dereferencing AliasSet.end()!");
262 assert(CurNode &&
"Advancing past AliasSet.end()!");
263 CurNode = CurNode->getNext();
267 iterator tmp = *
this; ++*
this;
return tmp;
274 : PtrListEnd(&PtrList), RefCount(0), AliasAny(
false), Access(NoAccess),
275 Alias(SetMustAlias) {}
277 PointerRec *getSomePointer()
const {
285 if (!Forward)
return this;
287 AliasSet *Dest = Forward->getForwardedTarget(AST);
288 if (Dest != Forward) {
290 Forward->dropRef(AST);
299 const AAMDNodes &AAInfo,
bool KnownMustAlias =
false,
300 bool SkipSizeUpdate =
false);
304 bool WasEmpty = UnknownInsts.empty();
305 for (
size_t i = 0,
e = UnknownInsts.size(); i !=
e; ++i)
306 if (UnknownInsts[i] == I) {
307 UnknownInsts[i] = UnknownInsts.back();
308 UnknownInsts.pop_back();
311 if (!WasEmpty && UnknownInsts.empty())
331 class ASTCallbackVH final :
public CallbackVH {
334 void deleted()
override;
335 void allUsesReplacedWith(
Value *)
override;
344 struct ASTCallbackVHDenseMapInfo :
public DenseMapInfo<Value *> {};
352 ASTCallbackVHDenseMapInfo>;
362 : AA(aa), MSSA(mssa), L(l) {}
387 void addAllInstructionsInLoopUsingMSSA();
407 void deleteValue(
Value *PtrVal);
431 unsigned TotalMayAliasSetSize = 0;
441 AliasSet::PointerRec &getEntryFor(
Value *V) {
442 AliasSet::PointerRec *&
Entry = PointerMap[ASTCallbackVH(V,
this)];
444 Entry =
new AliasSet::PointerRec(V);
467 #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
static uint64_t add(uint64_t LeftOp, uint64_t RightOp)
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.