LLVM  14.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/Module.h"
46 #include "llvm/IR/Type.h"
47 #include "llvm/IR/Value.h"
48 #include "llvm/InitializePasses.h"
49 #include "llvm/Pass.h"
51 #include "llvm/Support/Casting.h"
53 #include <algorithm>
54 #include <cassert>
55 #include <functional>
56 #include <iterator>
57 
58 #define DEBUG_TYPE "aa"
59 
60 using namespace llvm;
61 
62 STATISTIC(NumNoAlias, "Number of NoAlias results");
63 STATISTIC(NumMayAlias, "Number of MayAlias results");
64 STATISTIC(NumMustAlias, "Number of MustAlias results");
65 
66 namespace llvm {
67 /// Allow disabling BasicAA from the AA results. This is particularly useful
68 /// when testing to isolate a single AA implementation.
69 cl::opt<bool> DisableBasicAA("disable-basic-aa", cl::Hidden, cl::init(false));
70 } // namespace llvm
71 
72 #ifndef NDEBUG
73 /// Print a trace of alias analysis queries and their results.
74 static cl::opt<bool> EnableAATrace("aa-trace", cl::Hidden, cl::init(false));
75 #else
76 static const bool EnableAATrace = false;
77 #endif
78 
80  : TLI(Arg.TLI), AAs(std::move(Arg.AAs)), AADeps(std::move(Arg.AADeps)) {
81  for (auto &AA : AAs)
82  AA->setAAResults(this);
83 }
84 
86 // FIXME; It would be nice to at least clear out the pointers back to this
87 // aggregation here, but we end up with non-nesting lifetimes in the legacy
88 // pass manager that prevent this from working. In the legacy pass manager
89 // we'll end up with dangling references here in some cases.
90 #if 0
91  for (auto &AA : AAs)
92  AA->setAAResults(nullptr);
93 #endif
94 }
95 
98  // AAResults preserves the AAManager by default, due to the stateless nature
99  // of AliasAnalysis. There is no need to check whether it has been preserved
100  // explicitly. Check if any module dependency was invalidated and caused the
101  // AAManager to be invalidated. Invalidate ourselves in that case.
102  auto PAC = PA.getChecker<AAManager>();
103  if (!PAC.preservedWhenStateless())
104  return true;
105 
106  // Check if any of the function dependencies were invalidated, and invalidate
107  // ourselves in that case.
108  for (AnalysisKey *ID : AADeps)
109  if (Inv.invalidate(ID, F, PA))
110  return true;
111 
112  // Everything we depend on is still fine, so are we. Nothing to invalidate.
113  return false;
114 }
115 
116 //===----------------------------------------------------------------------===//
117 // Default chaining methods
118 //===----------------------------------------------------------------------===//
119 
121  const MemoryLocation &LocB) {
122  AAQueryInfo AAQIP;
123  return alias(LocA, LocB, AAQIP);
124 }
125 
127  const MemoryLocation &LocB, AAQueryInfo &AAQI) {
129 
130  if (EnableAATrace) {
131  for (unsigned I = 0; I < AAQI.Depth; ++I)
132  dbgs() << " ";
133  dbgs() << "Start " << *LocA.Ptr << " @ " << LocA.Size << ", "
134  << *LocB.Ptr << " @ " << LocB.Size << "\n";
135  }
136 
137  AAQI.Depth++;
138  for (const auto &AA : AAs) {
139  Result = AA->alias(LocA, LocB, AAQI);
140  if (Result != AliasResult::MayAlias)
141  break;
142  }
143  AAQI.Depth--;
144 
145  if (EnableAATrace) {
146  for (unsigned I = 0; I < AAQI.Depth; ++I)
147  dbgs() << " ";
148  dbgs() << "End " << *LocA.Ptr << " @ " << LocA.Size << ", "
149  << *LocB.Ptr << " @ " << LocB.Size << " = " << Result << "\n";
150  }
151 
152  if (AAQI.Depth == 0) {
153  if (Result == AliasResult::NoAlias)
154  ++NumNoAlias;
155  else if (Result == AliasResult::MustAlias)
156  ++NumMustAlias;
157  else
158  ++NumMayAlias;
159  }
160  return Result;
161 }
162 
164  bool OrLocal) {
165  AAQueryInfo AAQIP;
166  return pointsToConstantMemory(Loc, AAQIP, OrLocal);
167 }
168 
170  AAQueryInfo &AAQI, bool OrLocal) {
171  for (const auto &AA : AAs)
172  if (AA->pointsToConstantMemory(Loc, AAQI, OrLocal))
173  return true;
174 
175  return false;
176 }
177 
178 ModRefInfo AAResults::getArgModRefInfo(const CallBase *Call, unsigned ArgIdx) {
180 
181  for (const auto &AA : AAs) {
182  Result = intersectModRef(Result, AA->getArgModRefInfo(Call, ArgIdx));
183 
184  // Early-exit the moment we reach the bottom of the lattice.
185  if (isNoModRef(Result))
186  return ModRefInfo::NoModRef;
187  }
188 
189  return Result;
190 }
191 
193  AAQueryInfo AAQIP;
194  return getModRefInfo(I, Call2, AAQIP);
195 }
196 
198  AAQueryInfo &AAQI) {
199  // We may have two calls.
200  if (const auto *Call1 = dyn_cast<CallBase>(I)) {
201  // Check if the two calls modify the same memory.
202  return getModRefInfo(Call1, Call2, AAQI);
203  } else if (I->isFenceLike()) {
204  // If this is a fence, just return ModRef.
205  return ModRefInfo::ModRef;
206  } else {
207  // Otherwise, check if the call modifies or references the
208  // location this memory access defines. The best we can say
209  // is that if the call references what this instruction
210  // defines, it must be clobbered by this location.
211  const MemoryLocation DefLoc = MemoryLocation::get(I);
212  ModRefInfo MR = getModRefInfo(Call2, DefLoc, AAQI);
213  if (isModOrRefSet(MR))
214  return setModAndRef(MR);
215  }
216  return ModRefInfo::NoModRef;
217 }
218 
220  const MemoryLocation &Loc) {
221  AAQueryInfo AAQIP;
222  return getModRefInfo(Call, Loc, AAQIP);
223 }
224 
226  const MemoryLocation &Loc,
227  AAQueryInfo &AAQI) {
229 
230  for (const auto &AA : AAs) {
231  Result = intersectModRef(Result, AA->getModRefInfo(Call, Loc, AAQI));
232 
233  // Early-exit the moment we reach the bottom of the lattice.
234  if (isNoModRef(Result))
235  return ModRefInfo::NoModRef;
236  }
237 
238  // Try to refine the mod-ref info further using other API entry points to the
239  // aggregate set of AA results.
240  auto MRB = getModRefBehavior(Call);
242  return ModRefInfo::NoModRef;
243 
244  if (onlyReadsMemory(MRB))
245  Result = clearMod(Result);
246  else if (doesNotReadMemory(MRB))
247  Result = clearRef(Result);
248 
250  bool IsMustAlias = true;
251  ModRefInfo AllArgsMask = ModRefInfo::NoModRef;
252  if (doesAccessArgPointees(MRB)) {
253  for (auto AI = Call->arg_begin(), AE = Call->arg_end(); AI != AE; ++AI) {
254  const Value *Arg = *AI;
255  if (!Arg->getType()->isPointerTy())
256  continue;
257  unsigned ArgIdx = std::distance(Call->arg_begin(), AI);
258  MemoryLocation ArgLoc =
259  MemoryLocation::getForArgument(Call, ArgIdx, TLI);
260  AliasResult ArgAlias = alias(ArgLoc, Loc, AAQI);
261  if (ArgAlias != AliasResult::NoAlias) {
262  ModRefInfo ArgMask = getArgModRefInfo(Call, ArgIdx);
263  AllArgsMask = unionModRef(AllArgsMask, ArgMask);
264  }
265  // Conservatively clear IsMustAlias unless only MustAlias is found.
266  IsMustAlias &= (ArgAlias == AliasResult::MustAlias);
267  }
268  }
269  // Return NoModRef if no alias found with any argument.
270  if (isNoModRef(AllArgsMask))
271  return ModRefInfo::NoModRef;
272  // Logical & between other AA analyses and argument analysis.
273  Result = intersectModRef(Result, AllArgsMask);
274  // If only MustAlias found above, set Must bit.
275  Result = IsMustAlias ? setMust(Result) : clearMust(Result);
276  }
277 
278  // If Loc is a constant memory location, the call definitely could not
279  // modify the memory location.
280  if (isModSet(Result) && pointsToConstantMemory(Loc, AAQI, /*OrLocal*/ false))
281  Result = clearMod(Result);
282 
283  return Result;
284 }
285 
287  const CallBase *Call2) {
288  AAQueryInfo AAQIP;
289  return getModRefInfo(Call1, Call2, AAQIP);
290 }
291 
293  const CallBase *Call2, AAQueryInfo &AAQI) {
295 
296  for (const auto &AA : AAs) {
297  Result = intersectModRef(Result, AA->getModRefInfo(Call1, Call2, AAQI));
298 
299  // Early-exit the moment we reach the bottom of the lattice.
300  if (isNoModRef(Result))
301  return ModRefInfo::NoModRef;
302  }
303 
304  // Try to refine the mod-ref info further using other API entry points to the
305  // aggregate set of AA results.
306 
307  // If Call1 or Call2 are readnone, they don't interact.
308  auto Call1B = getModRefBehavior(Call1);
309  if (Call1B == FMRB_DoesNotAccessMemory)
310  return ModRefInfo::NoModRef;
311 
312  auto Call2B = getModRefBehavior(Call2);
313  if (Call2B == FMRB_DoesNotAccessMemory)
314  return ModRefInfo::NoModRef;
315 
316  // If they both only read from memory, there is no dependence.
317  if (onlyReadsMemory(Call1B) && onlyReadsMemory(Call2B))
318  return ModRefInfo::NoModRef;
319 
320  // If Call1 only reads memory, the only dependence on Call2 can be
321  // from Call1 reading memory written by Call2.
322  if (onlyReadsMemory(Call1B))
323  Result = clearMod(Result);
324  else if (doesNotReadMemory(Call1B))
325  Result = clearRef(Result);
326 
327  // If Call2 only access memory through arguments, accumulate the mod/ref
328  // information from Call1's references to the memory referenced by
329  // Call2's arguments.
330  if (onlyAccessesArgPointees(Call2B)) {
331  if (!doesAccessArgPointees(Call2B))
332  return ModRefInfo::NoModRef;
334  bool IsMustAlias = true;
335  for (auto I = Call2->arg_begin(), E = Call2->arg_end(); I != E; ++I) {
336  const Value *Arg = *I;
337  if (!Arg->getType()->isPointerTy())
338  continue;
339  unsigned Call2ArgIdx = std::distance(Call2->arg_begin(), I);
340  auto Call2ArgLoc =
341  MemoryLocation::getForArgument(Call2, Call2ArgIdx, TLI);
342 
343  // ArgModRefC2 indicates what Call2 might do to Call2ArgLoc, and the
344  // dependence of Call1 on that location is the inverse:
345  // - If Call2 modifies location, dependence exists if Call1 reads or
346  // writes.
347  // - If Call2 only reads location, dependence exists if Call1 writes.
348  ModRefInfo ArgModRefC2 = getArgModRefInfo(Call2, Call2ArgIdx);
350  if (isModSet(ArgModRefC2))
351  ArgMask = ModRefInfo::ModRef;
352  else if (isRefSet(ArgModRefC2))
353  ArgMask = ModRefInfo::Mod;
354 
355  // ModRefC1 indicates what Call1 might do to Call2ArgLoc, and we use
356  // above ArgMask to update dependence info.
357  ModRefInfo ModRefC1 = getModRefInfo(Call1, Call2ArgLoc, AAQI);
358  ArgMask = intersectModRef(ArgMask, ModRefC1);
359 
360  // Conservatively clear IsMustAlias unless only MustAlias is found.
361  IsMustAlias &= isMustSet(ModRefC1);
362 
363  R = intersectModRef(unionModRef(R, ArgMask), Result);
364  if (R == Result) {
365  // On early exit, not all args were checked, cannot set Must.
366  if (I + 1 != E)
367  IsMustAlias = false;
368  break;
369  }
370  }
371 
372  if (isNoModRef(R))
373  return ModRefInfo::NoModRef;
374 
375  // If MustAlias found above, set Must bit.
376  return IsMustAlias ? setMust(R) : clearMust(R);
377  }
378 
379  // If Call1 only accesses memory through arguments, check if Call2 references
380  // any of the memory referenced by Call1's arguments. If not, return NoModRef.
381  if (onlyAccessesArgPointees(Call1B)) {
382  if (!doesAccessArgPointees(Call1B))
383  return ModRefInfo::NoModRef;
385  bool IsMustAlias = true;
386  for (auto I = Call1->arg_begin(), E = Call1->arg_end(); I != E; ++I) {
387  const Value *Arg = *I;
388  if (!Arg->getType()->isPointerTy())
389  continue;
390  unsigned Call1ArgIdx = std::distance(Call1->arg_begin(), I);
391  auto Call1ArgLoc =
392  MemoryLocation::getForArgument(Call1, Call1ArgIdx, TLI);
393 
394  // ArgModRefC1 indicates what Call1 might do to Call1ArgLoc; if Call1
395  // might Mod Call1ArgLoc, then we care about either a Mod or a Ref by
396  // Call2. If Call1 might Ref, then we care only about a Mod by Call2.
397  ModRefInfo ArgModRefC1 = getArgModRefInfo(Call1, Call1ArgIdx);
398  ModRefInfo ModRefC2 = getModRefInfo(Call2, Call1ArgLoc, AAQI);
399  if ((isModSet(ArgModRefC1) && isModOrRefSet(ModRefC2)) ||
400  (isRefSet(ArgModRefC1) && isModSet(ModRefC2)))
401  R = intersectModRef(unionModRef(R, ArgModRefC1), Result);
402 
403  // Conservatively clear IsMustAlias unless only MustAlias is found.
404  IsMustAlias &= isMustSet(ModRefC2);
405 
406  if (R == Result) {
407  // On early exit, not all args were checked, cannot set Must.
408  if (I + 1 != E)
409  IsMustAlias = false;
410  break;
411  }
412  }
413 
414  if (isNoModRef(R))
415  return ModRefInfo::NoModRef;
416 
417  // If MustAlias found above, set Must bit.
418  return IsMustAlias ? setMust(R) : clearMust(R);
419  }
420 
421  return Result;
422 }
423 
426 
427  for (const auto &AA : AAs) {
428  Result = FunctionModRefBehavior(Result & AA->getModRefBehavior(Call));
429 
430  // Early-exit the moment we reach the bottom of the lattice.
431  if (Result == FMRB_DoesNotAccessMemory)
432  return Result;
433  }
434 
435  return Result;
436 }
437 
440 
441  for (const auto &AA : AAs) {
442  Result = FunctionModRefBehavior(Result & AA->getModRefBehavior(F));
443 
444  // Early-exit the moment we reach the bottom of the lattice.
445  if (Result == FMRB_DoesNotAccessMemory)
446  return Result;
447  }
448 
449  return Result;
450 }
451 
453  switch (AR) {
455  OS << "NoAlias";
456  break;
458  OS << "MustAlias";
459  break;
461  OS << "MayAlias";
462  break;
464  OS << "PartialAlias";
465  if (AR.hasOffset())
466  OS << " (off " << AR.getOffset() << ")";
467  break;
468  }
469  return OS;
470 }
471 
472 //===----------------------------------------------------------------------===//
473 // Helper method implementation
474 //===----------------------------------------------------------------------===//
475 
477  const MemoryLocation &Loc) {
478  AAQueryInfo AAQIP;
479  return getModRefInfo(L, Loc, AAQIP);
480 }
482  const MemoryLocation &Loc,
483  AAQueryInfo &AAQI) {
484  // Be conservative in the face of atomic.
486  return ModRefInfo::ModRef;
487 
488  // If the load address doesn't alias the given address, it doesn't read
489  // or write the specified memory.
490  if (Loc.Ptr) {
491  AliasResult AR = alias(MemoryLocation::get(L), Loc, AAQI);
492  if (AR == AliasResult::NoAlias)
493  return ModRefInfo::NoModRef;
494  if (AR == AliasResult::MustAlias)
495  return ModRefInfo::MustRef;
496  }
497  // Otherwise, a load just reads.
498  return ModRefInfo::Ref;
499 }
500 
502  const MemoryLocation &Loc) {
503  AAQueryInfo AAQIP;
504  return getModRefInfo(S, Loc, AAQIP);
505 }
507  const MemoryLocation &Loc,
508  AAQueryInfo &AAQI) {
509  // Be conservative in the face of atomic.
510  if (isStrongerThan(S->getOrdering(), AtomicOrdering::Unordered))
511  return ModRefInfo::ModRef;
512 
513  if (Loc.Ptr) {
514  AliasResult AR = alias(MemoryLocation::get(S), Loc, AAQI);
515  // If the store address cannot alias the pointer in question, then the
516  // specified memory cannot be modified by the store.
517  if (AR == AliasResult::NoAlias)
518  return ModRefInfo::NoModRef;
519 
520  // If the pointer is a pointer to constant memory, then it could not have
521  // been modified by this store.
522  if (pointsToConstantMemory(Loc, AAQI))
523  return ModRefInfo::NoModRef;
524 
525  // If the store address aliases the pointer as must alias, set Must.
526  if (AR == AliasResult::MustAlias)
527  return ModRefInfo::MustMod;
528  }
529 
530  // Otherwise, a store just writes.
531  return ModRefInfo::Mod;
532 }
533 
535  AAQueryInfo AAQIP;
536  return getModRefInfo(S, Loc, AAQIP);
537 }
538 
540  const MemoryLocation &Loc,
541  AAQueryInfo &AAQI) {
542  // If we know that the location is a constant memory location, the fence
543  // cannot modify this location.
544  if (Loc.Ptr && pointsToConstantMemory(Loc, AAQI))
545  return ModRefInfo::Ref;
546  return ModRefInfo::ModRef;
547 }
548 
550  const MemoryLocation &Loc) {
551  AAQueryInfo AAQIP;
552  return getModRefInfo(V, Loc, AAQIP);
553 }
554 
556  const MemoryLocation &Loc,
557  AAQueryInfo &AAQI) {
558  if (Loc.Ptr) {
559  AliasResult AR = alias(MemoryLocation::get(V), Loc, AAQI);
560  // If the va_arg address cannot alias the pointer in question, then the
561  // specified memory cannot be accessed by the va_arg.
562  if (AR == AliasResult::NoAlias)
563  return ModRefInfo::NoModRef;
564 
565  // If the pointer is a pointer to constant memory, then it could not have
566  // been modified by this va_arg.
567  if (pointsToConstantMemory(Loc, AAQI))
568  return ModRefInfo::NoModRef;
569 
570  // If the va_arg aliases the pointer as must alias, set Must.
571  if (AR == AliasResult::MustAlias)
572  return ModRefInfo::MustModRef;
573  }
574 
575  // Otherwise, a va_arg reads and writes.
576  return ModRefInfo::ModRef;
577 }
578 
580  const MemoryLocation &Loc) {
581  AAQueryInfo AAQIP;
582  return getModRefInfo(CatchPad, Loc, AAQIP);
583 }
584 
586  const MemoryLocation &Loc,
587  AAQueryInfo &AAQI) {
588  if (Loc.Ptr) {
589  // If the pointer is a pointer to constant memory,
590  // then it could not have been modified by this catchpad.
591  if (pointsToConstantMemory(Loc, AAQI))
592  return ModRefInfo::NoModRef;
593  }
594 
595  // Otherwise, a catchpad reads and writes.
596  return ModRefInfo::ModRef;
597 }
598 
600  const MemoryLocation &Loc) {
601  AAQueryInfo AAQIP;
602  return getModRefInfo(CatchRet, Loc, AAQIP);
603 }
604 
606  const MemoryLocation &Loc,
607  AAQueryInfo &AAQI) {
608  if (Loc.Ptr) {
609  // If the pointer is a pointer to constant memory,
610  // then it could not have been modified by this catchpad.
611  if (pointsToConstantMemory(Loc, AAQI))
612  return ModRefInfo::NoModRef;
613  }
614 
615  // Otherwise, a catchret reads and writes.
616  return ModRefInfo::ModRef;
617 }
618 
620  const MemoryLocation &Loc) {
621  AAQueryInfo AAQIP;
622  return getModRefInfo(CX, Loc, AAQIP);
623 }
624 
626  const MemoryLocation &Loc,
627  AAQueryInfo &AAQI) {
628  // Acquire/Release cmpxchg has properties that matter for arbitrary addresses.
630  return ModRefInfo::ModRef;
631 
632  if (Loc.Ptr) {
633  AliasResult AR = alias(MemoryLocation::get(CX), Loc, AAQI);
634  // If the cmpxchg address does not alias the location, it does not access
635  // it.
636  if (AR == AliasResult::NoAlias)
637  return ModRefInfo::NoModRef;
638 
639  // If the cmpxchg address aliases the pointer as must alias, set Must.
640  if (AR == AliasResult::MustAlias)
641  return ModRefInfo::MustModRef;
642  }
643 
644  return ModRefInfo::ModRef;
645 }
646 
648  const MemoryLocation &Loc) {
649  AAQueryInfo AAQIP;
650  return getModRefInfo(RMW, Loc, AAQIP);
651 }
652 
654  const MemoryLocation &Loc,
655  AAQueryInfo &AAQI) {
656  // Acquire/Release atomicrmw has properties that matter for arbitrary addresses.
658  return ModRefInfo::ModRef;
659 
660  if (Loc.Ptr) {
661  AliasResult AR = alias(MemoryLocation::get(RMW), Loc, AAQI);
662  // If the atomicrmw address does not alias the location, it does not access
663  // it.
664  if (AR == AliasResult::NoAlias)
665  return ModRefInfo::NoModRef;
666 
667  // If the atomicrmw address aliases the pointer as must alias, set Must.
668  if (AR == AliasResult::MustAlias)
669  return ModRefInfo::MustModRef;
670  }
671 
672  return ModRefInfo::ModRef;
673 }
674 
676  const Optional<MemoryLocation> &OptLoc,
677  AAQueryInfo &AAQIP) {
678  if (OptLoc == None) {
679  if (const auto *Call = dyn_cast<CallBase>(I)) {
680  return createModRefInfo(getModRefBehavior(Call));
681  }
682  }
683 
684  const MemoryLocation &Loc = OptLoc.getValueOr(MemoryLocation());
685 
686  switch (I->getOpcode()) {
687  case Instruction::VAArg:
688  return getModRefInfo((const VAArgInst *)I, Loc, AAQIP);
689  case Instruction::Load:
690  return getModRefInfo((const LoadInst *)I, Loc, AAQIP);
691  case Instruction::Store:
692  return getModRefInfo((const StoreInst *)I, Loc, AAQIP);
693  case Instruction::Fence:
694  return getModRefInfo((const FenceInst *)I, Loc, AAQIP);
695  case Instruction::AtomicCmpXchg:
696  return getModRefInfo((const AtomicCmpXchgInst *)I, Loc, AAQIP);
697  case Instruction::AtomicRMW:
698  return getModRefInfo((const AtomicRMWInst *)I, Loc, AAQIP);
699  case Instruction::Call:
700  return getModRefInfo((const CallInst *)I, Loc, AAQIP);
701  case Instruction::Invoke:
702  return getModRefInfo((const InvokeInst *)I, Loc, AAQIP);
703  case Instruction::CatchPad:
704  return getModRefInfo((const CatchPadInst *)I, Loc, AAQIP);
705  case Instruction::CatchRet:
706  return getModRefInfo((const CatchReturnInst *)I, Loc, AAQIP);
707  default:
708  return ModRefInfo::NoModRef;
709  }
710 }
711 
712 /// Return information about whether a particular call site modifies
713 /// or reads the specified memory location \p MemLoc before instruction \p I
714 /// in a BasicBlock.
715 /// FIXME: this is really just shoring-up a deficiency in alias analysis.
716 /// BasicAA isn't willing to spend linear time determining whether an alloca
717 /// was captured before or after this particular call, while we are. However,
718 /// with a smarter AA in place, this test is just wasting compile time.
720  const MemoryLocation &MemLoc,
721  DominatorTree *DT,
722  AAQueryInfo &AAQI) {
723  if (!DT)
724  return ModRefInfo::ModRef;
725 
726  const Value *Object = getUnderlyingObject(MemLoc.Ptr);
727  if (!isIdentifiedFunctionLocal(Object))
728  return ModRefInfo::ModRef;
729 
730  const auto *Call = dyn_cast<CallBase>(I);
731  if (!Call || Call == Object)
732  return ModRefInfo::ModRef;
733 
734  if (PointerMayBeCapturedBefore(Object, /* ReturnCaptures */ true,
735  /* StoreCaptures */ true, I, DT,
736  /* include Object */ true))
737  return ModRefInfo::ModRef;
738 
739  unsigned ArgNo = 0;
741  bool IsMustAlias = true;
742  // Set flag only if no May found and all operands processed.
743  for (auto CI = Call->data_operands_begin(), CE = Call->data_operands_end();
744  CI != CE; ++CI, ++ArgNo) {
745  // Only look at the no-capture or byval pointer arguments. If this
746  // pointer were passed to arguments that were neither of these, then it
747  // couldn't be no-capture.
748  if (!(*CI)->getType()->isPointerTy() ||
749  (!Call->doesNotCapture(ArgNo) && ArgNo < Call->getNumArgOperands() &&
750  !Call->isByValArgument(ArgNo)))
751  continue;
752 
753  AliasResult AR = alias(
755  MemoryLocation::getBeforeOrAfter(Object), AAQI);
756  // If this is a no-capture pointer argument, see if we can tell that it
757  // is impossible to alias the pointer we're checking. If not, we have to
758  // assume that the call could touch the pointer, even though it doesn't
759  // escape.
760  if (AR != AliasResult::MustAlias)
761  IsMustAlias = false;
762  if (AR == AliasResult::NoAlias)
763  continue;
764  if (Call->doesNotAccessMemory(ArgNo))
765  continue;
766  if (Call->onlyReadsMemory(ArgNo)) {
767  R = ModRefInfo::Ref;
768  continue;
769  }
770  // Not returning MustModRef since we have not seen all the arguments.
771  return ModRefInfo::ModRef;
772  }
773  return IsMustAlias ? setMust(R) : clearMust(R);
774 }
775 
776 /// canBasicBlockModify - Return true if it is possible for execution of the
777 /// specified basic block to modify the location Loc.
778 ///
780  const MemoryLocation &Loc) {
781  return canInstructionRangeModRef(BB.front(), BB.back(), Loc, ModRefInfo::Mod);
782 }
783 
784 /// canInstructionRangeModRef - Return true if it is possible for the
785 /// execution of the specified instructions to mod\ref (according to the
786 /// mode) the location Loc. The instructions to consider are all
787 /// of the instructions in the range of [I1,I2] INCLUSIVE.
788 /// I1 and I2 must be in the same basic block.
790  const Instruction &I2,
791  const MemoryLocation &Loc,
792  const ModRefInfo Mode) {
793  assert(I1.getParent() == I2.getParent() &&
794  "Instructions not in same basic block!");
797  ++E; // Convert from inclusive to exclusive range.
798 
799  for (; I != E; ++I) // Check every instruction in range
801  return true;
802  return false;
803 }
804 
805 // Provide a definition for the root virtual destructor.
806 AAResults::Concept::~Concept() = default;
807 
808 // Provide a definition for the static object used to identify passes.
809 AnalysisKey AAManager::Key;
810 
811 namespace {
812 
813 
814 } // end anonymous namespace
815 
818 }
819 
821  : ImmutablePass(ID), CB(std::move(CB)) {
823 }
824 
826 
827 INITIALIZE_PASS(ExternalAAWrapperPass, "external-aa", "External Alias Analysis",
828  false, true)
829 
832  return new ExternalAAWrapperPass(std::move(Callback));
833 }
834 
837 }
838 
839 char AAResultsWrapperPass::ID = 0;
840 
842  "Function Alias Analysis Results", false, true)
848 INITIALIZE_PASS_DEPENDENCY(ObjCARCAAWrapperPass)
853  "Function Alias Analysis Results", false, true)
854 
856  return new AAResultsWrapperPass();
857 }
858 
859 /// Run the wrapper pass to rebuild an aggregation over known AA passes.
860 ///
861 /// This is the legacy pass manager's interface to the new-style AA results
862 /// aggregation object. Because this is somewhat shoe-horned into the legacy
863 /// pass manager, we hard code all the specific alias analyses available into
864 /// it. While the particular set enabled is configured via commandline flags,
865 /// adding a new alias analysis to LLVM will require adding support for it to
866 /// this list.
868  // NB! This *must* be reset before adding new AA results to the new
869  // AAResults object because in the legacy pass manager, each instance
870  // of these will refer to the *same* immutable analyses, registering and
871  // unregistering themselves with them. We need to carefully tear down the
872  // previous object first, in this case replacing it with an empty one, before
873  // registering new results.
874  AAR.reset(
875  new AAResults(getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F)));
876 
877  // BasicAA is always available for function analyses. Also, we add it first
878  // so that it can trump TBAA results when it proves MustAlias.
879  // FIXME: TBAA should have an explicit mode to support this and then we
880  // should reconsider the ordering here.
881  if (!DisableBasicAA)
882  AAR->addAAResult(getAnalysis<BasicAAWrapperPass>().getResult());
883 
884  // Populate the results with the currently available AAs.
885  if (auto *WrapperPass = getAnalysisIfAvailable<ScopedNoAliasAAWrapperPass>())
886  AAR->addAAResult(WrapperPass->getResult());
887  if (auto *WrapperPass = getAnalysisIfAvailable<TypeBasedAAWrapperPass>())
888  AAR->addAAResult(WrapperPass->getResult());
889  if (auto *WrapperPass =
890  getAnalysisIfAvailable<objcarc::ObjCARCAAWrapperPass>())
891  AAR->addAAResult(WrapperPass->getResult());
892  if (auto *WrapperPass = getAnalysisIfAvailable<GlobalsAAWrapperPass>())
893  AAR->addAAResult(WrapperPass->getResult());
894  if (auto *WrapperPass = getAnalysisIfAvailable<SCEVAAWrapperPass>())
895  AAR->addAAResult(WrapperPass->getResult());
896  if (auto *WrapperPass = getAnalysisIfAvailable<CFLAndersAAWrapperPass>())
897  AAR->addAAResult(WrapperPass->getResult());
898  if (auto *WrapperPass = getAnalysisIfAvailable<CFLSteensAAWrapperPass>())
899  AAR->addAAResult(WrapperPass->getResult());
900 
901  // If available, run an external AA providing callback over the results as
902  // well.
903  if (auto *WrapperPass = getAnalysisIfAvailable<ExternalAAWrapperPass>())
904  if (WrapperPass->CB)
905  WrapperPass->CB(*this, F, *AAR);
906 
907  // Analyses don't mutate the IR, so return false.
908  return false;
909 }
910 
912  AU.setPreservesAll();
915 
916  // We also need to mark all the alias analysis passes we will potentially
917  // probe in runOnFunction as used here to ensure the legacy pass manager
918  // preserves them. This hard coding of lists of alias analyses is specific to
919  // the legacy pass manager.
928 }
929 
932  for (auto &Getter : ResultGetters)
933  (*Getter)(F, AM, R);
934  return R;
935 }
936 
938  BasicAAResult &BAR) {
939  AAResults AAR(P.getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F));
940 
941  // Add in our explicitly constructed BasicAA results.
942  if (!DisableBasicAA)
943  AAR.addAAResult(BAR);
944 
945  // Populate the results with the other currently available AAs.
946  if (auto *WrapperPass =
947  P.getAnalysisIfAvailable<ScopedNoAliasAAWrapperPass>())
948  AAR.addAAResult(WrapperPass->getResult());
949  if (auto *WrapperPass = P.getAnalysisIfAvailable<TypeBasedAAWrapperPass>())
950  AAR.addAAResult(WrapperPass->getResult());
951  if (auto *WrapperPass =
952  P.getAnalysisIfAvailable<objcarc::ObjCARCAAWrapperPass>())
953  AAR.addAAResult(WrapperPass->getResult());
954  if (auto *WrapperPass = P.getAnalysisIfAvailable<GlobalsAAWrapperPass>())
955  AAR.addAAResult(WrapperPass->getResult());
956  if (auto *WrapperPass = P.getAnalysisIfAvailable<CFLAndersAAWrapperPass>())
957  AAR.addAAResult(WrapperPass->getResult());
958  if (auto *WrapperPass = P.getAnalysisIfAvailable<CFLSteensAAWrapperPass>())
959  AAR.addAAResult(WrapperPass->getResult());
960  if (auto *WrapperPass = P.getAnalysisIfAvailable<ExternalAAWrapperPass>())
961  if (WrapperPass->CB)
962  WrapperPass->CB(P, F, AAR);
963 
964  return AAR;
965 }
966 
967 bool llvm::isNoAliasCall(const Value *V) {
968  if (const auto *Call = dyn_cast<CallBase>(V))
969  return Call->hasRetAttr(Attribute::NoAlias);
970  return false;
971 }
972 
973 static bool isNoAliasOrByValArgument(const Value *V) {
974  if (const Argument *A = dyn_cast<Argument>(V))
975  return A->hasNoAliasAttr() || A->hasByValAttr();
976  return false;
977 }
978 
980  if (isa<AllocaInst>(V))
981  return true;
982  if (isa<GlobalValue>(V) && !isa<GlobalAlias>(V))
983  return true;
984  if (isNoAliasCall(V))
985  return true;
987  return true;
988  return false;
989 }
990 
992  return isa<AllocaInst>(V) || isNoAliasCall(V) || isNoAliasOrByValArgument(V);
993 }
994 
996  // This function needs to be in sync with llvm::createLegacyPMAAResults -- if
997  // more alias analyses are added to llvm::createLegacyPMAAResults, they need
998  // to be added here also.
1007 }
llvm::AAResults::addAAResult
void addAAResult(AAResultT &AAResult)
Register a specific AA result.
Definition: AliasAnalysis.h:465
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
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:29
llvm::AAManager
A manager for alias analyses.
Definition: AliasAnalysis.h:1233
llvm::AliasResult::MayAlias
@ MayAlias
The two locations may or may not alias.
Definition: AliasAnalysis.h:102
llvm::AliasResult::PartialAlias
@ PartialAlias
The two locations alias, but only due to a partial overlap.
Definition: AliasAnalysis.h:104
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:37
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::ExternalAAWrapperPass::ExternalAAWrapperPass
ExternalAAWrapperPass()
Definition: AliasAnalysis.cpp:816
llvm::VAArgInst
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
Definition: Instructions.h:1835
llvm::isModOrRefSet
LLVM_NODISCARD bool isModOrRefSet(const ModRefInfo MRI)
Definition: AliasAnalysis.h:189
llvm::ImmutablePass
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:269
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:769
llvm::MemoryLocation::Ptr
const Value * Ptr
The address of the start of the location.
Definition: MemoryLocation.h:217
aa
aa
Definition: AliasAnalysis.cpp:852
llvm::Function
Definition: Function.h:61
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:674
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:96
llvm::createAAResultsWrapperPass
FunctionPass * createAAResultsWrapperPass()
Definition: AliasAnalysis.cpp:855
Statistic.h
CaptureTracking.h
llvm::AtomicCmpXchgInst::getSuccessOrdering
AtomicOrdering getSuccessOrdering() const
Returns the success ordering constraint of this cmpxchg instruction.
Definition: Instructions.h:604
llvm::AAResults::Concept::~Concept
virtual ~Concept()=0
llvm::createModRefInfo
LLVM_NODISCARD ModRefInfo createModRefInfo(const FunctionModRefBehavior FMRB)
Definition: AliasAnalysis.h:377
ValueTracking.h
llvm::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:151
GlobalsModRef.h
isNoAliasOrByValArgument
static bool isNoAliasOrByValArgument(const Value *V)
Definition: AliasAnalysis.cpp:973
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:143
llvm::AAResults::onlyAccessesArgPointees
static bool onlyAccessesArgPointees(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to read and write at most from objects poin...
Definition: AliasAnalysis.h:637
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:226
Module.h
llvm::Optional
Definition: APInt.h:33
llvm::FenceInst
An instruction for ordering other memory operations.
Definition: Instructions.h:444
llvm::AliasResult
The possible results of an alias query.
Definition: AliasAnalysis.h:81
Results
Function Alias Analysis Results
Definition: AliasAnalysis.cpp:853
llvm::CallBase::arg_begin
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
Definition: InstrTypes.h:1303
BasicAliasAnalysis.h
llvm::PointerMayBeCapturedBefore
bool PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures, bool StoreCaptures, const Instruction *I, const DominatorTree *DT, bool IncludeI=false, unsigned MaxUsesToExplore=0)
PointerMayBeCapturedBefore - Return true if this pointer value may be captured by the enclosing funct...
Definition: CaptureTracking.cpp:183
llvm::FMRB_UnknownModRefBehavior
@ FMRB_UnknownModRefBehavior
This indicates that the function could not be classified into one of the behaviors above.
Definition: AliasAnalysis.h:368
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:995
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::RISCVFenceField::R
@ R
Definition: RISCVBaseInfo.h:180
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
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:991
llvm::AAResults::AAResults
AAResults(const TargetLibraryInfo &TLI)
Definition: AliasAnalysis.h:460
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:206
llvm::AAQueryInfo
This class stores info we want to provide to or retain within an alias query.
Definition: AliasAnalysis.h:414
Instruction.h
CommandLine.h
llvm::ModRefInfo::MustRef
@ MustRef
The access may reference the value stored in memory, a mustAlias relation was found,...
llvm::isNoAliasCall
bool isNoAliasCall(const Value *V)
Return true if this pointer is returned by a noalias function.
Definition: AliasAnalysis.cpp:967
llvm::SPII::Load
@ Load
Definition: SparcInstrInfo.h:32
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:911
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:31
llvm::AAResults::onlyReadsMemory
bool onlyReadsMemory(const CallBase *Call)
Checks if the specified call is known to only read from non-volatile memory (or not access memory at ...
Definition: AliasAnalysis.h:605
llvm::ModRefInfo::Ref
@ Ref
The access may reference the value stored in memory.
llvm::AAResults
Definition: AliasAnalysis.h:456
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::ModRefInfo::MustModRef
@ MustModRef
The access may reference, modify or both the value stored in memory, a mustAlias relation was found,...
llvm::ModRefInfo::MustMod
@ MustMod
The access may modify the value stored in memory, a mustAlias relation was found, and no mayAlias or ...
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::AliasResult::hasOffset
constexpr bool hasOffset() const
Definition: AliasAnalysis.h:117
llvm::ms_demangle::QualifierMangleMode::Result
@ Result
TargetLibraryInfo.h
false
Definition: StackSlotColoring.cpp:142
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:827
llvm::Instruction
Definition: Instruction.h:45
llvm::ExternalAAWrapperPass::CallbackT
std::function< void(Pass &, Function &, AAResults &)> CallbackT
Definition: AliasAnalysis.h:1300
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:53
llvm::AAManager::run
Result run(Function &F, FunctionAnalysisManager &AM)
Definition: AliasAnalysis.cpp:930
llvm::operator<<
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:230
llvm::clearRef
LLVM_NODISCARD ModRefInfo clearRef(const ModRefInfo MRI)
Definition: AliasAnalysis.h:225
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:4356
llvm::AnalysisManager::Invalidator
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:656
CFLAndersAliasAnalysis.h
llvm::MCID::Call
@ Call
Definition: MCInstrDesc.h:153
llvm::isModSet
LLVM_NODISCARD bool isModSet(const ModRefInfo MRI)
Definition: AliasAnalysis.h:196
ScopedNoAliasAA.h
llvm::None
const NoneType None
Definition: None.h:23
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:937
llvm::AliasResult::getOffset
constexpr int32_t getOffset() const
Definition: AliasAnalysis.h:118
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:58
llvm::clearMod
LLVM_NODISCARD ModRefInfo clearMod(const ModRefInfo MRI)
Definition: AliasAnalysis.h:222
llvm::InvokeInst
Invoke instruction.
Definition: Instructions.h:3743
llvm::OutputFileType::Object
@ Object
llvm::clearMust
LLVM_NODISCARD ModRefInfo clearMust(const ModRefInfo MRI)
Definition: AliasAnalysis.h:228
llvm::TypeBasedAAWrapperPass
Legacy wrapper pass to provide the TypeBasedAAResult object.
Definition: TypeBasedAliasAnalysis.h:71
llvm::Optional::getValueOr
constexpr T getValueOr(U &&value) const LLVM_LVALUE_FUNCTION
Definition: Optional.h:297
BasicBlock.h
llvm::cl::opt< bool >
llvm::ExternalAAWrapperPass::ID
static char ID
Definition: AliasAnalysis.h:1304
llvm::StoreInst
An instruction for storing to memory.
Definition: Instructions.h:304
llvm::isNoModRef
LLVM_NODISCARD bool isNoModRef(const ModRefInfo MRI)
Definition: AliasAnalysis.h:185
llvm::SCEVAAWrapperPass
Legacy wrapper pass to provide the SCEVAAResult object.
Definition: ScalarEvolutionAliasAnalysis.h:55
llvm::TargetLibraryInfoWrapperPass
Definition: TargetLibraryInfo.h:463
llvm::CatchReturnInst
Definition: Instructions.h:4520
INITIALIZE_PASS_DEPENDENCY
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
llvm::BasicAAWrapperPass
Legacy wrapper pass to provide the BasicAAResult object.
Definition: BasicAliasAnalysis.h:244
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:844
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:72
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:789
llvm::AtomicOrdering::Unordered
@ Unordered
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
llvm::unionModRef
LLVM_NODISCARD ModRefInfo unionModRef(const ModRefInfo MRI1, const ModRefInfo MRI2)
Definition: AliasAnalysis.h:232
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::CFLSteensAAWrapperPass
Legacy wrapper pass to provide the CFLSteensAAResult object.
Definition: CFLSteensAliasAnalysis.h:123
llvm::ModRefInfo
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
Definition: AliasAnalysis.h:148
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:1605
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:147
llvm::AAResults::doesAccessArgPointees
static bool doesAccessArgPointees(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to potentially read or write from objects p...
Definition: AliasAnalysis.h:644
Mode
SI Whole Quad Mode
Definition: SIWholeQuadMode.cpp:262
ObjCARCAliasAnalysis.h
llvm::FMRB_DoesNotAccessMemory
@ FMRB_DoesNotAccessMemory
This function does not perform any non-local loads or stores to memory.
Definition: AliasAnalysis.h:268
llvm::CallBase::arg_end
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
Definition: InstrTypes.h:1309
llvm::AAResultsWrapperPass::ID
static char ID
Definition: AliasAnalysis.h:1285
llvm::initializeAAResultsWrapperPassPass
void initializeAAResultsWrapperPassPass(PassRegistry &)
llvm::SPII::Store
@ Store
Definition: SparcInstrInfo.h:33
llvm::AAResults::~AAResults
~AAResults()
Definition: AliasAnalysis.cpp:85
llvm::AliasResult::NoAlias
@ NoAlias
The two locations do not alias at all.
Definition: AliasAnalysis.h:99
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:81
llvm::setModAndRef
LLVM_NODISCARD ModRefInfo setModAndRef(const ModRefInfo MRI)
Definition: AliasAnalysis.h:218
llvm::AliasResult::MustAlias
@ MustAlias
The two locations precisely alias each other.
Definition: AliasAnalysis.h:106
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:475
llvm::FunctionModRefBehavior
FunctionModRefBehavior
Summary of how a function affects memory in the program.
Definition: AliasAnalysis.h:262
llvm::LoadInst::getOrdering
AtomicOrdering getOrdering() const
Returns the ordering constraint of this load instruction.
Definition: Instructions.h:232
llvm::BasicAAResult
This is the AA result object for the basic, local, and stateless alias analysis.
Definition: BasicAliasAnalysis.h:50
llvm::LoadInst
An instruction for reading from memory.
Definition: Instructions.h:175
llvm::AAResults::getModRefBehavior
FunctionModRefBehavior getModRefBehavior(const CallBase *Call)
Return the behavior of the given call site.
Definition: AliasAnalysis.cpp:424
llvm::AAResults::onlyAccessesInaccessibleOrArgMem
static bool onlyAccessesInaccessibleOrArgMem(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to read and write at most from memory that ...
Definition: AliasAnalysis.h:665
llvm::AtomicRMWInst
an instruction that atomically reads a memory location, combines it with another value,...
Definition: Instructions.h:726
Argument.h
Attributes.h
std
Definition: BitVector.h:838
llvm::isIdentifiedObject
bool isIdentifiedObject(const Value *V)
Return true if this pointer refers to a distinct and identifiable object.
Definition: AliasAnalysis.cpp:979
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition: PassAnalysisSupport.h:130
llvm::isMustSet
LLVM_NODISCARD bool isMustSet(const ModRefInfo MRI)
Definition: AliasAnalysis.h:202
llvm::AAResults::doesNotReadMemory
static bool doesNotReadMemory(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to only write memory (or not access memory ...
Definition: AliasAnalysis.h:630
llvm::AAResults::onlyAccessesInaccessibleMem
static bool onlyAccessesInaccessibleMem(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to read and write at most from memory that ...
Definition: AliasAnalysis.h:651
llvm::AAResultsWrapperPass::runOnFunction
bool runOnFunction(Function &F) override
Run the wrapper pass to rebuild an aggregation over known AA passes.
Definition: AliasAnalysis.cpp:867
Casting.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:120
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:163
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
llvm::CatchPadInst
Definition: Instructions.h:4469
llvm::AAResultsWrapperPass::AAResultsWrapperPass
AAResultsWrapperPass()
Definition: AliasAnalysis.cpp:835
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:178
llvm::Pass
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:91
Instructions.h
llvm::isRefSet
LLVM_NODISCARD bool isRefSet(const ModRefInfo MRI)
Definition: AliasAnalysis.h:199
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:1281
llvm::Instruction::getParent
const BasicBlock * getParent() const
Definition: Instruction.h:94
llvm::ExternalAAWrapperPass
A wrapper pass for external alias analyses.
Definition: AliasAnalysis.h:1299
llvm::GlobalsAAWrapperPass
Legacy wrapper pass to provide the GlobalsAAResult object.
Definition: GlobalsModRef.h:143
llvm::isStrongerThanMonotonic
bool isStrongerThanMonotonic(AtomicOrdering AO)
Definition: AtomicOrdering.h:124
llvm::setMust
LLVM_NODISCARD ModRefInfo setMust(const ModRefInfo MRI)
Definition: AliasAnalysis.h:214
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:779
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:797
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:275
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1161
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:313
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
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:298
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition: Instructions.h:1475
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::intersectModRef
LLVM_NODISCARD ModRefInfo intersectModRef(const ModRefInfo MRI1, const ModRefInfo MRI2)
Definition: AliasAnalysis.h:236
true
basic Basic Alias true
Definition: BasicAliasAnalysis.cpp:1815
llvm::initializeExternalAAWrapperPassPass
void initializeExternalAAWrapperPassPass(PassRegistry &)
Value.h
InitializePasses.h
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::AtomicCmpXchgInst
An instruction that atomically checks whether a specified value is in a memory location,...
Definition: Instructions.h:521
llvm::TargetLibraryAnalysis
Analysis pass providing the TargetLibraryInfo.
Definition: TargetLibraryInfo.h:438
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:219
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:209
llvm::BasicBlock::const_iterator
InstListType::const_iterator const_iterator
Definition: BasicBlock.h:91
llvm::AAQueryInfo::Depth
unsigned Depth
Query depth used to distinguish recursive queries.
Definition: AliasAnalysis.h:432
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38