LLVM  16.0.0git
AliasAnalysis.cpp
Go to the documentation of this file.
1 //==- AliasAnalysis.cpp - Generic Alias Analysis Interface 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 generic AliasAnalysis interface which is used as the
10 // common interface used by all clients and implementations of alias analysis.
11 //
12 // This file also implements the default version of the AliasAnalysis interface
13 // that is to be used when no other implementation is specified. This does some
14 // simple tests that detect obvious cases: two different global pointers cannot
15 // alias, a global cannot alias a malloc, two different mallocs cannot alias,
16 // etc.
17 //
18 // This alias analysis implementation really isn't very good for anything, but
19 // it is very fast, and makes a nice clean default implementation. Because it
20 // handles lots of little corner cases, other, more complex, alias analysis
21 // implementations may choose to rely on this pass to resolve these simple and
22 // easy cases.
23 //
24 //===----------------------------------------------------------------------===//
25 
27 #include "llvm/ADT/Statistic.h"
40 #include "llvm/IR/Argument.h"
41 #include "llvm/IR/Attributes.h"
42 #include "llvm/IR/BasicBlock.h"
43 #include "llvm/IR/Instruction.h"
44 #include "llvm/IR/Instructions.h"
45 #include "llvm/IR/Type.h"
46 #include "llvm/IR/Value.h"
47 #include "llvm/InitializePasses.h"
48 #include "llvm/Pass.h"
50 #include "llvm/Support/Casting.h"
52 #include <algorithm>
53 #include <cassert>
54 #include <functional>
55 #include <iterator>
56 
57 #define DEBUG_TYPE "aa"
58 
59 using namespace llvm;
60 
61 STATISTIC(NumNoAlias, "Number of NoAlias results");
62 STATISTIC(NumMayAlias, "Number of MayAlias results");
63 STATISTIC(NumMustAlias, "Number of MustAlias results");
64 
65 namespace llvm {
66 /// Allow disabling BasicAA from the AA results. This is particularly useful
67 /// when testing to isolate a single AA implementation.
68 cl::opt<bool> DisableBasicAA("disable-basic-aa", cl::Hidden, cl::init(false));
69 } // namespace llvm
70 
71 #ifndef NDEBUG
72 /// Print a trace of alias analysis queries and their results.
73 static cl::opt<bool> EnableAATrace("aa-trace", cl::Hidden, cl::init(false));
74 #else
75 static const bool EnableAATrace = false;
76 #endif
77 
79  : TLI(Arg.TLI), AAs(std::move(Arg.AAs)), AADeps(std::move(Arg.AADeps)) {
80  for (auto &AA : AAs)
81  AA->setAAResults(this);
82 }
83 
85 // FIXME; It would be nice to at least clear out the pointers back to this
86 // aggregation here, but we end up with non-nesting lifetimes in the legacy
87 // pass manager that prevent this from working. In the legacy pass manager
88 // we'll end up with dangling references here in some cases.
89 #if 0
90  for (auto &AA : AAs)
91  AA->setAAResults(nullptr);
92 #endif
93 }
94 
97  // AAResults preserves the AAManager by default, due to the stateless nature
98  // of AliasAnalysis. There is no need to check whether it has been preserved
99  // explicitly. Check if any module dependency was invalidated and caused the
100  // AAManager to be invalidated. Invalidate ourselves in that case.
101  auto PAC = PA.getChecker<AAManager>();
102  if (!PAC.preservedWhenStateless())
103  return true;
104 
105  // Check if any of the function dependencies were invalidated, and invalidate
106  // ourselves in that case.
107  for (AnalysisKey *ID : AADeps)
108  if (Inv.invalidate(ID, F, PA))
109  return true;
110 
111  // Everything we depend on is still fine, so are we. Nothing to invalidate.
112  return false;
113 }
114 
115 //===----------------------------------------------------------------------===//
116 // Default chaining methods
117 //===----------------------------------------------------------------------===//
118 
120  const MemoryLocation &LocB) {
121  SimpleAAQueryInfo AAQIP;
122  return alias(LocA, LocB, AAQIP);
123 }
124 
126  const MemoryLocation &LocB, AAQueryInfo &AAQI) {
128 
129  if (EnableAATrace) {
130  for (unsigned I = 0; I < AAQI.Depth; ++I)
131  dbgs() << " ";
132  dbgs() << "Start " << *LocA.Ptr << " @ " << LocA.Size << ", "
133  << *LocB.Ptr << " @ " << LocB.Size << "\n";
134  }
135 
136  AAQI.Depth++;
137  for (const auto &AA : AAs) {
138  Result = AA->alias(LocA, LocB, AAQI);
139  if (Result != AliasResult::MayAlias)
140  break;
141  }
142  AAQI.Depth--;
143 
144  if (EnableAATrace) {
145  for (unsigned I = 0; I < AAQI.Depth; ++I)
146  dbgs() << " ";
147  dbgs() << "End " << *LocA.Ptr << " @ " << LocA.Size << ", "
148  << *LocB.Ptr << " @ " << LocB.Size << " = " << Result << "\n";
149  }
150 
151  if (AAQI.Depth == 0) {
152  if (Result == AliasResult::NoAlias)
153  ++NumNoAlias;
154  else if (Result == AliasResult::MustAlias)
155  ++NumMustAlias;
156  else
157  ++NumMayAlias;
158  }
159  return Result;
160 }
161 
163  bool OrLocal) {
164  SimpleAAQueryInfo AAQIP;
165  return pointsToConstantMemory(Loc, AAQIP, OrLocal);
166 }
167 
169  AAQueryInfo &AAQI, bool OrLocal) {
170  for (const auto &AA : AAs)
171  if (AA->pointsToConstantMemory(Loc, AAQI, OrLocal))
172  return true;
173 
174  return false;
175 }
176 
177 ModRefInfo AAResults::getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
179 
180  for (const auto &AA : AAs) {
181  Result &= AA->getArgModRefInfo(Call, ArgIdx);
182 
183  // Early-exit the moment we reach the bottom of the lattice.
184  if (isNoModRef(Result))
185  return ModRefInfo::NoModRef;
186  }
187 
188  return Result;
189 }
190 
192  SimpleAAQueryInfo AAQIP;
193  return getModRefInfo(I, Call2, AAQIP);
194 }
195 
197  AAQueryInfo &AAQI) {
198  // We may have two calls.
199  if (const auto *Call1 = dyn_cast<CallBase>(I)) {
200  // Check if the two calls modify the same memory.
201  return getModRefInfo(Call1, Call2, AAQI);
202  }
203  // If this is a fence, just return ModRef.
204  if (I->isFenceLike())
205  return ModRefInfo::ModRef;
206  // Otherwise, check if the call modifies or references the
207  // location this memory access defines. The best we can say
208  // is that if the call references what this instruction
209  // defines, it must be clobbered by this location.
210  const MemoryLocation DefLoc = MemoryLocation::get(I);
211  ModRefInfo MR = getModRefInfo(Call2, DefLoc, AAQI);
212  if (isModOrRefSet(MR))
213  return ModRefInfo::ModRef;
214  return ModRefInfo::NoModRef;
215 }
216 
218  const MemoryLocation &Loc) {
219  SimpleAAQueryInfo AAQIP;
220  return getModRefInfo(Call, Loc, AAQIP);
221 }
222 
224  const MemoryLocation &Loc,
225  AAQueryInfo &AAQI) {
227 
228  for (const auto &AA : AAs) {
229  Result &= AA->getModRefInfo(Call, Loc, AAQI);
230 
231  // Early-exit the moment we reach the bottom of the lattice.
232  if (isNoModRef(Result))
233  return ModRefInfo::NoModRef;
234  }
235 
236  // Try to refine the mod-ref info further using other API entry points to the
237  // aggregate set of AA results.
238 
239  // We can completely ignore inaccessible memory here, because MemoryLocations
240  // can only reference accessible memory.
241  auto MRB = getModRefBehavior(Call).getWithoutLoc(
243  if (MRB.doesNotAccessMemory())
244  return ModRefInfo::NoModRef;
245 
246  ModRefInfo ArgMR = MRB.getModRef(FunctionModRefBehavior::ArgMem);
247  ModRefInfo OtherMR =
248  MRB.getWithoutLoc(FunctionModRefBehavior::ArgMem).getModRef();
249  if ((ArgMR | OtherMR) != OtherMR) {
250  // Refine the modref info for argument memory. We only bother to do this
251  // if ArgMR is not a subset of OtherMR, otherwise this won't have an impact
252  // on the final result.
253  ModRefInfo AllArgsMask = ModRefInfo::NoModRef;
254  for (const auto &I : llvm::enumerate(Call->args())) {
255  const Value *Arg = I.value();
256  if (!Arg->getType()->isPointerTy())
257  continue;
258  unsigned ArgIdx = I.index();
259  MemoryLocation ArgLoc = MemoryLocation::getForArgument(Call, ArgIdx, TLI);
260  AliasResult ArgAlias = alias(ArgLoc, Loc, AAQI);
261  if (ArgAlias != AliasResult::NoAlias)
262  AllArgsMask |= getArgModRefInfo(Call, ArgIdx);
263  }
264  ArgMR &= AllArgsMask;
265  }
266 
267  Result &= ArgMR | OtherMR;
268 
269  // If Loc is a constant memory location, the call definitely could not
270  // modify the memory location.
271  if (isModSet(Result) && pointsToConstantMemory(Loc, AAQI, /*OrLocal*/ false))
273 
274  return Result;
275 }
276 
278  const CallBase *Call2) {
279  SimpleAAQueryInfo AAQIP;
280  return getModRefInfo(Call1, Call2, AAQIP);
281 }
282 
284  const CallBase *Call2, AAQueryInfo &AAQI) {
286 
287  for (const auto &AA : AAs) {
288  Result &= AA->getModRefInfo(Call1, Call2, AAQI);
289 
290  // Early-exit the moment we reach the bottom of the lattice.
291  if (isNoModRef(Result))
292  return ModRefInfo::NoModRef;
293  }
294 
295  // Try to refine the mod-ref info further using other API entry points to the
296  // aggregate set of AA results.
297 
298  // If Call1 or Call2 are readnone, they don't interact.
299  auto Call1B = getModRefBehavior(Call1);
300  if (Call1B.doesNotAccessMemory())
301  return ModRefInfo::NoModRef;
302 
303  auto Call2B = getModRefBehavior(Call2);
304  if (Call2B.doesNotAccessMemory())
305  return ModRefInfo::NoModRef;
306 
307  // If they both only read from memory, there is no dependence.
308  if (Call1B.onlyReadsMemory() && Call2B.onlyReadsMemory())
309  return ModRefInfo::NoModRef;
310 
311  // If Call1 only reads memory, the only dependence on Call2 can be
312  // from Call1 reading memory written by Call2.
313  if (Call1B.onlyReadsMemory())
314  Result &= ModRefInfo::Ref;
315  else if (Call1B.onlyWritesMemory())
316  Result &= ModRefInfo::Mod;
317 
318  // If Call2 only access memory through arguments, accumulate the mod/ref
319  // information from Call1's references to the memory referenced by
320  // Call2's arguments.
321  if (Call2B.onlyAccessesArgPointees()) {
322  if (!Call2B.doesAccessArgPointees())
323  return ModRefInfo::NoModRef;
325  for (auto I = Call2->arg_begin(), E = Call2->arg_end(); I != E; ++I) {
326  const Value *Arg = *I;
327  if (!Arg->getType()->isPointerTy())
328  continue;
329  unsigned Call2ArgIdx = std::distance(Call2->arg_begin(), I);
330  auto Call2ArgLoc =
331  MemoryLocation::getForArgument(Call2, Call2ArgIdx, TLI);
332 
333  // ArgModRefC2 indicates what Call2 might do to Call2ArgLoc, and the
334  // dependence of Call1 on that location is the inverse:
335  // - If Call2 modifies location, dependence exists if Call1 reads or
336  // writes.
337  // - If Call2 only reads location, dependence exists if Call1 writes.
338  ModRefInfo ArgModRefC2 = getArgModRefInfo(Call2, Call2ArgIdx);
340  if (isModSet(ArgModRefC2))
341  ArgMask = ModRefInfo::ModRef;
342  else if (isRefSet(ArgModRefC2))
343  ArgMask = ModRefInfo::Mod;
344 
345  // ModRefC1 indicates what Call1 might do to Call2ArgLoc, and we use
346  // above ArgMask to update dependence info.
347  ArgMask &= getModRefInfo(Call1, Call2ArgLoc, AAQI);
348 
349  R = (R | ArgMask) & Result;
350  if (R == Result)
351  break;
352  }
353 
354  return R;
355  }
356 
357  // If Call1 only accesses memory through arguments, check if Call2 references
358  // any of the memory referenced by Call1's arguments. If not, return NoModRef.
359  if (Call1B.onlyAccessesArgPointees()) {
360  if (!Call1B.doesAccessArgPointees())
361  return ModRefInfo::NoModRef;
363  for (auto I = Call1->arg_begin(), E = Call1->arg_end(); I != E; ++I) {
364  const Value *Arg = *I;
365  if (!Arg->getType()->isPointerTy())
366  continue;
367  unsigned Call1ArgIdx = std::distance(Call1->arg_begin(), I);
368  auto Call1ArgLoc =
369  MemoryLocation::getForArgument(Call1, Call1ArgIdx, TLI);
370 
371  // ArgModRefC1 indicates what Call1 might do to Call1ArgLoc; if Call1
372  // might Mod Call1ArgLoc, then we care about either a Mod or a Ref by
373  // Call2. If Call1 might Ref, then we care only about a Mod by Call2.
374  ModRefInfo ArgModRefC1 = getArgModRefInfo(Call1, Call1ArgIdx);
375  ModRefInfo ModRefC2 = getModRefInfo(Call2, Call1ArgLoc, AAQI);
376  if ((isModSet(ArgModRefC1) && isModOrRefSet(ModRefC2)) ||
377  (isRefSet(ArgModRefC1) && isModSet(ModRefC2)))
378  R = (R | ArgModRefC1) & Result;
379 
380  if (R == Result)
381  break;
382  }
383 
384  return R;
385  }
386 
387  return Result;
388 }
389 
392 
393  for (const auto &AA : AAs) {
394  Result &= AA->getModRefBehavior(Call);
395 
396  // Early-exit the moment we reach the bottom of the lattice.
397  if (Result.doesNotAccessMemory())
398  return Result;
399  }
400 
401  return Result;
402 }
403 
406 
407  for (const auto &AA : AAs) {
408  Result &= AA->getModRefBehavior(F);
409 
410  // Early-exit the moment we reach the bottom of the lattice.
411  if (Result.doesNotAccessMemory())
412  return Result;
413  }
414 
415  return Result;
416 }
417 
419  switch (AR) {
421  OS << "NoAlias";
422  break;
424  OS << "MustAlias";
425  break;
427  OS << "MayAlias";
428  break;
430  OS << "PartialAlias";
431  if (AR.hasOffset())
432  OS << " (off " << AR.getOffset() << ")";
433  break;
434  }
435  return OS;
436 }
437 
439  switch (MR) {
441  OS << "NoModRef";
442  break;
443  case ModRefInfo::Ref:
444  OS << "Ref";
445  break;
446  case ModRefInfo::Mod:
447  OS << "Mod";
448  break;
449  case ModRefInfo::ModRef:
450  OS << "ModRef";
451  break;
452  }
453  return OS;
454 }
455 
458  FunctionModRefBehavior::locations()) {
459  switch (Loc) {
461  OS << "ArgMem: ";
462  break;
464  OS << "InaccessibleMem: ";
465  break;
467  OS << "Other: ";
468  break;
469  }
470  OS << FMRB.getModRef(Loc) << ", ";
471  }
472  return OS;
473 }
474 
475 //===----------------------------------------------------------------------===//
476 // Helper method implementation
477 //===----------------------------------------------------------------------===//
478 
480  const MemoryLocation &Loc) {
481  SimpleAAQueryInfo AAQIP;
482  return getModRefInfo(L, Loc, AAQIP);
483 }
485  const MemoryLocation &Loc,
486  AAQueryInfo &AAQI) {
487  // Be conservative in the face of atomic.
489  return ModRefInfo::ModRef;
490 
491  // If the load address doesn't alias the given address, it doesn't read
492  // or write the specified memory.
493  if (Loc.Ptr) {
494  AliasResult AR = alias(MemoryLocation::get(L), Loc, AAQI);
495  if (AR == AliasResult::NoAlias)
496  return ModRefInfo::NoModRef;
497  }
498  // Otherwise, a load just reads.
499  return ModRefInfo::Ref;
500 }
501 
503  const MemoryLocation &Loc) {
504  SimpleAAQueryInfo AAQIP;
505  return getModRefInfo(S, Loc, AAQIP);
506 }
508  const MemoryLocation &Loc,
509  AAQueryInfo &AAQI) {
510  // Be conservative in the face of atomic.
511  if (isStrongerThan(S->getOrdering(), AtomicOrdering::Unordered))
512  return ModRefInfo::ModRef;
513 
514  if (Loc.Ptr) {
515  AliasResult AR = alias(MemoryLocation::get(S), Loc, AAQI);
516  // If the store address cannot alias the pointer in question, then the
517  // specified memory cannot be modified by the store.
518  if (AR == AliasResult::NoAlias)
519  return ModRefInfo::NoModRef;
520 
521  // If the pointer is a pointer to constant memory, then it could not have
522  // been modified by this store.
523  if (pointsToConstantMemory(Loc, AAQI))
524  return ModRefInfo::NoModRef;
525  }
526 
527  // Otherwise, a store just writes.
528  return ModRefInfo::Mod;
529 }
530 
532  SimpleAAQueryInfo AAQIP;
533  return getModRefInfo(S, Loc, AAQIP);
534 }
535 
537  const MemoryLocation &Loc,
538  AAQueryInfo &AAQI) {
539  // If we know that the location is a constant memory location, the fence
540  // cannot modify this location.
541  if (Loc.Ptr && pointsToConstantMemory(Loc, AAQI))
542  return ModRefInfo::Ref;
543  return ModRefInfo::ModRef;
544 }
545 
547  const MemoryLocation &Loc) {
548  SimpleAAQueryInfo AAQIP;
549  return getModRefInfo(V, Loc, AAQIP);
550 }
551 
553  const MemoryLocation &Loc,
554  AAQueryInfo &AAQI) {
555  if (Loc.Ptr) {
556  AliasResult AR = alias(MemoryLocation::get(V), Loc, AAQI);
557  // If the va_arg address cannot alias the pointer in question, then the
558  // specified memory cannot be accessed by the va_arg.
559  if (AR == AliasResult::NoAlias)
560  return ModRefInfo::NoModRef;
561 
562  // If the pointer is a pointer to constant memory, then it could not have
563  // been modified by this va_arg.
564  if (pointsToConstantMemory(Loc, AAQI))
565  return ModRefInfo::NoModRef;
566  }
567 
568  // Otherwise, a va_arg reads and writes.
569  return ModRefInfo::ModRef;
570 }
571 
573  const MemoryLocation &Loc) {
574  SimpleAAQueryInfo AAQIP;
575  return getModRefInfo(CatchPad, Loc, AAQIP);
576 }
577 
579  const MemoryLocation &Loc,
580  AAQueryInfo &AAQI) {
581  if (Loc.Ptr) {
582  // If the pointer is a pointer to constant memory,
583  // then it could not have been modified by this catchpad.
584  if (pointsToConstantMemory(Loc, AAQI))
585  return ModRefInfo::NoModRef;
586  }
587 
588  // Otherwise, a catchpad reads and writes.
589  return ModRefInfo::ModRef;
590 }
591 
593  const MemoryLocation &Loc) {
594  SimpleAAQueryInfo AAQIP;
595  return getModRefInfo(CatchRet, Loc, AAQIP);
596 }
597 
599  const MemoryLocation &Loc,
600  AAQueryInfo &AAQI) {
601  if (Loc.Ptr) {
602  // If the pointer is a pointer to constant memory,
603  // then it could not have been modified by this catchpad.
604  if (pointsToConstantMemory(Loc, AAQI))
605  return ModRefInfo::NoModRef;
606  }
607 
608  // Otherwise, a catchret reads and writes.
609  return ModRefInfo::ModRef;
610 }
611 
613  const MemoryLocation &Loc) {
614  SimpleAAQueryInfo AAQIP;
615  return getModRefInfo(CX, Loc, AAQIP);
616 }
617 
619  const MemoryLocation &Loc,
620  AAQueryInfo &AAQI) {
621  // Acquire/Release cmpxchg has properties that matter for arbitrary addresses.
623  return ModRefInfo::ModRef;
624 
625  if (Loc.Ptr) {
626  AliasResult AR = alias(MemoryLocation::get(CX), Loc, AAQI);
627  // If the cmpxchg address does not alias the location, it does not access
628  // it.
629  if (AR == AliasResult::NoAlias)
630  return ModRefInfo::NoModRef;
631  }
632 
633  return ModRefInfo::ModRef;
634 }
635 
637  const MemoryLocation &Loc) {
638  SimpleAAQueryInfo AAQIP;
639  return getModRefInfo(RMW, Loc, AAQIP);
640 }
641 
643  const MemoryLocation &Loc,
644  AAQueryInfo &AAQI) {
645  // Acquire/Release atomicrmw has properties that matter for arbitrary addresses.
647  return ModRefInfo::ModRef;
648 
649  if (Loc.Ptr) {
650  AliasResult AR = alias(MemoryLocation::get(RMW), Loc, AAQI);
651  // If the atomicrmw address does not alias the location, it does not access
652  // it.
653  if (AR == AliasResult::NoAlias)
654  return ModRefInfo::NoModRef;
655  }
656 
657  return ModRefInfo::ModRef;
658 }
659 
661  const Optional<MemoryLocation> &OptLoc,
662  AAQueryInfo &AAQIP) {
663  if (OptLoc == None) {
664  if (const auto *Call = dyn_cast<CallBase>(I))
665  return getModRefBehavior(Call).getModRef();
666  }
667 
668  const MemoryLocation &Loc = OptLoc.value_or(MemoryLocation());
669 
670  switch (I->getOpcode()) {
671  case Instruction::VAArg:
672  return getModRefInfo((const VAArgInst *)I, Loc, AAQIP);
673  case Instruction::Load:
674  return getModRefInfo((const LoadInst *)I, Loc, AAQIP);
675  case Instruction::Store:
676  return getModRefInfo((const StoreInst *)I, Loc, AAQIP);
677  case Instruction::Fence:
678  return getModRefInfo((const FenceInst *)I, Loc, AAQIP);
679  case Instruction::AtomicCmpXchg:
680  return getModRefInfo((const AtomicCmpXchgInst *)I, Loc, AAQIP);
681  case Instruction::AtomicRMW:
682  return getModRefInfo((const AtomicRMWInst *)I, Loc, AAQIP);
683  case Instruction::Call:
684  case Instruction::CallBr:
685  case Instruction::Invoke:
686  return getModRefInfo((const CallBase *)I, Loc, AAQIP);
687  case Instruction::CatchPad:
688  return getModRefInfo((const CatchPadInst *)I, Loc, AAQIP);
689  case Instruction::CatchRet:
690  return getModRefInfo((const CatchReturnInst *)I, Loc, AAQIP);
691  default:
692  assert(!I->mayReadOrWriteMemory() &&
693  "Unhandled memory access instruction!");
694  return ModRefInfo::NoModRef;
695  }
696 }
697 
698 /// Return information about whether a particular call site modifies
699 /// or reads the specified memory location \p MemLoc before instruction \p I
700 /// in a BasicBlock.
701 /// FIXME: this is really just shoring-up a deficiency in alias analysis.
702 /// BasicAA isn't willing to spend linear time determining whether an alloca
703 /// was captured before or after this particular call, while we are. However,
704 /// with a smarter AA in place, this test is just wasting compile time.
706  const MemoryLocation &MemLoc,
707  DominatorTree *DT,
708  AAQueryInfo &AAQI) {
709  if (!DT)
710  return ModRefInfo::ModRef;
711 
712  const Value *Object = getUnderlyingObject(MemLoc.Ptr);
713  if (!isIdentifiedFunctionLocal(Object))
714  return ModRefInfo::ModRef;
715 
716  const auto *Call = dyn_cast<CallBase>(I);
717  if (!Call || Call == Object)
718  return ModRefInfo::ModRef;
719 
720  if (PointerMayBeCapturedBefore(Object, /* ReturnCaptures */ true,
721  /* StoreCaptures */ true, I, DT,
722  /* include Object */ true))
723  return ModRefInfo::ModRef;
724 
725  unsigned ArgNo = 0;
727  // Set flag only if no May found and all operands processed.
728  for (auto CI = Call->data_operands_begin(), CE = Call->data_operands_end();
729  CI != CE; ++CI, ++ArgNo) {
730  // Only look at the no-capture or byval pointer arguments. If this
731  // pointer were passed to arguments that were neither of these, then it
732  // couldn't be no-capture.
733  if (!(*CI)->getType()->isPointerTy() ||
734  (!Call->doesNotCapture(ArgNo) && ArgNo < Call->arg_size() &&
735  !Call->isByValArgument(ArgNo)))
736  continue;
737 
738  AliasResult AR = alias(
740  MemoryLocation::getBeforeOrAfter(Object), AAQI);
741  // If this is a no-capture pointer argument, see if we can tell that it
742  // is impossible to alias the pointer we're checking. If not, we have to
743  // assume that the call could touch the pointer, even though it doesn't
744  // escape.
745  if (AR == AliasResult::NoAlias)
746  continue;
747  if (Call->doesNotAccessMemory(ArgNo))
748  continue;
749  if (Call->onlyReadsMemory(ArgNo)) {
750  R = ModRefInfo::Ref;
751  continue;
752  }
753  return ModRefInfo::ModRef;
754  }
755  return R;
756 }
757 
758 /// canBasicBlockModify - Return true if it is possible for execution of the
759 /// specified basic block to modify the location Loc.
760 ///
762  const MemoryLocation &Loc) {
763  return canInstructionRangeModRef(BB.front(), BB.back(), Loc, ModRefInfo::Mod);
764 }
765 
766 /// canInstructionRangeModRef - Return true if it is possible for the
767 /// execution of the specified instructions to mod\ref (according to the
768 /// mode) the location Loc. The instructions to consider are all
769 /// of the instructions in the range of [I1,I2] INCLUSIVE.
770 /// I1 and I2 must be in the same basic block.
772  const Instruction &I2,
773  const MemoryLocation &Loc,
774  const ModRefInfo Mode) {
775  assert(I1.getParent() == I2.getParent() &&
776  "Instructions not in same basic block!");
777  BasicBlock::const_iterator I = I1.getIterator();
779  ++E; // Convert from inclusive to exclusive range.
780 
781  for (; I != E; ++I) // Check every instruction in range
782  if (isModOrRefSet(getModRefInfo(&*I, Loc) & Mode))
783  return true;
784  return false;
785 }
786 
787 // Provide a definition for the root virtual destructor.
788 AAResults::Concept::~Concept() = default;
789 
790 // Provide a definition for the static object used to identify passes.
791 AnalysisKey AAManager::Key;
792 
795 }
796 
798  : ImmutablePass(ID), CB(std::move(CB)) {
800 }
801 
803 
804 INITIALIZE_PASS(ExternalAAWrapperPass, "external-aa", "External Alias Analysis",
805  false, true)
806 
809  return new ExternalAAWrapperPass(std::move(Callback));
810 }
811 
814 }
815 
816 char AAResultsWrapperPass::ID = 0;
817 
819  "Function Alias Analysis Results", false, true)
825 INITIALIZE_PASS_DEPENDENCY(ObjCARCAAWrapperPass)
830  "Function Alias Analysis Results", false, true)
831 
833  return new AAResultsWrapperPass();
834 }
835 
836 /// Run the wrapper pass to rebuild an aggregation over known AA passes.
837 ///
838 /// This is the legacy pass manager's interface to the new-style AA results
839 /// aggregation object. Because this is somewhat shoe-horned into the legacy
840 /// pass manager, we hard code all the specific alias analyses available into
841 /// it. While the particular set enabled is configured via commandline flags,
842 /// adding a new alias analysis to LLVM will require adding support for it to
843 /// this list.
845  // NB! This *must* be reset before adding new AA results to the new
846  // AAResults object because in the legacy pass manager, each instance
847  // of these will refer to the *same* immutable analyses, registering and
848  // unregistering themselves with them. We need to carefully tear down the
849  // previous object first, in this case replacing it with an empty one, before
850  // registering new results.
851  AAR.reset(
852  new AAResults(getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F)));
853 
854  // BasicAA is always available for function analyses. Also, we add it first
855  // so that it can trump TBAA results when it proves MustAlias.
856  // FIXME: TBAA should have an explicit mode to support this and then we
857  // should reconsider the ordering here.
858  if (!DisableBasicAA)
859  AAR->addAAResult(getAnalysis<BasicAAWrapperPass>().getResult());
860 
861  // Populate the results with the currently available AAs.
862  if (auto *WrapperPass = getAnalysisIfAvailable<ScopedNoAliasAAWrapperPass>())
863  AAR->addAAResult(WrapperPass->getResult());
864  if (auto *WrapperPass = getAnalysisIfAvailable<TypeBasedAAWrapperPass>())
865  AAR->addAAResult(WrapperPass->getResult());
866  if (auto *WrapperPass =
867  getAnalysisIfAvailable<objcarc::ObjCARCAAWrapperPass>())
868  AAR->addAAResult(WrapperPass->getResult());
869  if (auto *WrapperPass = getAnalysisIfAvailable<GlobalsAAWrapperPass>())
870  AAR->addAAResult(WrapperPass->getResult());
871  if (auto *WrapperPass = getAnalysisIfAvailable<SCEVAAWrapperPass>())
872  AAR->addAAResult(WrapperPass->getResult());
873  if (auto *WrapperPass = getAnalysisIfAvailable<CFLAndersAAWrapperPass>())
874  AAR->addAAResult(WrapperPass->getResult());
875  if (auto *WrapperPass = getAnalysisIfAvailable<CFLSteensAAWrapperPass>())
876  AAR->addAAResult(WrapperPass->getResult());
877 
878  // If available, run an external AA providing callback over the results as
879  // well.
880  if (auto *WrapperPass = getAnalysisIfAvailable<ExternalAAWrapperPass>())
881  if (WrapperPass->CB)
882  WrapperPass->CB(*this, F, *AAR);
883 
884  // Analyses don't mutate the IR, so return false.
885  return false;
886 }
887 
889  AU.setPreservesAll();
892 
893  // We also need to mark all the alias analysis passes we will potentially
894  // probe in runOnFunction as used here to ensure the legacy pass manager
895  // preserves them. This hard coding of lists of alias analyses is specific to
896  // the legacy pass manager.
905 }
906 
909  for (auto &Getter : ResultGetters)
910  (*Getter)(F, AM, R);
911  return R;
912 }
913 
915  BasicAAResult &BAR) {
916  AAResults AAR(P.getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F));
917 
918  // Add in our explicitly constructed BasicAA results.
919  if (!DisableBasicAA)
920  AAR.addAAResult(BAR);
921 
922  // Populate the results with the other currently available AAs.
923  if (auto *WrapperPass =
924  P.getAnalysisIfAvailable<ScopedNoAliasAAWrapperPass>())
925  AAR.addAAResult(WrapperPass->getResult());
926  if (auto *WrapperPass = P.getAnalysisIfAvailable<TypeBasedAAWrapperPass>())
927  AAR.addAAResult(WrapperPass->getResult());
928  if (auto *WrapperPass =
929  P.getAnalysisIfAvailable<objcarc::ObjCARCAAWrapperPass>())
930  AAR.addAAResult(WrapperPass->getResult());
931  if (auto *WrapperPass = P.getAnalysisIfAvailable<GlobalsAAWrapperPass>())
932  AAR.addAAResult(WrapperPass->getResult());
933  if (auto *WrapperPass = P.getAnalysisIfAvailable<CFLAndersAAWrapperPass>())
934  AAR.addAAResult(WrapperPass->getResult());
935  if (auto *WrapperPass = P.getAnalysisIfAvailable<CFLSteensAAWrapperPass>())
936  AAR.addAAResult(WrapperPass->getResult());
937  if (auto *WrapperPass = P.getAnalysisIfAvailable<ExternalAAWrapperPass>())
938  if (WrapperPass->CB)
939  WrapperPass->CB(P, F, AAR);
940 
941  return AAR;
942 }
943 
944 bool llvm::isNoAliasCall(const Value *V) {
945  if (const auto *Call = dyn_cast<CallBase>(V))
946  return Call->hasRetAttr(Attribute::NoAlias);
947  return false;
948 }
949 
950 static bool isNoAliasOrByValArgument(const Value *V) {
951  if (const Argument *A = dyn_cast<Argument>(V))
952  return A->hasNoAliasAttr() || A->hasByValAttr();
953  return false;
954 }
955 
957  if (isa<AllocaInst>(V))
958  return true;
959  if (isa<GlobalValue>(V) && !isa<GlobalAlias>(V))
960  return true;
961  if (isNoAliasCall(V))
962  return true;
964  return true;
965  return false;
966 }
967 
969  return isa<AllocaInst>(V) || isNoAliasCall(V) || isNoAliasOrByValArgument(V);
970 }
971 
972 bool llvm::isEscapeSource(const Value *V) {
973  if (auto *CB = dyn_cast<CallBase>(V))
975  true);
976 
977  // The load case works because isNonEscapingLocalObject considers all
978  // stores to be escapes (it passes true for the StoreCaptures argument
979  // to PointerMayBeCaptured).
980  if (isa<LoadInst>(V))
981  return true;
982 
983  // The inttoptr case works because isNonEscapingLocalObject considers all
984  // means of converting or equating a pointer to an int (ptrtoint, ptr store
985  // which could be followed by an integer load, ptr<->int compare) as
986  // escaping, and objects located at well-known addresses via platform-specific
987  // means cannot be considered non-escaping local objects.
988  if (isa<IntToPtrInst>(V))
989  return true;
990 
991  return false;
992 }
993 
995  bool &RequiresNoCaptureBeforeUnwind) {
996  RequiresNoCaptureBeforeUnwind = false;
997 
998  // Alloca goes out of scope on unwind.
999  if (isa<AllocaInst>(Object))
1000  return true;
1001 
1002  // Byval goes out of scope on unwind.
1003  if (auto *A = dyn_cast<Argument>(Object))
1004  return A->hasByValAttr();
1005 
1006  // A noalias return is not accessible from any other code. If the pointer
1007  // does not escape prior to the unwind, then the caller cannot access the
1008  // memory either.
1009  if (isNoAliasCall(Object)) {
1010  RequiresNoCaptureBeforeUnwind = true;
1011  return true;
1012  }
1013 
1014  return false;
1015 }
1016 
1018  // This function needs to be in sync with llvm::createLegacyPMAAResults -- if
1019  // more alias analyses are added to llvm::createLegacyPMAAResults, they need
1020  // to be added here also.
1029 }
llvm::AAResults::addAAResult
void addAAResult(AAResultT &AAResult)
Register a specific AA result.
Definition: AliasAnalysis.h:527
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
TypeBasedAliasAnalysis.h
llvm::ModRefInfo::NoModRef
@ NoModRef
The access neither references nor modifies the value stored in memory.
llvm::Argument
This class represents an incoming formal argument to a Function.
Definition: Argument.h:28
llvm::AAManager
A manager for alias analyses.
Definition: AliasAnalysis.h:1260
llvm::AliasResult::MayAlias
@ MayAlias
The two locations may or may not alias.
Definition: AliasAnalysis.h:103
llvm::AliasResult::PartialAlias
@ PartialAlias
The two locations alias, but only due to a partial overlap.
Definition: AliasAnalysis.h:105
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:35
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::ExternalAAWrapperPass::ExternalAAWrapperPass
ExternalAAWrapperPass()
Definition: AliasAnalysis.cpp:793
llvm::VAArgInst
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
Definition: Instructions.h:1832
llvm::ImmutablePass
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:279
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
aa
aa
Definition: AliasAnalysis.cpp:829
llvm::Function
Definition: Function.h:60
llvm::AnalysisManager::Invalidator::invalidate
bool invalidate(IRUnitT &IR, const PreservedAnalyses &PA)
Trigger the invalidation of some other analysis pass if not already handled and return whether it was...
Definition: PassManager.h:679
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
llvm::AAResults::invalidate
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)
Handle invalidation events in the new pass manager.
Definition: AliasAnalysis.cpp:95
llvm::createAAResultsWrapperPass
FunctionPass * createAAResultsWrapperPass()
Definition: AliasAnalysis.cpp:832
llvm::FunctionModRefBehavior::InaccessibleMem
@ InaccessibleMem
Memory that is inaccessible via LLVM IR.
Definition: AliasAnalysis.h:215
Statistic.h
CaptureTracking.h
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:2068
llvm::AtomicCmpXchgInst::getSuccessOrdering
AtomicOrdering getSuccessOrdering() const
Returns the success ordering constraint of this cmpxchg instruction.
Definition: Instructions.h:593
llvm::AAResults::Concept::~Concept
virtual ~Concept()=0
llvm::isModSet
bool isModSet(const ModRefInfo MRI)
Definition: AliasAnalysis.h:168
ValueTracking.h
llvm::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:166
GlobalsModRef.h
isNoAliasOrByValArgument
static bool isNoAliasOrByValArgument(const Value *V)
Definition: AliasAnalysis.cpp:950
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:140
llvm::SimpleAAQueryInfo
AAQueryInfo that uses SimpleCaptureInfo.
Definition: AliasAnalysis.h:509
true
basic Basic Alias true
Definition: BasicAliasAnalysis.cpp:1835
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: AliasAnalysis.h:162
llvm::Optional
Definition: APInt.h:33
llvm::FenceInst
An instruction for ordering other memory operations.
Definition: Instructions.h:433
llvm::AliasResult
The possible results of an alias query.
Definition: AliasAnalysis.h:82
llvm::FunctionModRefBehavior::Other
@ Other
Any other memory.
Definition: AliasAnalysis.h:217
Results
Function Alias Analysis Results
Definition: AliasAnalysis.cpp:830
llvm::CallBase::arg_begin
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
Definition: InstrTypes.h:1316
BasicAliasAnalysis.h
llvm::getAAResultsAnalysisUsage
void getAAResultsAnalysisUsage(AnalysisUsage &AU)
A helper for the legacy pass manager to populate AU to add uses to make sure the analyses required by...
Definition: AliasAnalysis.cpp:1017
llvm::FunctionModRefBehavior::getWithoutLoc
FunctionModRefBehavior getWithoutLoc(Location Loc) const
Get new FunctionModRefBehavior with NoModRef on the given Loc.
Definition: AliasAnalysis.h:308
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::RISCVFenceField::R
@ R
Definition: RISCVBaseInfo.h:265
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
AliasAnalysis.h
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
llvm::isIdentifiedFunctionLocal
bool isIdentifiedFunctionLocal(const Value *V)
Return true if V is umabigously identified at the function-level.
Definition: AliasAnalysis.cpp:968
llvm::AAResults::AAResults
AAResults(const TargetLibraryInfo &TLI)
Definition: AliasAnalysis.h:522
llvm::objcarc::ObjCARCAAWrapperPass
Legacy wrapper pass to provide the ObjCARCAAResult object.
Definition: ObjCARCAliasAnalysis.h:80
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:187
llvm::FunctionModRefBehavior::unknown
static FunctionModRefBehavior unknown()
Create FunctionModRefBehavior that can read and write any memory.
Definition: AliasAnalysis.h:257
llvm::AAQueryInfo
This class stores info we want to provide to or retain within an alias query.
Definition: AliasAnalysis.h:469
Instruction.h
CommandLine.h
llvm::isNoAliasCall
bool isNoAliasCall(const Value *V)
Return true if this pointer is returned by a noalias function.
Definition: AliasAnalysis.cpp:944
llvm::AAResultsWrapperPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition: AliasAnalysis.cpp:888
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:24
llvm::ModRefInfo::Ref
@ Ref
The access may reference the value stored in memory.
llvm::AAResults
Definition: AliasAnalysis.h:518
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::AliasResult::hasOffset
constexpr bool hasOffset() const
Definition: AliasAnalysis.h:118
llvm::ms_demangle::QualifierMangleMode::Result
@ Result
TargetLibraryInfo.h
false
Definition: StackSlotColoring.cpp:141
INITIALIZE_PASS_BEGIN
INITIALIZE_PASS_BEGIN(AAResultsWrapperPass, "aa", "Function Alias Analysis Results", false, true) INITIALIZE_PASS_END(AAResultsWrapperPass
INITIALIZE_PASS
INITIALIZE_PASS(ExternalAAWrapperPass, "external-aa", "External Alias Analysis", false, true) ImmutablePass *llvm
Definition: AliasAnalysis.cpp:804
llvm::Instruction
Definition: Instruction.h:42
llvm::ExternalAAWrapperPass::CallbackT
std::function< void(Pass &, Function &, AAResults &)> CallbackT
Definition: AliasAnalysis.h:1327
llvm::STATISTIC
STATISTIC(NumFunctions, "Total number of functions")
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
llvm::AAManager::run
Result run(Function &F, FunctionAnalysisManager &AM)
Definition: AliasAnalysis.cpp:907
llvm::operator<<
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:230
llvm::getUnderlyingObject
const Value * getUnderlyingObject(const Value *V, unsigned MaxLookup=6)
This method strips off any GEP address adjustments and pointer casts from the specified value,...
Definition: ValueTracking.cpp:4501
llvm::AnalysisManager::Invalidator
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:661
CFLAndersAliasAnalysis.h
llvm::MCID::Call
@ Call
Definition: MCInstrDesc.h:155
ScopedNoAliasAA.h
llvm::None
const NoneType None
Definition: None.h:24
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
Type.h
llvm::createLegacyPMAAResults
AAResults createLegacyPMAAResults(Pass &P, Function &F, BasicAAResult &BAR)
A helper for the legacy pass manager to create a AAResults object populated to the best of our abilit...
Definition: AliasAnalysis.cpp:914
llvm::AliasResult::getOffset
constexpr int32_t getOffset() const
Definition: AliasAnalysis.h:119
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:58
llvm::OutputFileType::Object
@ Object
llvm::TypeBasedAAWrapperPass
Legacy wrapper pass to provide the TypeBasedAAResult object.
Definition: TypeBasedAliasAnalysis.h:71
BasicBlock.h
llvm::cl::opt< bool >
llvm::ExternalAAWrapperPass::ID
static char ID
Definition: AliasAnalysis.h:1331
llvm::StoreInst
An instruction for storing to memory.
Definition: Instructions.h:298
llvm::SCEVAAWrapperPass
Legacy wrapper pass to provide the SCEVAAResult object.
Definition: ScalarEvolutionAliasAnalysis.h:56
llvm::TargetLibraryInfoWrapperPass
Definition: TargetLibraryInfo.h:474
llvm::CatchReturnInst
Definition: Instructions.h:4582
INITIALIZE_PASS_DEPENDENCY
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
llvm::BasicAAWrapperPass
Legacy wrapper pass to provide the BasicAAResult object.
Definition: BasicAliasAnalysis.h:173
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
MemoryLocation.h
llvm::AtomicRMWInst::getOrdering
AtomicOrdering getOrdering() const
Returns the ordering constraint of this rmw instruction.
Definition: Instructions.h:843
llvm::CFLAndersAAWrapperPass
Legacy wrapper pass to provide the CFLAndersAAResult object.
Definition: CFLAndersAliasAnalysis.h:106
llvm::AnalysisKey
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:69
llvm::AAResults::canInstructionRangeModRef
bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2, const MemoryLocation &Loc, const ModRefInfo Mode)
Check if it is possible for the execution of the specified instructions to mod(according to the mode)...
Definition: AliasAnalysis.cpp:771
llvm::AtomicOrdering::Unordered
@ Unordered
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::FunctionModRefBehavior::getModRef
ModRefInfo getModRef(Location Loc) const
Get ModRefInfo for the given Location.
Definition: AliasAnalysis.h:296
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:440
llvm::createExternalAAWrapperPass
ImmutablePass * createExternalAAWrapperPass(std::function< void(Pass &, Function &, AAResults &)> Callback)
A wrapper pass around a callback which can be used to populate the AAResults in the AAResultsWrapperP...
llvm::SPII::Store
@ Store
Definition: SparcInstrInfo.h:33
llvm::CFLSteensAAWrapperPass
Legacy wrapper pass to provide the CFLSteensAAResult object.
Definition: CFLSteensAliasAnalysis.h:121
llvm::ModRefInfo
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
Definition: AliasAnalysis.h:147
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1666
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:158
Mode
SI Whole Quad Mode
Definition: SIWholeQuadMode.cpp:262
ObjCARCAliasAnalysis.h
llvm::isEscapeSource
bool isEscapeSource(const Value *V)
Returns true if the pointer is one which would have been considered an escape by isNonEscapingLocalOb...
Definition: AliasAnalysis.cpp:972
llvm::CallBase::arg_end
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
Definition: InstrTypes.h:1322
llvm::AAResultsWrapperPass::ID
static char ID
Definition: AliasAnalysis.h:1312
llvm::initializeAAResultsWrapperPassPass
void initializeAAResultsWrapperPassPass(PassRegistry &)
llvm::isNotVisibleOnUnwind
bool isNotVisibleOnUnwind(const Value *Object, bool &RequiresNoCaptureBeforeUnwind)
Return true if Object memory is not visible after an unwind, in the sense that program semantics cann...
Definition: AliasAnalysis.cpp:994
llvm::AAResults::~AAResults
~AAResults()
Definition: AliasAnalysis.cpp:84
llvm::AliasResult::NoAlias
@ NoAlias
The two locations do not alias at all.
Definition: AliasAnalysis.h:100
llvm::ModRefInfo::Mod
@ Mod
The access may modify the value stored in memory.
llvm::ilist_node_impl::getIterator
self_iterator getIterator()
Definition: ilist_node.h:82
llvm::isRefSet
bool isRefSet(const ModRefInfo MRI)
Definition: AliasAnalysis.h:171
llvm::AliasResult::MustAlias
@ MustAlias
The two locations precisely alias each other.
Definition: AliasAnalysis.h:107
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::TargetLibraryInfoWrapperPass::getTLI
TargetLibraryInfo & getTLI(const Function &F)
Definition: TargetLibraryInfo.h:486
llvm::LoadInst::getOrdering
AtomicOrdering getOrdering() const
Returns the ordering constraint of this load instruction.
Definition: Instructions.h:226
llvm::BasicAAResult
This is the AA result object for the basic, local, and stateless alias analysis.
Definition: BasicAliasAnalysis.h:44
llvm::LoadInst
An instruction for reading from memory.
Definition: Instructions.h:174
llvm::AAResults::getModRefBehavior
FunctionModRefBehavior getModRefBehavior(const CallBase *Call)
Return the behavior of the given call site.
Definition: AliasAnalysis.cpp:390
llvm::AtomicRMWInst
an instruction that atomically reads a memory location, combines it with another value,...
Definition: Instructions.h:715
llvm::FunctionModRefBehavior
Summary of how a function affects memory in the program.
Definition: AliasAnalysis.h:208
Argument.h
Attributes.h
std
Definition: BitVector.h:851
llvm::isIdentifiedObject
bool isIdentifiedObject(const Value *V)
Return true if this pointer refers to a distinct and identifiable object.
Definition: AliasAnalysis.cpp:956
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition: PassAnalysisSupport.h:130
llvm::AAResultsWrapperPass::runOnFunction
bool runOnFunction(Function &F) override
Run the wrapper pass to rebuild an aggregation over known AA passes.
Definition: AliasAnalysis.cpp:844
Casting.h
llvm::FunctionModRefBehavior::Location
Location
The locations at which a function might access memory.
Definition: AliasAnalysis.h:211
llvm::AAResults::alias
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
The main low level interface to the alias analysis implementation.
Definition: AliasAnalysis.cpp:119
EnableAATrace
static cl::opt< bool > EnableAATrace("aa-trace", cl::Hidden, cl::init(false))
Print a trace of alias analysis queries and their results.
ScalarEvolutionAliasAnalysis.h
llvm::AAResults::pointsToConstantMemory
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal=false)
Checks whether the given location points to constant memory, or if OrLocal is true whether it points ...
Definition: AliasAnalysis.cpp:162
llvm::ScopedNoAliasAAWrapperPass
Legacy wrapper pass to provide the ScopedNoAliasAAResult object.
Definition: ScopedNoAliasAA.h:65
llvm::isStrongerThan
bool isStrongerThan(AtomicOrdering AO, AtomicOrdering Other)
Returns true if ao is stronger than other as defined by the AtomicOrdering lattice,...
Definition: AtomicOrdering.h:90
AA
llvm::CatchPadInst
Definition: Instructions.h:4531
llvm::AAResultsWrapperPass::AAResultsWrapperPass
AAResultsWrapperPass()
Definition: AliasAnalysis.cpp:812
llvm::SPII::Load
@ Load
Definition: SparcInstrInfo.h:32
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:177
llvm::Pass
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:91
Instructions.h
llvm::DisableBasicAA
cl::opt< bool > DisableBasicAA("disable-basic-aa", cl::Hidden, cl::init(false))
Allow disabling BasicAA from the AA results.
llvm::AAResultsWrapperPass
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
Definition: AliasAnalysis.h:1308
llvm::Instruction::getParent
const BasicBlock * getParent() const
Definition: Instruction.h:91
llvm::ExternalAAWrapperPass
A wrapper pass for external alias analyses.
Definition: AliasAnalysis.h:1326
llvm::GlobalsAAWrapperPass
Legacy wrapper pass to provide the GlobalsAAResult object.
Definition: GlobalsModRef.h:144
llvm::isStrongerThanMonotonic
bool isStrongerThanMonotonic(AtomicOrdering AO)
Definition: AtomicOrdering.h:124
llvm::AAResults::canBasicBlockModify
bool canBasicBlockModify(const BasicBlock &BB, const MemoryLocation &Loc)
Check if it is possible for execution of the specified basic block to modify the location Loc.
Definition: AliasAnalysis.cpp:761
llvm::AAResults::callCapturesBefore
ModRefInfo callCapturesBefore(const Instruction *I, const MemoryLocation &MemLoc, DominatorTree *DT)
Return information about whether a particular call site modifies or reads the specified memory locati...
Definition: AliasAnalysis.h:809
llvm::isNoModRef
bool isNoModRef(const ModRefInfo MRI)
Definition: AliasAnalysis.h:159
llvm::MemoryLocation::getBeforeOrAfter
static MemoryLocation getBeforeOrAfter(const Value *Ptr, const AAMDNodes &AATags=AAMDNodes())
Return a location that may access any location before or after Ptr, while remaining within the underl...
Definition: MemoryLocation.h:278
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1174
llvm::AnalysisUsage::addRequiredTransitive
AnalysisUsage & addRequiredTransitive()
Definition: PassAnalysisSupport.h:81
llvm::PreservedAnalyses::getChecker
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
Definition: PassManager.h:310
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
llvm::AnalysisUsage::addUsedIfAvailable
AnalysisUsage & addUsedIfAvailable()
Add the specified Pass class to the set of analyses used by this pass.
Definition: PassAnalysisSupport.h:117
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:308
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::AnalysisUsage::addRequired
AnalysisUsage & addRequired()
Definition: PassAnalysisSupport.h:75
llvm::initializeExternalAAWrapperPassPass
void initializeExternalAAWrapperPassPass(PassRegistry &)
Value.h
llvm::Optional::value_or
constexpr T value_or(U &&alt) const &
Definition: Optional.h:334
InitializePasses.h
llvm::PointerMayBeCapturedBefore
bool PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures, bool StoreCaptures, const Instruction *I, const DominatorTree *DT, bool IncludeI=false, unsigned MaxUsesToExplore=0, const LoopInfo *LI=nullptr)
PointerMayBeCapturedBefore - Return true if this pointer value may be captured by the enclosing funct...
Definition: CaptureTracking.cpp:269
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::AtomicCmpXchgInst
An instruction that atomically checks whether a specified value is in a memory location,...
Definition: Instructions.h:510
llvm::TargetLibraryAnalysis
Analysis pass providing the TargetLibraryInfo.
Definition: TargetLibraryInfo.h:449
llvm::AAResults::getModRefInfo
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc)
getModRefInfo (for call sites) - Return information about whether a particular call site modifies or ...
Definition: AliasAnalysis.cpp:217
llvm::isIntrinsicReturningPointerAliasingArgumentWithoutCapturing
bool isIntrinsicReturningPointerAliasingArgumentWithoutCapturing(const CallBase *Call, bool MustPreserveNullness)
{launder,strip}.invariant.group returns pointer that aliases its argument, and it only captures point...
Definition: ValueTracking.cpp:4459
CFLSteensAliasAnalysis.h
llvm::ModRefInfo::ModRef
@ ModRef
The access may reference and may modify the value stored in memory.
llvm::MemoryLocation
Representation for a specific memory location.
Definition: MemoryLocation.h:210
llvm::BasicBlock::const_iterator
InstListType::const_iterator const_iterator
Definition: BasicBlock.h:88
llvm::AAQueryInfo::Depth
unsigned Depth
Query depth used to distinguish recursive queries.
Definition: AliasAnalysis.h:486
llvm::FunctionModRefBehavior::ArgMem
@ ArgMem
Access to memory via argument pointers.
Definition: AliasAnalysis.h:213