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