LLVM 18.0.0git
AliasSetTracker.cpp
Go to the documentation of this file.
1//===- AliasSetTracker.cpp - Alias Sets Tracker implementation-------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the AliasSetTracker and AliasSet classes.
10//
11//===----------------------------------------------------------------------===//
12
18#include "llvm/Config/llvm-config.h"
19#include "llvm/IR/Function.h"
23#include "llvm/IR/PassManager.h"
25#include "llvm/IR/Value.h"
27#include "llvm/Pass.h"
31#include "llvm/Support/Debug.h"
34
35using namespace llvm;
36
38 SaturationThreshold("alias-set-saturation-threshold", cl::Hidden,
39 cl::init(250),
40 cl::desc("The maximum number of pointers may-alias "
41 "sets may contain before degradation"));
42
43/// mergeSetIn - Merge the specified alias set into this alias set.
45 BatchAAResults &BatchAA) {
46 assert(!AS.Forward && "Alias set is already forwarding!");
47 assert(!Forward && "This set is a forwarding set!!");
48
49 bool WasMustAlias = (Alias == SetMustAlias);
50 // Update the alias and access types of this set...
51 Access |= AS.Access;
52 Alias |= AS.Alias;
53
54 if (Alias == SetMustAlias) {
55 // Check that these two merged sets really are must aliases. Since both
56 // used to be must-alias sets, we can just check any pointer from each set
57 // for aliasing.
58 PointerRec *L = getSomePointer();
59 PointerRec *R = AS.getSomePointer();
60
61 // If the pointers are not a must-alias pair, this set becomes a may alias.
62 if (!BatchAA.isMustAlias(
63 MemoryLocation(L->getValue(), L->getSize(), L->getAAInfo()),
64 MemoryLocation(R->getValue(), R->getSize(), R->getAAInfo())))
65 Alias = SetMayAlias;
66 }
67
68 if (Alias == SetMayAlias) {
69 if (WasMustAlias)
70 AST.TotalMayAliasSetSize += size();
71 if (AS.Alias == SetMustAlias)
72 AST.TotalMayAliasSetSize += AS.size();
73 }
74
75 bool ASHadUnknownInsts = !AS.UnknownInsts.empty();
76 if (UnknownInsts.empty()) { // Merge call sites...
77 if (ASHadUnknownInsts) {
78 std::swap(UnknownInsts, AS.UnknownInsts);
79 addRef();
80 }
81 } else if (ASHadUnknownInsts) {
82 llvm::append_range(UnknownInsts, AS.UnknownInsts);
83 AS.UnknownInsts.clear();
84 }
85
86 AS.Forward = this; // Forward across AS now...
87 addRef(); // AS is now pointing to us...
88
89 // Merge the list of constituent pointers...
90 if (AS.PtrList) {
91 SetSize += AS.size();
92 AS.SetSize = 0;
93 *PtrListEnd = AS.PtrList;
94 AS.PtrList->setPrevInList(PtrListEnd);
95 PtrListEnd = AS.PtrListEnd;
96
97 AS.PtrList = nullptr;
98 AS.PtrListEnd = &AS.PtrList;
99 assert(*AS.PtrListEnd == nullptr && "End of list is not null?");
100 }
101 if (ASHadUnknownInsts)
102 AS.dropRef(AST);
103}
104
105void AliasSetTracker::removeAliasSet(AliasSet *AS) {
106 if (AliasSet *Fwd = AS->Forward) {
107 Fwd->dropRef(*this);
108 AS->Forward = nullptr;
109 } else // Update TotalMayAliasSetSize only if not forwarding.
110 if (AS->Alias == AliasSet::SetMayAlias)
111 TotalMayAliasSetSize -= AS->size();
112
113 AliasSets.erase(AS);
114 // If we've removed the saturated alias set, set saturated marker back to
115 // nullptr and ensure this tracker is empty.
116 if (AS == AliasAnyAS) {
117 AliasAnyAS = nullptr;
118 assert(AliasSets.empty() && "Tracker not empty");
119 }
120}
121
122void AliasSet::removeFromTracker(AliasSetTracker &AST) {
123 assert(RefCount == 0 && "Cannot remove non-dead alias set from tracker!");
124 AST.removeAliasSet(this);
125}
126
127void AliasSet::addPointer(AliasSetTracker &AST, PointerRec &Entry,
128 LocationSize Size, const AAMDNodes &AAInfo,
129 bool KnownMustAlias, bool SkipSizeUpdate) {
130 assert(!Entry.hasAliasSet() && "Entry already in set!");
131
132 // Check to see if we have to downgrade to _may_ alias.
133 if (isMustAlias())
134 if (PointerRec *P = getSomePointer()) {
135 if (!KnownMustAlias) {
138 MemoryLocation(P->getValue(), P->getSize(), P->getAAInfo()),
139 MemoryLocation(Entry.getValue(), Size, AAInfo));
140 if (Result != AliasResult::MustAlias) {
141 Alias = SetMayAlias;
142 AST.TotalMayAliasSetSize += size();
143 }
144 assert(Result != AliasResult::NoAlias && "Cannot be part of must set!");
145 } else if (!SkipSizeUpdate)
146 P->updateSizeAndAAInfo(Size, AAInfo);
147 }
148
149 Entry.setAliasSet(this);
150 Entry.updateSizeAndAAInfo(Size, AAInfo);
151
152 // Add it to the end of the list...
153 ++SetSize;
154 assert(*PtrListEnd == nullptr && "End of list is not null?");
155 *PtrListEnd = &Entry;
156 PtrListEnd = Entry.setPrevInList(PtrListEnd);
157 assert(*PtrListEnd == nullptr && "End of list is not null?");
158 // Entry points to alias set.
159 addRef();
160
161 if (Alias == SetMayAlias)
162 AST.TotalMayAliasSetSize++;
163}
164
165void AliasSet::addUnknownInst(Instruction *I, BatchAAResults &AA) {
166 if (UnknownInsts.empty())
167 addRef();
168 UnknownInsts.emplace_back(I);
169
170 // Guards are marked as modifying memory for control flow modelling purposes,
171 // but don't actually modify any specific memory location.
172 using namespace PatternMatch;
173 bool MayWriteMemory = I->mayWriteToMemory() && !isGuard(I) &&
174 !(I->use_empty() && match(I, m_Intrinsic<Intrinsic::invariant_start>()));
175 if (!MayWriteMemory) {
176 Alias = SetMayAlias;
177 Access |= RefAccess;
178 return;
179 }
180
181 // FIXME: This should use mod/ref information to make this not suck so bad
182 Alias = SetMayAlias;
183 Access = ModRefAccess;
184}
185
186/// aliasesPointer - If the specified pointer "may" (or must) alias one of the
187/// members in the set return the appropriate AliasResult. Otherwise return
188/// NoAlias.
189///
191 const AAMDNodes &AAInfo,
192 BatchAAResults &AA) const {
193 if (AliasAny)
195
196 if (Alias == SetMustAlias) {
197 assert(UnknownInsts.empty() && "Illegal must alias set!");
198
199 // If this is a set of MustAliases, only check to see if the pointer aliases
200 // SOME value in the set.
201 PointerRec *SomePtr = getSomePointer();
202 assert(SomePtr && "Empty must-alias set??");
203 return AA.alias(MemoryLocation(SomePtr->getValue(), SomePtr->getSize(),
204 SomePtr->getAAInfo()),
205 MemoryLocation(Ptr, Size, AAInfo));
206 }
207
208 // If this is a may-alias set, we have to check all of the pointers in the set
209 // to be sure it doesn't alias the set...
210 for (iterator I = begin(), E = end(); I != E; ++I) {
211 AliasResult AR =
212 AA.alias(MemoryLocation(Ptr, Size, AAInfo),
213 MemoryLocation(I.getPointer(), I.getSize(), I.getAAInfo()));
214 if (AR != AliasResult::NoAlias)
215 return AR;
216 }
217
218 // Check the unknown instructions...
219 if (!UnknownInsts.empty()) {
220 for (Instruction *Inst : UnknownInsts)
221 if (isModOrRefSet(
222 AA.getModRefInfo(Inst, MemoryLocation(Ptr, Size, AAInfo))))
224 }
225
227}
228
230 BatchAAResults &AA) const {
231
232 if (AliasAny)
233 return ModRefInfo::ModRef;
234
235 if (!Inst->mayReadOrWriteMemory())
237
238 for (Instruction *UnknownInst : UnknownInsts) {
239 const auto *C1 = dyn_cast<CallBase>(UnknownInst);
240 const auto *C2 = dyn_cast<CallBase>(Inst);
241 if (!C1 || !C2 || isModOrRefSet(AA.getModRefInfo(C1, C2)) ||
242 isModOrRefSet(AA.getModRefInfo(C2, C1))) {
243 // TODO: Could be more precise, but not really useful right now.
244 return ModRefInfo::ModRef;
245 }
246 }
247
249 for (iterator I = begin(), E = end(); I != E; ++I) {
250 MR |= AA.getModRefInfo(
251 Inst, MemoryLocation(I.getPointer(), I.getSize(), I.getAAInfo()));
252 if (isModAndRefSet(MR))
253 return MR;
254 }
255
256 return MR;
257}
258
260 // Delete all the PointerRec entries.
261 for (auto &I : PointerMap)
262 I.second->eraseFromList();
263
264 PointerMap.clear();
265
266 // The alias sets should all be clear now.
267 AliasSets.clear();
268}
269
270/// mergeAliasSetsForPointer - Given a pointer, merge all alias sets that may
271/// alias the pointer. Return the unified set, or nullptr if no set that aliases
272/// the pointer was found. MustAliasAll is updated to true/false if the pointer
273/// is found to MustAlias all the sets it merged.
274AliasSet *AliasSetTracker::mergeAliasSetsForPointer(const Value *Ptr,
276 const AAMDNodes &AAInfo,
277 bool &MustAliasAll) {
278 AliasSet *FoundSet = nullptr;
279 MustAliasAll = true;
280 for (AliasSet &AS : llvm::make_early_inc_range(*this)) {
281 if (AS.Forward)
282 continue;
283
284 AliasResult AR = AS.aliasesPointer(Ptr, Size, AAInfo, AA);
285 if (AR == AliasResult::NoAlias)
286 continue;
287
288 if (AR != AliasResult::MustAlias)
289 MustAliasAll = false;
290
291 if (!FoundSet) {
292 // If this is the first alias set ptr can go into, remember it.
293 FoundSet = &AS;
294 } else {
295 // Otherwise, we must merge the sets.
296 FoundSet->mergeSetIn(AS, *this, AA);
297 }
298 }
299
300 return FoundSet;
301}
302
303AliasSet *AliasSetTracker::findAliasSetForUnknownInst(Instruction *Inst) {
304 AliasSet *FoundSet = nullptr;
305 for (AliasSet &AS : llvm::make_early_inc_range(*this)) {
306 if (AS.Forward || !isModOrRefSet(AS.aliasesUnknownInst(Inst, AA)))
307 continue;
308 if (!FoundSet) {
309 // If this is the first alias set ptr can go into, remember it.
310 FoundSet = &AS;
311 } else {
312 // Otherwise, we must merge the sets.
313 FoundSet->mergeSetIn(AS, *this, AA);
314 }
315 }
316 return FoundSet;
317}
318
320
321 Value * const Pointer = const_cast<Value*>(MemLoc.Ptr);
322 const LocationSize Size = MemLoc.Size;
323 const AAMDNodes &AAInfo = MemLoc.AATags;
324
325 AliasSet::PointerRec &Entry = getEntryFor(Pointer);
326
327 if (AliasAnyAS) {
328 // At this point, the AST is saturated, so we only have one active alias
329 // set. That means we already know which alias set we want to return, and
330 // just need to add the pointer to that set to keep the data structure
331 // consistent.
332 // This, of course, means that we will never need a merge here.
333 if (Entry.hasAliasSet()) {
334 Entry.updateSizeAndAAInfo(Size, AAInfo);
335 assert(Entry.getAliasSet(*this) == AliasAnyAS &&
336 "Entry in saturated AST must belong to only alias set");
337 } else {
338 AliasAnyAS->addPointer(*this, Entry, Size, AAInfo);
339 }
340 return *AliasAnyAS;
341 }
342
343 bool MustAliasAll = false;
344 // Check to see if the pointer is already known.
345 if (Entry.hasAliasSet()) {
346 // If the size changed, we may need to merge several alias sets.
347 // Note that we can *not* return the result of mergeAliasSetsForPointer
348 // due to a quirk of alias analysis behavior. Since alias(undef, undef)
349 // is NoAlias, mergeAliasSetsForPointer(undef, ...) will not find the
350 // the right set for undef, even if it exists.
351 if (Entry.updateSizeAndAAInfo(Size, AAInfo))
352 mergeAliasSetsForPointer(Pointer, Size, AAInfo, MustAliasAll);
353 // Return the set!
354 return *Entry.getAliasSet(*this)->getForwardedTarget(*this);
355 }
356
357 if (AliasSet *AS =
358 mergeAliasSetsForPointer(Pointer, Size, AAInfo, MustAliasAll)) {
359 // Add it to the alias set it aliases.
360 AS->addPointer(*this, Entry, Size, AAInfo, MustAliasAll);
361 return *AS;
362 }
363
364 // Otherwise create a new alias set to hold the loaded pointer.
365 AliasSets.push_back(new AliasSet());
366 AliasSets.back().addPointer(*this, Entry, Size, AAInfo, true);
367 return AliasSets.back();
368}
369
371 const AAMDNodes &AAInfo) {
372 addPointer(MemoryLocation(Ptr, Size, AAInfo), AliasSet::NoAccess);
373}
374
377 return addUnknown(LI);
378 addPointer(MemoryLocation::get(LI), AliasSet::RefAccess);
379}
380
382 if (isStrongerThanMonotonic(SI->getOrdering()))
383 return addUnknown(SI);
384 addPointer(MemoryLocation::get(SI), AliasSet::ModAccess);
385}
386
388 addPointer(MemoryLocation::get(VAAI), AliasSet::ModRefAccess);
389}
390
392 addPointer(MemoryLocation::getForDest(MSI), AliasSet::ModAccess);
393}
394
396 addPointer(MemoryLocation::getForDest(MTI), AliasSet::ModAccess);
397 addPointer(MemoryLocation::getForSource(MTI), AliasSet::RefAccess);
398}
399
401 if (isa<DbgInfoIntrinsic>(Inst))
402 return; // Ignore DbgInfo Intrinsics.
403
404 if (auto *II = dyn_cast<IntrinsicInst>(Inst)) {
405 // These intrinsics will show up as affecting memory, but they are just
406 // markers.
407 switch (II->getIntrinsicID()) {
408 default:
409 break;
410 // FIXME: Add lifetime/invariant intrinsics (See: PR30807).
411 case Intrinsic::assume:
412 case Intrinsic::experimental_noalias_scope_decl:
413 case Intrinsic::sideeffect:
414 case Intrinsic::pseudoprobe:
415 return;
416 }
417 }
418 if (!Inst->mayReadOrWriteMemory())
419 return; // doesn't alias anything
420
421 if (AliasSet *AS = findAliasSetForUnknownInst(Inst)) {
422 AS->addUnknownInst(Inst, AA);
423 return;
424 }
425 AliasSets.push_back(new AliasSet());
426 AliasSets.back().addUnknownInst(Inst, AA);
427}
428
430 // Dispatch to one of the other add methods.
431 if (LoadInst *LI = dyn_cast<LoadInst>(I))
432 return add(LI);
433 if (StoreInst *SI = dyn_cast<StoreInst>(I))
434 return add(SI);
435 if (VAArgInst *VAAI = dyn_cast<VAArgInst>(I))
436 return add(VAAI);
437 if (AnyMemSetInst *MSI = dyn_cast<AnyMemSetInst>(I))
438 return add(MSI);
439 if (AnyMemTransferInst *MTI = dyn_cast<AnyMemTransferInst>(I))
440 return add(MTI);
441
442 // Handle all calls with known mod/ref sets genericall
443 if (auto *Call = dyn_cast<CallBase>(I))
444 if (Call->onlyAccessesArgMemory()) {
445 auto getAccessFromModRef = [](ModRefInfo MRI) {
446 if (isRefSet(MRI) && isModSet(MRI))
447 return AliasSet::ModRefAccess;
448 else if (isModSet(MRI))
449 return AliasSet::ModAccess;
450 else if (isRefSet(MRI))
451 return AliasSet::RefAccess;
452 else
453 return AliasSet::NoAccess;
454 };
455
456 ModRefInfo CallMask = AA.getMemoryEffects(Call).getModRef();
457
458 // Some intrinsics are marked as modifying memory for control flow
459 // modelling purposes, but don't actually modify any specific memory
460 // location.
461 using namespace PatternMatch;
462 if (Call->use_empty() &&
463 match(Call, m_Intrinsic<Intrinsic::invariant_start>()))
464 CallMask &= ModRefInfo::Ref;
465
466 for (auto IdxArgPair : enumerate(Call->args())) {
467 int ArgIdx = IdxArgPair.index();
468 const Value *Arg = IdxArgPair.value();
469 if (!Arg->getType()->isPointerTy())
470 continue;
471 MemoryLocation ArgLoc =
472 MemoryLocation::getForArgument(Call, ArgIdx, nullptr);
473 ModRefInfo ArgMask = AA.getArgModRefInfo(Call, ArgIdx);
474 ArgMask &= CallMask;
475 if (!isNoModRef(ArgMask))
476 addPointer(ArgLoc, getAccessFromModRef(ArgMask));
477 }
478 return;
479 }
480
481 return addUnknown(I);
482}
483
485 for (auto &I : BB)
486 add(&I);
487}
488
490 assert(&AA == &AST.AA &&
491 "Merging AliasSetTracker objects with different Alias Analyses!");
492
493 // Loop over all of the alias sets in AST, adding the pointers contained
494 // therein into the current alias sets. This can cause alias sets to be
495 // merged together in the current AST.
496 for (const AliasSet &AS : AST) {
497 if (AS.Forward)
498 continue; // Ignore forwarding alias sets
499
500 // If there are any call sites in the alias set, add them to this AST.
501 for (Instruction *Inst : AS.UnknownInsts)
502 add(Inst);
503
504 // Loop over all of the pointers in this alias set.
505 for (AliasSet::iterator ASI = AS.begin(), E = AS.end(); ASI != E; ++ASI)
506 addPointer(
507 MemoryLocation(ASI.getPointer(), ASI.getSize(), ASI.getAAInfo()),
508 (AliasSet::AccessLattice)AS.Access);
509 }
510}
511
512AliasSet &AliasSetTracker::mergeAllAliasSets() {
513 assert(!AliasAnyAS && (TotalMayAliasSetSize > SaturationThreshold) &&
514 "Full merge should happen once, when the saturation threshold is "
515 "reached");
516
517 // Collect all alias sets, so that we can drop references with impunity
518 // without worrying about iterator invalidation.
519 std::vector<AliasSet *> ASVector;
520 ASVector.reserve(SaturationThreshold);
521 for (AliasSet &AS : *this)
522 ASVector.push_back(&AS);
523
524 // Copy all instructions and pointers into a new set, and forward all other
525 // sets to it.
526 AliasSets.push_back(new AliasSet());
527 AliasAnyAS = &AliasSets.back();
528 AliasAnyAS->Alias = AliasSet::SetMayAlias;
529 AliasAnyAS->Access = AliasSet::ModRefAccess;
530 AliasAnyAS->AliasAny = true;
531
532 for (auto *Cur : ASVector) {
533 // If Cur was already forwarding, just forward to the new AS instead.
534 AliasSet *FwdTo = Cur->Forward;
535 if (FwdTo) {
536 Cur->Forward = AliasAnyAS;
537 AliasAnyAS->addRef();
538 FwdTo->dropRef(*this);
539 continue;
540 }
541
542 // Otherwise, perform the actual merge.
543 AliasAnyAS->mergeSetIn(*Cur, *this, AA);
544 }
545
546 return *AliasAnyAS;
547}
548
549AliasSet &AliasSetTracker::addPointer(MemoryLocation Loc,
550 AliasSet::AccessLattice E) {
551 AliasSet &AS = getAliasSetFor(Loc);
552 AS.Access |= E;
553
554 if (!AliasAnyAS && (TotalMayAliasSetSize > SaturationThreshold)) {
555 // The AST is now saturated. From here on, we conservatively consider all
556 // pointers to alias each-other.
557 return mergeAllAliasSets();
558 }
559
560 return AS;
561}
562
563//===----------------------------------------------------------------------===//
564// AliasSet/AliasSetTracker Printing Support
565//===----------------------------------------------------------------------===//
566
568 OS << " AliasSet[" << (const void*)this << ", " << RefCount << "] ";
569 OS << (Alias == SetMustAlias ? "must" : "may") << " alias, ";
570 switch (Access) {
571 case NoAccess: OS << "No access "; break;
572 case RefAccess: OS << "Ref "; break;
573 case ModAccess: OS << "Mod "; break;
574 case ModRefAccess: OS << "Mod/Ref "; break;
575 default: llvm_unreachable("Bad value for Access!");
576 }
577 if (Forward)
578 OS << " forwarding to " << (void*)Forward;
579
580 if (!empty()) {
581 OS << "Pointers: ";
582 for (iterator I = begin(), E = end(); I != E; ++I) {
583 if (I != begin()) OS << ", ";
584 I.getPointer()->printAsOperand(OS << "(");
585 if (I.getSize() == LocationSize::afterPointer())
586 OS << ", unknown after)";
587 else if (I.getSize() == LocationSize::beforeOrAfterPointer())
588 OS << ", unknown before-or-after)";
589 else
590 OS << ", " << I.getSize() << ")";
591 }
592 }
593 if (!UnknownInsts.empty()) {
594 ListSeparator LS;
595 OS << "\n " << UnknownInsts.size() << " Unknown instructions: ";
596 for (Instruction *I : UnknownInsts) {
597 OS << LS;
598 if (I->hasName())
599 I->printAsOperand(OS);
600 else
601 I->print(OS);
602 }
603 }
604 OS << "\n";
605}
606
608 OS << "Alias Set Tracker: " << AliasSets.size();
609 if (AliasAnyAS)
610 OS << " (Saturated)";
611 OS << " alias sets for " << PointerMap.size() << " pointer values.\n";
612 for (const AliasSet &AS : *this)
613 AS.print(OS);
614 OS << "\n";
615}
616
617#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
620#endif
621
622//===----------------------------------------------------------------------===//
623// AliasSetPrinter Pass
624//===----------------------------------------------------------------------===//
625
627
630 auto &AA = AM.getResult<AAManager>(F);
631 BatchAAResults BatchAA(AA);
632 AliasSetTracker Tracker(BatchAA);
633 OS << "Alias sets for function '" << F.getName() << "':\n";
634 for (Instruction &I : instructions(F))
635 Tracker.add(&I);
636 Tracker.print(OS);
637 return PreservedAnalyses::all();
638}
unsigned const MachineRegisterInfo * MRI
static cl::opt< unsigned > SaturationThreshold("alias-set-saturation-threshold", cl::Hidden, cl::init(250), cl::desc("The maximum number of pointers may-alias " "sets may contain before degradation"))
Atomic ordering constants.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:510
uint64_t Size
Select target instructions out of generic instructions
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
This file provides utility analysis objects describing memory locations.
#define P(N)
This header defines various interfaces for pass management in LLVM.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
This file contains some functions that are useful when dealing with strings.
A manager for alias analyses.
The possible results of an alias query.
Definition: AliasAnalysis.h:82
@ MayAlias
The two locations may or may not alias.
@ NoAlias
The two locations do not alias at all.
@ MustAlias
The two locations precisely alias each other.
BatchAAResults & getAliasAnalysis() const
Return the underlying alias analysis object used by this tracker.
AliasSet & getAliasSetFor(const MemoryLocation &MemLoc)
Return the alias set which contains the specified memory location.
void addUnknown(Instruction *I)
void print(raw_ostream &OS) const
void add(Value *Ptr, LocationSize Size, const AAMDNodes &AAInfo)
These methods are used to add different types of instructions to the alias sets.
Define an iterator for alias sets... this is just a forward iterator.
iterator begin() const
void mergeSetIn(AliasSet &AS, AliasSetTracker &AST, BatchAAResults &BatchAA)
Merge the specified alias set into this alias set.
void print(raw_ostream &OS) const
iterator end() const
bool empty() const
ModRefInfo aliasesUnknownInst(const Instruction *Inst, BatchAAResults &AA) const
AliasResult aliasesPointer(const Value *Ptr, LocationSize Size, const AAMDNodes &AAInfo, BatchAAResults &AA) const
If the specified pointer "may" (or must) alias one of the members in the set return the appropriate A...
bool isMustAlias() const
void dump() const
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
AliasSetsPrinterPass(raw_ostream &OS)
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:620
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:774
This class represents any memset intrinsic.
LLVM Basic Block Representation.
Definition: BasicBlock.h:56
This class is a wrapper over an AAResults, and it is intended to be used only when there are no IR ch...
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx)
bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
MemoryEffects getMemoryEffects(const CallBase *Call)
ModRefInfo getModRefInfo(const Instruction *I, const std::optional< MemoryLocation > &OptLoc)
unsigned size() const
Definition: DenseMap.h:99
bool mayReadOrWriteMemory() const
Return true if this instruction may read or write memory.
Definition: Instruction.h:664
An instruction for reading from memory.
Definition: Instructions.h:177
AtomicOrdering getOrdering() const
Returns the ordering constraint of this load instruction.
Definition: Instructions.h:229
static constexpr LocationSize beforeOrAfterPointer()
Any location before or after the base pointer (but still within the underlying object).
static constexpr LocationSize afterPointer()
Any location after the base pointer (but still within the underlying object).
ModRefInfo getModRef(Location Loc) const
Get ModRefInfo for the given Location.
Definition: ModRef.h:165
Representation for a specific memory location.
static MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
static MemoryLocation getForSource(const MemTransferInst *MTI)
Return a location representing the source of a memory transfer.
LocationSize Size
The maximum size of the location, in address-units, or UnknownSize if the size is not known.
AAMDNodes AATags
The metadata nodes which describes the aliasing of the location (each member is null if that kind of ...
const Value * Ptr
The address of the start of the location.
static MemoryLocation getForDest(const MemIntrinsic *MI)
Return a location representing the destination of a memory set or transfer.
static MemoryLocation getForArgument(const CallBase *Call, unsigned ArgIdx, const TargetLibraryInfo *TLI)
Return a location representing a particular argument of a call.
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:158
An instruction for storing to memory.
Definition: Instructions.h:301
bool isPointerTy() const
True if this is an instance of PointerType.
Definition: Type.h:255
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
LLVM Value Representation.
Definition: Value.h:74
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool match(Val *V, const Pattern &P)
Definition: PatternMatch.h:49
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:445
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are are tuples (A,...
Definition: STLExtras.h:2338
bool isStrongerThanMonotonic(AtomicOrdering AO)
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
Definition: STLExtras.h:2037
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
Definition: STLExtras.h:666
bool isGuard(const User *U)
Returns true iff U has semantics of a guard expressed in a form of call of llvm.experimental....
Definition: GuardUtils.cpp:18
bool isModSet(const ModRefInfo MRI)
Definition: ModRef.h:48
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
bool isModOrRefSet(const ModRefInfo MRI)
Definition: ModRef.h:42
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
Definition: ModRef.h:27
@ Ref
The access may reference the value stored in memory.
@ ModRef
The access may reference and may modify the value stored in memory.
@ NoModRef
The access neither references nor modifies the value stored in memory.
bool isModAndRefSet(const ModRefInfo MRI)
Definition: ModRef.h:45
bool isNoModRef(const ModRefInfo MRI)
Definition: ModRef.h:39
bool isRefSet(const ModRefInfo MRI)
Definition: ModRef.h:51
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:860
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition: Metadata.h:651