17 #ifndef LLVM_ANALYSIS_ALIASSETTRACKER_H 18 #define LLVM_ANALYSIS_ALIASSETTRACKER_H 37 class AliasSetTracker;
41 class AnyMemTransferInst;
52 PointerRec **PrevInList =
nullptr;
53 PointerRec *NextInList =
nullptr;
66 Value *getValue()
const {
return Val; }
68 PointerRec *getNext()
const {
return NextInList; }
69 bool hasAliasSet()
const {
return AS !=
nullptr; }
71 PointerRec** setPrevInList(PointerRec **PIL) {
77 bool SizeChanged =
false;
78 if (NewSize != Size) {
80 Size = isSizeSet() ? Size.
unionWith(NewSize) : NewSize;
81 SizeChanged = OldSize !=
Size;
94 AAInfo = Intersection;
100 assert(isSizeSet() &&
"Getting an unset size!");
115 assert(AS &&
"No AliasSet yet!");
118 AS = OldAS->getForwardedTarget(AST);
126 assert(!AS &&
"Already have an alias set!");
130 void eraseFromList() {
131 if (NextInList) NextInList->PrevInList = PrevInList;
132 *PrevInList = NextInList;
133 if (AS->PtrListEnd == &NextInList) {
134 AS->PtrListEnd = PrevInList;
135 assert(*AS->PtrListEnd ==
nullptr &&
"List not terminated right!");
142 PointerRec *PtrList =
nullptr;
143 PointerRec **PtrListEnd;
151 std::vector<WeakVH> UnknownInsts;
155 unsigned RefCount : 27;
159 unsigned AliasAny : 1;
171 ModRefAccess = RefAccess | ModAccess
182 SetMustAlias = 0, SetMayAlias = 1
186 unsigned SetSize = 0;
188 void addRef() { ++RefCount; }
191 assert(RefCount >= 1 &&
"Invalid reference count detected!");
193 removeFromTracker(AST);
197 assert(i < UnknownInsts.size());
198 return cast_or_null<Instruction>(UnknownInsts[i]);
206 bool isRef()
const {
return Access & RefAccess; }
207 bool isMod()
const {
return Access & ModAccess; }
223 bool empty()
const {
return PtrList ==
nullptr; }
227 unsigned size() {
return SetSize; }
237 class iterator :
public std::iterator<std::forward_iterator_tag,
238 PointerRec, ptrdiff_t> {
242 explicit iterator(PointerRec *CN =
nullptr) : CurNode(CN) {}
245 return CurNode == x.CurNode;
250 assert(CurNode &&
"Dereferencing AliasSet.end()!");
260 assert(CurNode &&
"Advancing past AliasSet.end()!");
261 CurNode = CurNode->getNext();
265 iterator tmp = *
this; ++*
this;
return tmp;
272 : PtrListEnd(&PtrList), RefCount(0), AliasAny(
false), Access(NoAccess),
273 Alias(SetMustAlias) {}
275 PointerRec *getSomePointer()
const {
283 if (!Forward)
return this;
285 AliasSet *Dest = Forward->getForwardedTarget(AST);
286 if (Dest != Forward) {
288 Forward->dropRef(AST);
297 const AAMDNodes &AAInfo,
bool KnownMustAlias =
false);
301 bool WasEmpty = UnknownInsts.empty();
302 for (
size_t i = 0, e = UnknownInsts.size(); i != e; ++i)
303 if (UnknownInsts[i] == I) {
304 UnknownInsts[i] = UnknownInsts.back();
305 UnknownInsts.pop_back();
308 if (!WasEmpty && UnknownInsts.empty())
328 class ASTCallbackVH final :
public CallbackVH {
331 void deleted()
override;
332 void allUsesReplacedWith(
Value *)
override;
341 struct ASTCallbackVHDenseMapInfo :
public DenseMapInfo<Value *> {};
347 ASTCallbackVHDenseMapInfo>;
399 void deleteValue(
Value *PtrVal);
423 unsigned TotalMayAliasSetSize = 0;
433 AliasSet::PointerRec &getEntryFor(
Value *V) {
434 AliasSet::PointerRec *&Entry = PointerMap[ASTCallbackVH(V,
this)];
436 Entry =
new AliasSet::PointerRec(V);
458 #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
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.
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
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.
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.
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...
Value handle with callbacks on RAUW and destruction.
bool aliasesPointer(const Value *Ptr, LocationSize Size, const AAMDNodes &AAInfo, AliasAnalysis &AA) const
Return true if the specified pointer "may" (or must) alias one of the members in the set...
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.