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;
62 Value *getValue()
const {
return Val; }
64 PointerRec *getNext()
const {
return NextInList; }
65 bool hasAliasSet()
const {
return AS !=
nullptr; }
67 PointerRec** setPrevInList(PointerRec **PIL) {
73 bool SizeChanged =
false;
89 AAInfo = Intersection;
107 assert(AS &&
"No AliasSet yet!");
110 AS = OldAS->getForwardedTarget(AST);
118 assert(!AS &&
"Already have an alias set!");
122 void eraseFromList() {
123 if (NextInList) NextInList->PrevInList = PrevInList;
124 *PrevInList = NextInList;
125 if (AS->PtrListEnd == &NextInList) {
126 AS->PtrListEnd = PrevInList;
127 assert(*AS->PtrListEnd ==
nullptr &&
"List not terminated right!");
134 PointerRec *PtrList =
nullptr;
135 PointerRec **PtrListEnd;
143 std::vector<WeakVH> UnknownInsts;
147 unsigned RefCount : 27;
151 unsigned AliasAny : 1;
163 ModRefAccess = RefAccess | ModAccess
174 SetMustAlias = 0, SetMayAlias = 1
179 unsigned Volatile : 1;
181 unsigned SetSize = 0;
183 void addRef() { ++RefCount; }
186 assert(RefCount >= 1 &&
"Invalid reference count detected!");
188 removeFromTracker(AST);
192 assert(i < UnknownInsts.size());
193 return cast_or_null<Instruction>(UnknownInsts[i]);
201 bool isRef()
const {
return Access & RefAccess; }
202 bool isMod()
const {
return Access & ModAccess; }
221 bool empty()
const {
return PtrList ==
nullptr; }
225 unsigned size() {
return SetSize; }
231 class iterator :
public std::iterator<std::forward_iterator_tag,
232 PointerRec, ptrdiff_t> {
236 explicit iterator(PointerRec *CN =
nullptr) : CurNode(CN) {}
239 return CurNode == x.CurNode;
244 assert(CurNode &&
"Dereferencing AliasSet.end()!");
254 assert(CurNode &&
"Advancing past AliasSet.end()!");
255 CurNode = CurNode->getNext();
259 iterator tmp = *
this; ++*
this;
return tmp;
266 : PtrListEnd(&PtrList), RefCount(0), AliasAny(
false), Access(NoAccess),
267 Alias(SetMustAlias), Volatile(
false) {}
269 PointerRec *getSomePointer()
const {
277 if (!Forward)
return this;
279 AliasSet *Dest = Forward->getForwardedTarget(AST);
280 if (Dest != Forward) {
282 Forward->dropRef(AST);
291 const AAMDNodes &AAInfo,
bool KnownMustAlias =
false);
295 bool WasEmpty = UnknownInsts.empty();
296 for (
size_t i = 0, e = UnknownInsts.size(); i != e; ++i)
297 if (UnknownInsts[i] == I) {
298 UnknownInsts[i] = UnknownInsts.back();
299 UnknownInsts.pop_back();
302 if (!WasEmpty && UnknownInsts.empty())
306 void setVolatile() { Volatile =
true; }
324 class ASTCallbackVH final :
public CallbackVH {
327 void deleted()
override;
328 void allUsesReplacedWith(
Value *)
override;
337 struct ASTCallbackVHDenseMapInfo :
public DenseMapInfo<Value *> {};
343 ASTCallbackVHDenseMapInfo>;
393 return mergeAliasSetsForPointer(P, Size, AAInfo);
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);
449 AliasSet::AccessLattice
E);
467 #endif // LLVM_ANALYSIS_ALIASSETTRACKER_H void mergeSetIn(AliasSet &AS, AliasSetTracker &AST)
Merge the specified alias set into this alias set.
Compute iterated dominance frontiers using a linear time algorithm.
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
An instruction for storing to memory.
AliasSet * getAliasSetForPointerIfExists(const Value *P, LocationSize Size, const AAMDNodes &AAInfo)
Return the alias set containing the location specified if one exists, otherwise return null...
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")
AliasSetTracker(AliasAnalysis &aa)
Create an empty collection of AliasSets, and use the specified alias analysis object to disambiguate ...
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.
Iterator for intrusive lists based on ilist_node.
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.
bool isVolatile() const
Return true if this alias set contains volatile loads or stores.
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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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.