LLVM  3.7.0
AliasSetTracker.cpp
Go to the documentation of this file.
1 //===- AliasSetTracker.cpp - Alias Sets Tracker implementation-------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the AliasSetTracker and AliasSet classes.
11 //
12 //===----------------------------------------------------------------------===//
13 
16 #include "llvm/IR/DataLayout.h"
17 #include "llvm/IR/InstIterator.h"
18 #include "llvm/IR/Instructions.h"
19 #include "llvm/IR/IntrinsicInst.h"
20 #include "llvm/IR/LLVMContext.h"
21 #include "llvm/IR/Type.h"
22 #include "llvm/Pass.h"
23 #include "llvm/Support/Debug.h"
26 using namespace llvm;
27 
28 /// mergeSetIn - Merge the specified alias set into this alias set.
29 ///
31  assert(!AS.Forward && "Alias set is already forwarding!");
32  assert(!Forward && "This set is a forwarding set!!");
33 
34  // Update the alias and access types of this set...
35  Access |= AS.Access;
36  Alias |= AS.Alias;
37  Volatile |= AS.Volatile;
38 
39  if (Alias == SetMustAlias) {
40  // Check that these two merged sets really are must aliases. Since both
41  // used to be must-alias sets, we can just check any pointer from each set
42  // for aliasing.
43  AliasAnalysis &AA = AST.getAliasAnalysis();
44  PointerRec *L = getSomePointer();
45  PointerRec *R = AS.getSomePointer();
46 
47  // If the pointers are not a must-alias pair, this set becomes a may alias.
48  if (AA.alias(MemoryLocation(L->getValue(), L->getSize(), L->getAAInfo()),
49  MemoryLocation(R->getValue(), R->getSize(), R->getAAInfo())) !=
50  MustAlias)
51  Alias = SetMayAlias;
52  }
53 
54  bool ASHadUnknownInsts = !AS.UnknownInsts.empty();
55  if (UnknownInsts.empty()) { // Merge call sites...
56  if (ASHadUnknownInsts) {
57  std::swap(UnknownInsts, AS.UnknownInsts);
58  addRef();
59  }
60  } else if (ASHadUnknownInsts) {
61  UnknownInsts.insert(UnknownInsts.end(), AS.UnknownInsts.begin(), AS.UnknownInsts.end());
62  AS.UnknownInsts.clear();
63  }
64 
65  AS.Forward = this; // Forward across AS now...
66  addRef(); // AS is now pointing to us...
67 
68  // Merge the list of constituent pointers...
69  if (AS.PtrList) {
70  *PtrListEnd = AS.PtrList;
71  AS.PtrList->setPrevInList(PtrListEnd);
72  PtrListEnd = AS.PtrListEnd;
73 
74  AS.PtrList = nullptr;
75  AS.PtrListEnd = &AS.PtrList;
76  assert(*AS.PtrListEnd == nullptr && "End of list is not null?");
77  }
78  if (ASHadUnknownInsts)
79  AS.dropRef(AST);
80 }
81 
82 void AliasSetTracker::removeAliasSet(AliasSet *AS) {
83  if (AliasSet *Fwd = AS->Forward) {
84  Fwd->dropRef(*this);
85  AS->Forward = nullptr;
86  }
87  AliasSets.erase(AS);
88 }
89 
90 void AliasSet::removeFromTracker(AliasSetTracker &AST) {
91  assert(RefCount == 0 && "Cannot remove non-dead alias set from tracker!");
92  AST.removeAliasSet(this);
93 }
94 
95 void AliasSet::addPointer(AliasSetTracker &AST, PointerRec &Entry,
96  uint64_t Size, const AAMDNodes &AAInfo,
97  bool KnownMustAlias) {
98  assert(!Entry.hasAliasSet() && "Entry already in set!");
99 
100  // Check to see if we have to downgrade to _may_ alias.
101  if (isMustAlias() && !KnownMustAlias)
102  if (PointerRec *P = getSomePointer()) {
103  AliasAnalysis &AA = AST.getAliasAnalysis();
104  AliasResult Result =
105  AA.alias(MemoryLocation(P->getValue(), P->getSize(), P->getAAInfo()),
106  MemoryLocation(Entry.getValue(), Size, AAInfo));
107  if (Result != MustAlias)
108  Alias = SetMayAlias;
109  else // First entry of must alias must have maximum size!
110  P->updateSizeAndAAInfo(Size, AAInfo);
111  assert(Result != NoAlias && "Cannot be part of must set!");
112  }
113 
114  Entry.setAliasSet(this);
115  Entry.updateSizeAndAAInfo(Size, AAInfo);
116 
117  // Add it to the end of the list...
118  assert(*PtrListEnd == nullptr && "End of list is not null?");
119  *PtrListEnd = &Entry;
120  PtrListEnd = Entry.setPrevInList(PtrListEnd);
121  assert(*PtrListEnd == nullptr && "End of list is not null?");
122  addRef(); // Entry points to alias set.
123 }
124 
125 void AliasSet::addUnknownInst(Instruction *I, AliasAnalysis &AA) {
126  if (UnknownInsts.empty())
127  addRef();
128  UnknownInsts.emplace_back(I);
129 
130  if (!I->mayWriteToMemory()) {
131  Alias = SetMayAlias;
132  Access |= RefAccess;
133  return;
134  }
135 
136  // FIXME: This should use mod/ref information to make this not suck so bad
137  Alias = SetMayAlias;
138  Access = ModRefAccess;
139 }
140 
141 /// aliasesPointer - Return true if the specified pointer "may" (or must)
142 /// alias one of the members in the set.
143 ///
144 bool AliasSet::aliasesPointer(const Value *Ptr, uint64_t Size,
145  const AAMDNodes &AAInfo,
146  AliasAnalysis &AA) const {
147  if (Alias == SetMustAlias) {
148  assert(UnknownInsts.empty() && "Illegal must alias set!");
149 
150  // If this is a set of MustAliases, only check to see if the pointer aliases
151  // SOME value in the set.
152  PointerRec *SomePtr = getSomePointer();
153  assert(SomePtr && "Empty must-alias set??");
154  return AA.alias(MemoryLocation(SomePtr->getValue(), SomePtr->getSize(),
155  SomePtr->getAAInfo()),
156  MemoryLocation(Ptr, Size, AAInfo));
157  }
158 
159  // If this is a may-alias set, we have to check all of the pointers in the set
160  // to be sure it doesn't alias the set...
161  for (iterator I = begin(), E = end(); I != E; ++I)
162  if (AA.alias(MemoryLocation(Ptr, Size, AAInfo),
163  MemoryLocation(I.getPointer(), I.getSize(), I.getAAInfo())))
164  return true;
165 
166  // Check the unknown instructions...
167  if (!UnknownInsts.empty()) {
168  for (unsigned i = 0, e = UnknownInsts.size(); i != e; ++i)
169  if (AA.getModRefInfo(UnknownInsts[i],
170  MemoryLocation(Ptr, Size, AAInfo)) !=
172  return true;
173  }
174 
175  return false;
176 }
177 
179  AliasAnalysis &AA) const {
180  if (!Inst->mayReadOrWriteMemory())
181  return false;
182 
183  for (unsigned i = 0, e = UnknownInsts.size(); i != e; ++i) {
184  ImmutableCallSite C1(getUnknownInst(i)), C2(Inst);
185  if (!C1 || !C2 ||
186  AA.getModRefInfo(C1, C2) != AliasAnalysis::NoModRef ||
188  return true;
189  }
190 
191  for (iterator I = begin(), E = end(); I != E; ++I)
192  if (AA.getModRefInfo(
193  Inst, MemoryLocation(I.getPointer(), I.getSize(), I.getAAInfo())) !=
195  return true;
196 
197  return false;
198 }
199 
201  // Delete all the PointerRec entries.
202  for (PointerMapType::iterator I = PointerMap.begin(), E = PointerMap.end();
203  I != E; ++I)
204  I->second->eraseFromList();
205 
206  PointerMap.clear();
207 
208  // The alias sets should all be clear now.
209  AliasSets.clear();
210 }
211 
212 
213 /// findAliasSetForPointer - Given a pointer, find the one alias set to put the
214 /// instruction referring to the pointer into. If there are multiple alias sets
215 /// that may alias the pointer, merge them together and return the unified set.
216 ///
217 AliasSet *AliasSetTracker::findAliasSetForPointer(const Value *Ptr,
218  uint64_t Size,
219  const AAMDNodes &AAInfo) {
220  AliasSet *FoundSet = nullptr;
221  for (iterator I = begin(), E = end(); I != E;) {
222  iterator Cur = I++;
223  if (Cur->Forward || !Cur->aliasesPointer(Ptr, Size, AAInfo, AA)) continue;
224 
225  if (!FoundSet) { // If this is the first alias set ptr can go into.
226  FoundSet = Cur; // Remember it.
227  } else { // Otherwise, we must merge the sets.
228  FoundSet->mergeSetIn(*Cur, *this); // Merge in contents.
229  }
230  }
231 
232  return FoundSet;
233 }
234 
235 /// containsPointer - Return true if the specified location is represented by
236 /// this alias set, false otherwise. This does not modify the AST object or
237 /// alias sets.
238 bool AliasSetTracker::containsPointer(const Value *Ptr, uint64_t Size,
239  const AAMDNodes &AAInfo) const {
240  for (const_iterator I = begin(), E = end(); I != E; ++I)
241  if (!I->Forward && I->aliasesPointer(Ptr, Size, AAInfo, AA))
242  return true;
243  return false;
244 }
245 
247  for (const_iterator I = begin(), E = end(); I != E; ++I)
248  if (!I->Forward && I->aliasesUnknownInst(Inst, AA))
249  return true;
250  return false;
251 }
252 
253 AliasSet *AliasSetTracker::findAliasSetForUnknownInst(Instruction *Inst) {
254  AliasSet *FoundSet = nullptr;
255  for (iterator I = begin(), E = end(); I != E;) {
256  iterator Cur = I++;
257  if (Cur->Forward || !Cur->aliasesUnknownInst(Inst, AA))
258  continue;
259  if (!FoundSet) // If this is the first alias set ptr can go into.
260  FoundSet = Cur; // Remember it.
261  else if (!Cur->Forward) // Otherwise, we must merge the sets.
262  FoundSet->mergeSetIn(*Cur, *this); // Merge in contents.
263  }
264  return FoundSet;
265 }
266 
267 
268 
269 
270 /// getAliasSetForPointer - Return the alias set that the specified pointer
271 /// lives in.
273  const AAMDNodes &AAInfo,
274  bool *New) {
275  AliasSet::PointerRec &Entry = getEntryFor(Pointer);
276 
277  // Check to see if the pointer is already known.
278  if (Entry.hasAliasSet()) {
279  Entry.updateSizeAndAAInfo(Size, AAInfo);
280  // Return the set!
281  return *Entry.getAliasSet(*this)->getForwardedTarget(*this);
282  }
283 
284  if (AliasSet *AS = findAliasSetForPointer(Pointer, Size, AAInfo)) {
285  // Add it to the alias set it aliases.
286  AS->addPointer(*this, Entry, Size, AAInfo);
287  return *AS;
288  }
289 
290  if (New) *New = true;
291  // Otherwise create a new alias set to hold the loaded pointer.
292  AliasSets.push_back(new AliasSet());
293  AliasSets.back().addPointer(*this, Entry, Size, AAInfo);
294  return AliasSets.back();
295 }
296 
297 bool AliasSetTracker::add(Value *Ptr, uint64_t Size, const AAMDNodes &AAInfo) {
298  bool NewPtr;
299  addPointer(Ptr, Size, AAInfo, AliasSet::NoAccess, NewPtr);
300  return NewPtr;
301 }
302 
303 
305  if (LI->getOrdering() > Monotonic) return addUnknown(LI);
306 
307  AAMDNodes AAInfo;
308  LI->getAAMetadata(AAInfo);
309 
310  AliasSet::AccessLattice Access = AliasSet::RefAccess;
311  bool NewPtr;
312  AliasSet &AS = addPointer(LI->getOperand(0),
313  AA.getTypeStoreSize(LI->getType()),
314  AAInfo, Access, NewPtr);
315  if (LI->isVolatile()) AS.setVolatile();
316  return NewPtr;
317 }
318 
320  if (SI->getOrdering() > Monotonic) return addUnknown(SI);
321 
322  AAMDNodes AAInfo;
323  SI->getAAMetadata(AAInfo);
324 
325  AliasSet::AccessLattice Access = AliasSet::ModAccess;
326  bool NewPtr;
327  Value *Val = SI->getOperand(0);
328  AliasSet &AS = addPointer(SI->getOperand(1),
329  AA.getTypeStoreSize(Val->getType()),
330  AAInfo, Access, NewPtr);
331  if (SI->isVolatile()) AS.setVolatile();
332  return NewPtr;
333 }
334 
336  AAMDNodes AAInfo;
337  VAAI->getAAMetadata(AAInfo);
338 
339  bool NewPtr;
340  addPointer(VAAI->getOperand(0), MemoryLocation::UnknownSize, AAInfo,
341  AliasSet::ModRefAccess, NewPtr);
342  return NewPtr;
343 }
344 
345 
347  if (isa<DbgInfoIntrinsic>(Inst))
348  return true; // Ignore DbgInfo Intrinsics.
349  if (!Inst->mayReadOrWriteMemory())
350  return true; // doesn't alias anything
351 
352  AliasSet *AS = findAliasSetForUnknownInst(Inst);
353  if (AS) {
354  AS->addUnknownInst(Inst, AA);
355  return false;
356  }
357  AliasSets.push_back(new AliasSet());
358  AS = &AliasSets.back();
359  AS->addUnknownInst(Inst, AA);
360  return true;
361 }
362 
364  // Dispatch to one of the other add methods.
365  if (LoadInst *LI = dyn_cast<LoadInst>(I))
366  return add(LI);
367  if (StoreInst *SI = dyn_cast<StoreInst>(I))
368  return add(SI);
369  if (VAArgInst *VAAI = dyn_cast<VAArgInst>(I))
370  return add(VAAI);
371  return addUnknown(I);
372 }
373 
375  for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I)
376  add(I);
377 }
378 
380  assert(&AA == &AST.AA &&
381  "Merging AliasSetTracker objects with different Alias Analyses!");
382 
383  // Loop over all of the alias sets in AST, adding the pointers contained
384  // therein into the current alias sets. This can cause alias sets to be
385  // merged together in the current AST.
386  for (const_iterator I = AST.begin(), E = AST.end(); I != E; ++I) {
387  if (I->Forward) continue; // Ignore forwarding alias sets
388 
389  AliasSet &AS = const_cast<AliasSet&>(*I);
390 
391  // If there are any call sites in the alias set, add them to this AST.
392  for (unsigned i = 0, e = AS.UnknownInsts.size(); i != e; ++i)
393  add(AS.UnknownInsts[i]);
394 
395  // Loop over all of the pointers in this alias set.
396  bool X;
397  for (AliasSet::iterator ASI = AS.begin(), E = AS.end(); ASI != E; ++ASI) {
398  AliasSet &NewAS = addPointer(ASI.getPointer(), ASI.getSize(),
399  ASI.getAAInfo(),
400  (AliasSet::AccessLattice)AS.Access, X);
401  if (AS.isVolatile()) NewAS.setVolatile();
402  }
403  }
404 }
405 
406 /// remove - Remove the specified (potentially non-empty) alias set from the
407 /// tracker.
409  // Drop all call sites.
410  if (!AS.UnknownInsts.empty())
411  AS.dropRef(*this);
412  AS.UnknownInsts.clear();
413 
414  // Clear the alias set.
415  unsigned NumRefs = 0;
416  while (!AS.empty()) {
417  AliasSet::PointerRec *P = AS.PtrList;
418 
419  Value *ValToRemove = P->getValue();
420 
421  // Unlink and delete entry from the list of values.
422  P->eraseFromList();
423 
424  // Remember how many references need to be dropped.
425  ++NumRefs;
426 
427  // Finally, remove the entry.
428  PointerMap.erase(ValToRemove);
429  }
430 
431  // Stop using the alias set, removing it.
432  AS.RefCount -= NumRefs;
433  if (AS.RefCount == 0)
434  AS.removeFromTracker(*this);
435 }
436 
437 bool
438 AliasSetTracker::remove(Value *Ptr, uint64_t Size, const AAMDNodes &AAInfo) {
439  AliasSet *AS = findAliasSetForPointer(Ptr, Size, AAInfo);
440  if (!AS) return false;
441  remove(*AS);
442  return true;
443 }
444 
446  uint64_t Size = AA.getTypeStoreSize(LI->getType());
447 
448  AAMDNodes AAInfo;
449  LI->getAAMetadata(AAInfo);
450 
451  AliasSet *AS = findAliasSetForPointer(LI->getOperand(0), Size, AAInfo);
452  if (!AS) return false;
453  remove(*AS);
454  return true;
455 }
456 
458  uint64_t Size = AA.getTypeStoreSize(SI->getOperand(0)->getType());
459 
460  AAMDNodes AAInfo;
461  SI->getAAMetadata(AAInfo);
462 
463  AliasSet *AS = findAliasSetForPointer(SI->getOperand(1), Size, AAInfo);
464  if (!AS) return false;
465  remove(*AS);
466  return true;
467 }
468 
470  AAMDNodes AAInfo;
471  VAAI->getAAMetadata(AAInfo);
472 
473  AliasSet *AS = findAliasSetForPointer(VAAI->getOperand(0),
475  if (!AS) return false;
476  remove(*AS);
477  return true;
478 }
479 
481  if (!I->mayReadOrWriteMemory())
482  return false; // doesn't alias anything
483 
484  AliasSet *AS = findAliasSetForUnknownInst(I);
485  if (!AS) return false;
486  remove(*AS);
487  return true;
488 }
489 
491  // Dispatch to one of the other remove methods...
492  if (LoadInst *LI = dyn_cast<LoadInst>(I))
493  return remove(LI);
494  if (StoreInst *SI = dyn_cast<StoreInst>(I))
495  return remove(SI);
496  if (VAArgInst *VAAI = dyn_cast<VAArgInst>(I))
497  return remove(VAAI);
498  return removeUnknown(I);
499 }
500 
501 
502 // deleteValue method - This method is used to remove a pointer value from the
503 // AliasSetTracker entirely. It should be used when an instruction is deleted
504 // from the program to update the AST. If you don't use this, you would have
505 // dangling pointers to deleted instructions.
506 //
508  // Notify the alias analysis implementation that this value is gone.
509  AA.deleteValue(PtrVal);
510 
511  // If this is a call instruction, remove the callsite from the appropriate
512  // AliasSet (if present).
513  if (Instruction *Inst = dyn_cast<Instruction>(PtrVal)) {
514  if (Inst->mayReadOrWriteMemory()) {
515  // Scan all the alias sets to see if this call site is contained.
516  for (iterator I = begin(), E = end(); I != E;) {
517  iterator Cur = I++;
518  if (!Cur->Forward)
519  Cur->removeUnknownInst(*this, Inst);
520  }
521  }
522  }
523 
524  // First, look up the PointerRec for this pointer.
525  PointerMapType::iterator I = PointerMap.find_as(PtrVal);
526  if (I == PointerMap.end()) return; // Noop
527 
528  // If we found one, remove the pointer from the alias set it is in.
529  AliasSet::PointerRec *PtrValEnt = I->second;
530  AliasSet *AS = PtrValEnt->getAliasSet(*this);
531 
532  // Unlink and delete from the list of values.
533  PtrValEnt->eraseFromList();
534 
535  // Stop using the alias set.
536  AS->dropRef(*this);
537 
538  PointerMap.erase(I);
539 }
540 
541 // copyValue - This method should be used whenever a preexisting value in the
542 // program is copied or cloned, introducing a new value. Note that it is ok for
543 // clients that use this method to introduce the same value multiple times: if
544 // the tracker already knows about a value, it will ignore the request.
545 //
547  // First, look up the PointerRec for this pointer.
548  PointerMapType::iterator I = PointerMap.find_as(From);
549  if (I == PointerMap.end())
550  return; // Noop
551  assert(I->second->hasAliasSet() && "Dead entry?");
552 
553  AliasSet::PointerRec &Entry = getEntryFor(To);
554  if (Entry.hasAliasSet()) return; // Already in the tracker!
555 
556  // Add it to the alias set it aliases...
557  I = PointerMap.find_as(From);
558  AliasSet *AS = I->second->getAliasSet(*this);
559  AS->addPointer(*this, Entry, I->second->getSize(),
560  I->second->getAAInfo(),
561  true);
562 }
563 
564 
565 
566 //===----------------------------------------------------------------------===//
567 // AliasSet/AliasSetTracker Printing Support
568 //===----------------------------------------------------------------------===//
569 
570 void AliasSet::print(raw_ostream &OS) const {
571  OS << " AliasSet[" << (const void*)this << ", " << RefCount << "] ";
572  OS << (Alias == SetMustAlias ? "must" : "may") << " alias, ";
573  switch (Access) {
574  case NoAccess: OS << "No access "; break;
575  case RefAccess: OS << "Ref "; break;
576  case ModAccess: OS << "Mod "; break;
577  case ModRefAccess: OS << "Mod/Ref "; break;
578  default: llvm_unreachable("Bad value for Access!");
579  }
580  if (isVolatile()) OS << "[volatile] ";
581  if (Forward)
582  OS << " forwarding to " << (void*)Forward;
583 
584 
585  if (!empty()) {
586  OS << "Pointers: ";
587  for (iterator I = begin(), E = end(); I != E; ++I) {
588  if (I != begin()) OS << ", ";
589  I.getPointer()->printAsOperand(OS << "(");
590  OS << ", " << I.getSize() << ")";
591  }
592  }
593  if (!UnknownInsts.empty()) {
594  OS << "\n " << UnknownInsts.size() << " Unknown instructions: ";
595  for (unsigned i = 0, e = UnknownInsts.size(); i != e; ++i) {
596  if (i) OS << ", ";
597  UnknownInsts[i]->printAsOperand(OS);
598  }
599  }
600  OS << "\n";
601 }
602 
604  OS << "Alias Set Tracker: " << AliasSets.size() << " alias sets for "
605  << PointerMap.size() << " pointer values.\n";
606  for (const_iterator I = begin(), E = end(); I != E; ++I)
607  I->print(OS);
608  OS << "\n";
609 }
610 
611 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
612 void AliasSet::dump() const { print(dbgs()); }
613 void AliasSetTracker::dump() const { print(dbgs()); }
614 #endif
615 
616 //===----------------------------------------------------------------------===//
617 // ASTCallbackVH Class Implementation
618 //===----------------------------------------------------------------------===//
619 
620 void AliasSetTracker::ASTCallbackVH::deleted() {
621  assert(AST && "ASTCallbackVH called with a null AliasSetTracker!");
622  AST->deleteValue(getValPtr());
623  // this now dangles!
624 }
625 
626 void AliasSetTracker::ASTCallbackVH::allUsesReplacedWith(Value *V) {
627  AST->copyValue(getValPtr(), V);
628 }
629 
630 AliasSetTracker::ASTCallbackVH::ASTCallbackVH(Value *V, AliasSetTracker *ast)
631  : CallbackVH(V), AST(ast) {}
632 
633 AliasSetTracker::ASTCallbackVH &
634 AliasSetTracker::ASTCallbackVH::operator=(Value *V) {
635  return *this = ASTCallbackVH(V, AST);
636 }
637 
638 //===----------------------------------------------------------------------===//
639 // AliasSetPrinter Pass
640 //===----------------------------------------------------------------------===//
641 
642 namespace {
643  class AliasSetPrinter : public FunctionPass {
644  AliasSetTracker *Tracker;
645  public:
646  static char ID; // Pass identification, replacement for typeid
647  AliasSetPrinter() : FunctionPass(ID) {
649  }
650 
651  void getAnalysisUsage(AnalysisUsage &AU) const override {
652  AU.setPreservesAll();
654  }
655 
656  bool runOnFunction(Function &F) override {
657  Tracker = new AliasSetTracker(getAnalysis<AliasAnalysis>());
658 
659  for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I)
660  Tracker->add(&*I);
661  Tracker->print(errs());
662  delete Tracker;
663  return false;
664  }
665  };
666 }
667 
668 char AliasSetPrinter::ID = 0;
669 INITIALIZE_PASS_BEGIN(AliasSetPrinter, "print-alias-sets",
670  "Alias Set Printer", false, true)
672 INITIALIZE_PASS_END(AliasSetPrinter, "print-alias-sets",
673  "Alias Set Printer", false, true)
The two locations precisely alias each other.
Definition: AliasAnalysis.h:84
void mergeSetIn(AliasSet &AS, AliasSetTracker &AST)
mergeSetIn - Merge the specified alias set into this alias set...
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
bool isVolatile() const
isVolatile - Return true if this is a store to a volatile memory location.
Definition: Instructions.h:351
Define an iterator for alias sets... this is just a forward iterator.
iterator begin() const
print alias sets
The two locations do not alias at all.
Definition: AliasAnalysis.h:78
F(f)
LoadInst - an instruction for reading from memory.
Definition: Instructions.h:177
bool add(Value *Ptr, uint64_t Size, const AAMDNodes &AAInfo)
add methods - These methods are used to add different types of instructions to the alias sets...
print alias Alias Set Printer
AliasSet & getAliasSetForPointer(Value *P, uint64_t Size, const AAMDNodes &AAInfo, bool *New=nullptr)
getAliasSetForPointer - Return the alias set that the specified pointer lives in. ...
iterator begin()
Instruction iterator methods.
Definition: BasicBlock.h:231
bool isMustAlias() const
AnalysisUsage & addRequired()
inst_iterator inst_begin(Function *F)
Definition: InstIterator.h:127
const_iterator end() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:98
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:75
void initializeAliasSetPrinterPass(PassRegistry &)
void print(raw_ostream &O) const
Implement operator<< on Value.
Definition: AsmWriter.cpp:3209
bool aliasesPointer(const Value *Ptr, uint64_t Size, const AAMDNodes &AAInfo, AliasAnalysis &AA) const
aliasesPointer - Return true if the specified pointer "may" (or must) alias one of the members in the...
const_iterator begin() const
void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
Definition: AsmWriter.cpp:3287
uint64_t getTypeStoreSize(Type *Ty)
getTypeStoreSize - Return the DataLayout store size for the given type, if known, or a conservative v...
StoreInst - an instruction for storing to memory.
Definition: Instructions.h:316
bool mayReadOrWriteMemory() const
mayReadOrWriteMemory - Return true if this instruction may read or write memory.
Definition: Instruction.h:362
bool remove(Value *Ptr, uint64_t Size, const AAMDNodes &AAInfo)
remove methods - These methods are used to remove all entries that might be aliased by the specified ...
bool aliasesUnknownInst(const Instruction *Inst, AliasAnalysis &AA) const
#define P(N)
#define true
Definition: ConvertUTF.c:66
bool erase(const KeyT &Val)
Definition: DenseMap.h:206
iterator end() const
LLVM Basic Block Representation.
Definition: BasicBlock.h:65
bool isVolatile() const
bool empty() const
AliasResult
The possible results of an alias query.
Definition: AliasAnalysis.h:72
Represent the analysis usage information of a pass.
print alias Alias Set false
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:294
Value * getOperand(unsigned i) const
Definition: User.h:118
#define INITIALIZE_AG_DEPENDENCY(depName)
Definition: PassSupport.h:72
VAArgInst - This class represents the va_arg llvm instruction, which returns an argument of the speci...
virtual void deleteValue(Value *V)
Methods that clients should call when they transform the program to allow alias analyses to update th...
void print(raw_ostream &OS) const
bool mayWriteToMemory() const
mayWriteToMemory - Return true if this instruction may modify memory.
Representation for a specific memory location.
INITIALIZE_PASS_BEGIN(AliasSetPrinter,"print-alias-sets","Alias Set Printer", false, true) INITIALIZE_PASS_END(AliasSetPrinter
AtomicOrdering getOrdering() const
Returns the ordering effect of this store.
Definition: Instructions.h:372
bool removeUnknown(Instruction *I)
AliasAnalysis & getAliasAnalysis() const
getAliasAnalysis - Return the underlying alias analysis object used by this tracker.
iterator end()
Definition: BasicBlock.h:233
void copyValue(Value *From, Value *To)
copyValue - This method should be used whenever a preexisting value in the program is copied or clone...
virtual AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
Alias Queries...
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:222
ModRefResult getModRefInfo(const Instruction *I)
getModRefInfo - Return information about whether or not an instruction may read or write memory (with...
bool isVolatile() const
isVolatile - Return true if this is a load from a volatile memory location.
Definition: Instructions.h:232
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition: Metadata.h:548
bool containsUnknown(const Instruction *I) const
Return true if the specified instruction "may" (or must) alias one of the members in any of the sets...
AtomicOrdering getOrdering() const
Returns the ordering effect of this fence.
Definition: Instructions.h:250
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:123
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:576
void setPreservesAll()
Set by analyses that do not transform their input at all.
void print(raw_ostream &OS) const
ilist< AliasSet >::iterator iterator
bool addUnknown(Instruction *I)
unsigned size() const
Definition: DenseMap.h:82
iterator begin()
Definition: DenseMap.h:64
void getAAMetadata(AAMDNodes &N, bool Merge=false) const
getAAMetadata - Fills the AAMDNodes structure with AA metadata from this instruction.
ImmutableCallSite - establish a view to a call site for examination.
Definition: CallSite.h:418
#define I(x, y, z)
Definition: MD5.cpp:54
iterator end()
Definition: DenseMap.h:68
iterator find_as(const LookupKeyT &Val)
Alternate version of find() which allows a different, and possibly less expensive, key type.
Definition: DenseMap.h:143
LLVM Value Representation.
Definition: Value.h:69
void dump() const
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
Value handle with callbacks on RAUW and destruction.
Definition: ValueHandle.h:344
inst_iterator inst_end(Function *F)
Definition: InstIterator.h:128
void deleteValue(Value *PtrVal)
deleteValue method - This method is used to remove a pointer value from the AliasSetTracker entirely...
bool containsPointer(const Value *P, uint64_t Size, const AAMDNodes &AAInfo) const
containsPointer - Return true if the specified location is represented by this alias set...