Go to the documentation of this file.
16 #ifndef LLVM_ANALYSIS_ALIASSETTRACKER_H
17 #define LLVM_ANALYSIS_ALIASSETTRACKER_H
36 class AliasSetTracker;
38 class AnyMemTransferInst;
51 PointerRec **PrevInList =
nullptr;
52 PointerRec *NextInList =
nullptr;
65 Value *getValue()
const {
return Val; }
67 PointerRec *getNext()
const {
return NextInList; }
68 bool hasAliasSet()
const {
return AS !=
nullptr; }
70 PointerRec** setPrevInList(PointerRec **PIL) {
75 bool updateSizeAndAAInfo(LocationSize NewSize,
const AAMDNodes &NewAAInfo) {
76 bool SizeChanged =
false;
77 if (NewSize != Size) {
78 LocationSize OldSize =
Size;
79 Size = isSizeSet() ?
Size.unionWith(NewSize) : NewSize;
80 SizeChanged = OldSize !=
Size;
87 AAMDNodes Intersection(AAInfo.
intersect(NewAAInfo));
88 SizeChanged |= Intersection != AAInfo;
89 AAInfo = Intersection;
94 LocationSize getSize()
const {
95 assert(isSizeSet() &&
"Getting an unset size!");
101 AAMDNodes getAAInfo()
const {
110 assert(AS &&
"No AliasSet yet!");
112 AliasSet *OldAS = AS;
113 AS = OldAS->getForwardedTarget(AST);
120 void setAliasSet(AliasSet *
as) {
121 assert(!AS &&
"Already have an alias set!");
125 void eraseFromList() {
126 if (NextInList) NextInList->PrevInList = PrevInList;
127 *PrevInList = NextInList;
128 if (AS->PtrListEnd == &NextInList) {
129 AS->PtrListEnd = PrevInList;
130 assert(*AS->PtrListEnd ==
nullptr &&
"List not terminated right!");
137 PointerRec *PtrList =
nullptr;
138 PointerRec **PtrListEnd;
146 std::vector<WeakVH> 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);
191 Instruction *getUnknownInst(
unsigned i)
const {
192 assert(
i < UnknownInsts.size());
193 return cast_or_null<Instruction>(UnknownInsts[
i]);
197 AliasSet(
const AliasSet &) =
delete;
201 bool isRef()
const {
return Access & RefAccess; }
202 bool isMod()
const {
return Access & ModAccess; }
218 bool empty()
const {
return PtrList ==
nullptr; }
222 unsigned size() {
return SetSize; }
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();
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);
296 void addPointer(
AliasSetTracker &AST, PointerRec &Entry, LocationSize Size,
297 const AAMDNodes &AAInfo,
bool KnownMustAlias =
false,
298 bool SkipSizeUpdate =
false);
299 void addUnknownInst(Instruction *
I, AAResults &
AA);
302 bool WasEmpty = UnknownInsts.empty();
303 for (
size_t i = 0,
e = UnknownInsts.size();
i !=
e; ++
i)
304 if (UnknownInsts[
i] ==
I) {
305 UnknownInsts[
i] = UnknownInsts.back();
306 UnknownInsts.pop_back();
309 if (!WasEmpty && UnknownInsts.empty())
317 const AAMDNodes &AAInfo, AAResults &
AA)
const;
329 class ASTCallbackVH final :
public CallbackVH {
332 void deleted()
override;
333 void allUsesReplacedWith(
Value *)
override;
338 ASTCallbackVH &operator=(
Value *V);
342 struct ASTCallbackVHDenseMapInfo :
public DenseMapInfo<Value *> {};
348 ASTCallbackVHDenseMapInfo>;
424 unsigned TotalMayAliasSetSize = 0;
434 AliasSet::PointerRec &getEntryFor(
Value *V) {
435 AliasSet::PointerRec *&Entry = PointerMap[ASTCallbackVH(V,
this)];
437 Entry =
new AliasSet::PointerRec(V);
468 #endif // LLVM_ANALYSIS_ALIASSETTRACKER_H
A set of analyses that are preserved following a run of a transformation pass.
void addUnknown(Instruction *I)
compiles conv shl5 shl ret i32 or10 it would be better as
This is an optimization pass for GlobalISel generic memory operations.
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
const_iterator end() const
const ilist< AliasSet > & getAliasSets() const
Return the alias sets that are active.
A CRTP mix-in to automatically provide informational APIs needed for passes.
AliasSet(const AliasSet &)=delete
iterator(PointerRec *CN=nullptr)
void print(raw_ostream &OS) const
LocationSize getSize() const
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
std::ptrdiff_t difference_type
bool isRef() const
Accessors...
alloca< 16 x float >, align 16 %tmp2=alloca< 16 x float >, align 16 store< 16 x float > %A,< 16 x float > *%tmp %s=bitcast< 16 x float > *%tmp to i8 *%s2=bitcast< 16 x float > *%tmp2 to i8 *call void @llvm.memcpy.i64(i8 *%s, i8 *%s2, i64 64, i32 16) %R=load< 16 x float > *%tmp2 ret< 16 x float > %R } declare void @llvm.memcpy.i64(i8 *nocapture, i8 *nocapture, i64, i32) nounwind which compiles to:_foo:subl $140, %esp movaps %xmm3, 112(%esp) movaps %xmm2, 96(%esp) movaps %xmm1, 80(%esp) movaps %xmm0, 64(%esp) movl 60(%esp), %eax movl %eax, 124(%esp) movl 56(%esp), %eax movl %eax, 120(%esp) movl 52(%esp), %eax< many many more 32-bit copies > movaps(%esp), %xmm0 movaps 16(%esp), %xmm1 movaps 32(%esp), %xmm2 movaps 48(%esp), %xmm3 addl $140, %esp ret On Nehalem, it may even be cheaper to just use movups when unaligned than to fall back to lower-granularity chunks. Implement processor-specific optimizations for parity with GCC on these processors. GCC does two optimizations:1. ix86_pad_returns inserts a noop before ret instructions if immediately preceded by a conditional branch or is the target of a jump. 2. ix86_avoid_jump_misspredicts inserts noops in cases where a 16-byte block of code contains more than 3 branches. The first one is done for all AMDs, Core2, and "Generic" The second one is done for:Atom, Pentium Pro, all AMDs, Pentium 4, Nocona, Core 2, and "Generic" Testcase:int x(int a) { return(a &0xf0)> >4 tmp
void print(raw_ostream &OS) const
An intrusive list with ownership and callbacks specified/controlled by ilist_traits,...
LLVM Basic Block Representation.
value_type & operator*() const
An information struct used to provide DenseMap with the various necessary components for a given valu...
std::forward_iterator_tag iterator_category
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
bool operator!=(const iterator &x) const
bool isForwardingAliasSet() const
Return true if this alias set should be ignored as part of the AliasSetTracker object.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Value * getPointer() const
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
AAMDNodes getAAInfo() const
void mergeSetIn(AliasSet &AS, AliasSetTracker &AST)
Merge the specified alias set into this alias set.
AliasSet & operator=(const AliasSet &)=delete
An instruction for storing to memory.
void add(Value *Ptr, LocationSize Size, const AAMDNodes &AAInfo)
These methods are used to add different types of instructions to the alias sets.
AAResults & getAliasAnalysis() const
Return the underlying alias analysis object used by this tracker.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool operator==(const iterator &x) const
StandardInstrumentations SI(Debug, VerifyEach)
AliasSetsPrinterPass(raw_ostream &OS)
AAMDNodes intersect(const AAMDNodes &Other) const
Given two sets of AAMDNodes that apply to the same pointer, give the best AAMDNodes that are compatib...
AliasSet & getAliasSetFor(const MemoryLocation &MemLoc)
Return the alias set which contains the specified memory location.
@ BasicBlock
Various leaf nodes.
Define an iterator for alias sets... this is just a forward iterator.
AliasResult aliasesPointer(const Value *Ptr, LocationSize Size, const AAMDNodes &AAInfo, AAResults &AA) const
If the specified pointer "may" (or must) alias one of the members in the set return the appropriate A...
void copyValue(Value *From, Value *To)
This method should be used whenever a preexisting value in the program is copied or cloned,...
constexpr static LocationSize mapEmpty()
static AAMDNodes getTombstoneKey()
An instruction for reading from memory.
void deleteValue(Value *PtrVal)
This method is used to remove a pointer value from the AliasSetTracker entirely.
static AAMDNodes getEmptyKey()
This class represents any memset intrinsic.
Iterator for intrusive lists based on ilist_node.
Value handle with callbacks on RAUW and destruction.
const_iterator begin() const
AliasSetTracker(AAResults &AA)
Create an empty collection of AliasSets, and use the specified alias analysis object to disambiguate ...
friend class AliasSetTracker
Instruction * getUniqueInstruction()
If this alias set is known to contain a single instruction and only a single unique instruction,...
A container for analyses that lazily runs them and caches their results.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
BlockVerifier::State From
value_type * operator->() const
LLVM Value Representation.
Representation for a specific memory location.
bool aliasesUnknownInst(const Instruction *Inst, AAResults &AA) const