Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.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
26#include "llvm/Analysis/AliasAnalysis.h"
27#include "llvm/ADT/Statistic.h"
28#include "llvm/Analysis/BasicAliasAnalysis.h"
29#include "llvm/Analysis/CaptureTracking.h"
30#include "llvm/Analysis/GlobalsModRef.h"
31#include "llvm/Analysis/MemoryLocation.h"
32#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
33#include "llvm/Analysis/ScopedNoAliasAA.h"
34#include "llvm/Analysis/TargetLibraryInfo.h"
35#include "llvm/Analysis/TypeBasedAliasAnalysis.h"
36#include "llvm/Analysis/ValueTracking.h"
37#include "llvm/IR/Argument.h"
38#include "llvm/IR/Attributes.h"
39#include "llvm/IR/BasicBlock.h"
40#include "llvm/IR/Instruction.h"
41#include "llvm/IR/Instructions.h"
42#include "llvm/IR/Type.h"
43#include "llvm/IR/Value.h"
44#include "llvm/InitializePasses.h"
45#include "llvm/Pass.h"
46#include "llvm/Support/AtomicOrdering.h"
47#include "llvm/Support/Casting.h"
48#include "llvm/Support/CommandLine.h"
49#include <cassert>
50#include <functional>
51#include <iterator>
52
53#define DEBUG_TYPE "aa"
54
55using namespacellvm;
56
57STATISTIC(NumNoAlias,"Number of NoAlias results");
58STATISTIC(NumMayAlias,"Number of MayAlias results");
59STATISTIC(NumMustAlias,"Number of MustAlias results");
60
61namespacellvm {
62/// Allow disabling BasicAA from the AA results. This is particularly useful
63/// when testing to isolate a single AA implementation.
64cl::opt<bool>DisableBasicAA("disable-basic-aa",cl::Hidden,cl::init(false));
65}// namespace llvm
66
67#ifndef NDEBUG
68/// Print a trace of alias analysis queries and their results.
69staticcl::opt<bool>EnableAATrace("aa-trace",cl::Hidden,cl::init(false));
70#else
71staticconstboolEnableAATrace =false;
72#endif
73
74AAResults::AAResults(constTargetLibraryInfo &TLI) : TLI(TLI) {}
75
76AAResults::AAResults(AAResults &&Arg)
77 : TLI(Arg.TLI), AAs(std::move(Arg.AAs)), AADeps(std::move(Arg.AADeps)) {}
78
79AAResults::~AAResults() {}
80
81boolAAResults::invalidate(Function &F,constPreservedAnalyses &PA,
82FunctionAnalysisManager::Invalidator &Inv) {
83// AAResults preserves the AAManager by default, due to the stateless nature
84// of AliasAnalysis. There is no need to check whether it has been preserved
85// explicitly. Check if any module dependency was invalidated and caused the
86// AAManager to be invalidated. Invalidate ourselves in that case.
87auto PAC = PA.getChecker<AAManager>();
88if (!PAC.preservedWhenStateless())
89returntrue;
90
91// Check if any of the function dependencies were invalidated, and invalidate
92// ourselves in that case.
93for (AnalysisKey *ID : AADeps)
94if (Inv.invalidate(ID,F, PA))
95returntrue;
96
97// Everything we depend on is still fine, so are we. Nothing to invalidate.
98returnfalse;
99}
100
101//===----------------------------------------------------------------------===//
102// Default chaining methods
103//===----------------------------------------------------------------------===//
104
105AliasResultAAResults::alias(constMemoryLocation &LocA,
106constMemoryLocation &LocB) {
107SimpleAAQueryInfo AAQIP(*this);
108returnalias(LocA, LocB, AAQIP,nullptr);
109}
110
111AliasResultAAResults::alias(constMemoryLocation &LocA,
112constMemoryLocation &LocB,AAQueryInfo &AAQI,
113constInstruction *CtxI) {
114AliasResult Result =AliasResult::MayAlias;
115
116if (EnableAATrace) {
117for (unsignedI = 0;I < AAQI.Depth; ++I)
118dbgs() <<" ";
119dbgs() <<"Start " << *LocA.Ptr <<" @ " << LocA.Size <<", "
120 << *LocB.Ptr <<" @ " << LocB.Size <<"\n";
121 }
122
123 AAQI.Depth++;
124for (constauto &AA : AAs) {
125 Result = AA->alias(LocA, LocB, AAQI, CtxI);
126if (Result !=AliasResult::MayAlias)
127break;
128 }
129 AAQI.Depth--;
130
131if (EnableAATrace) {
132for (unsignedI = 0;I < AAQI.Depth; ++I)
133dbgs() <<" ";
134dbgs() <<"End " << *LocA.Ptr <<" @ " << LocA.Size <<", "
135 << *LocB.Ptr <<" @ " << LocB.Size <<" = " << Result <<"\n";
136 }
137
138if (AAQI.Depth == 0) {
139if (Result ==AliasResult::NoAlias)
140 ++NumNoAlias;
141elseif (Result ==AliasResult::MustAlias)
142 ++NumMustAlias;
143else
144 ++NumMayAlias;
145 }
146return Result;
147}
148
149ModRefInfoAAResults::getModRefInfoMask(constMemoryLocation &Loc,
150bool IgnoreLocals) {
151SimpleAAQueryInfo AAQIP(*this);
152returngetModRefInfoMask(Loc, AAQIP, IgnoreLocals);
153}
154
155ModRefInfoAAResults::getModRefInfoMask(constMemoryLocation &Loc,
156AAQueryInfo &AAQI,bool IgnoreLocals) {
157ModRefInfo Result =ModRefInfo::ModRef;
158
159for (constauto &AA : AAs) {
160 Result &= AA->getModRefInfoMask(Loc, AAQI, IgnoreLocals);
161
162// Early-exit the moment we reach the bottom of the lattice.
163if (isNoModRef(Result))
164returnModRefInfo::NoModRef;
165 }
166
167return Result;
168}
169
170ModRefInfoAAResults::getArgModRefInfo(constCallBase *Call,unsigned ArgIdx) {
171ModRefInfo Result =ModRefInfo::ModRef;
172
173for (constauto &AA : AAs) {
174 Result &= AA->getArgModRefInfo(Call, ArgIdx);
175
176// Early-exit the moment we reach the bottom of the lattice.
177if (isNoModRef(Result))
178returnModRefInfo::NoModRef;
179 }
180
181return Result;
182}
183
184ModRefInfoAAResults::getModRefInfo(constInstruction *I,
185constCallBase *Call2) {
186SimpleAAQueryInfo AAQIP(*this);
187returngetModRefInfo(I, Call2, AAQIP);
188}
189
190ModRefInfoAAResults::getModRefInfo(constInstruction *I,constCallBase *Call2,
191AAQueryInfo &AAQI) {
192// We may have two calls.
193if (constauto *Call1 = dyn_cast<CallBase>(I)) {
194// Check if the two calls modify the same memory.
195returngetModRefInfo(Call1, Call2, AAQI);
196 }
197// If this is a fence, just return ModRef.
198if (I->isFenceLike())
199returnModRefInfo::ModRef;
200// Otherwise, check if the call modifies or references the
201// location this memory access defines. The best we can say
202// is that if the call references what this instruction
203// defines, it must be clobbered by this location.
204constMemoryLocation DefLoc =MemoryLocation::get(I);
205ModRefInfo MR =getModRefInfo(Call2, DefLoc, AAQI);
206if (isModOrRefSet(MR))
207returnModRefInfo::ModRef;
208returnModRefInfo::NoModRef;
209}
210
211ModRefInfoAAResults::getModRefInfo(constCallBase *Call,
212constMemoryLocation &Loc,
213AAQueryInfo &AAQI) {
214ModRefInfo Result =ModRefInfo::ModRef;
215
216for (constauto &AA : AAs) {
217 Result &= AA->getModRefInfo(Call, Loc, AAQI);
218
219// Early-exit the moment we reach the bottom of the lattice.
220if (isNoModRef(Result))
221returnModRefInfo::NoModRef;
222 }
223
224// Try to refine the mod-ref info further using other API entry points to the
225// aggregate set of AA results.
226
227// We can completely ignore inaccessible memory here, because MemoryLocations
228// can only reference accessible memory.
229auto ME =getMemoryEffects(Call, AAQI)
230 .getWithoutLoc(IRMemLocation::InaccessibleMem);
231if (ME.doesNotAccessMemory())
232returnModRefInfo::NoModRef;
233
234ModRefInfo ArgMR = ME.getModRef(IRMemLocation::ArgMem);
235ModRefInfo OtherMR = ME.getWithoutLoc(IRMemLocation::ArgMem).getModRef();
236if ((ArgMR | OtherMR) != OtherMR) {
237// Refine the modref info for argument memory. We only bother to do this
238// if ArgMR is not a subset of OtherMR, otherwise this won't have an impact
239// on the final result.
240ModRefInfo AllArgsMask =ModRefInfo::NoModRef;
241for (constauto &I :llvm::enumerate(Call->args())) {
242constValue *Arg =I.value();
243if (!Arg->getType()->isPointerTy())
244continue;
245unsigned ArgIdx =I.index();
246MemoryLocation ArgLoc =MemoryLocation::getForArgument(Call, ArgIdx, TLI);
247AliasResult ArgAlias =alias(ArgLoc, Loc, AAQI, Call);
248if (ArgAlias !=AliasResult::NoAlias)
249 AllArgsMask |=getArgModRefInfo(Call, ArgIdx);
250 }
251 ArgMR &= AllArgsMask;
252 }
253
254 Result &= ArgMR | OtherMR;
255
256// Apply the ModRef mask. This ensures that if Loc is a constant memory
257// location, we take into account the fact that the call definitely could not
258// modify the memory location.
259if (!isNoModRef(Result))
260 Result &=getModRefInfoMask(Loc);
261
262return Result;
263}
264
265ModRefInfoAAResults::getModRefInfo(constCallBase *Call1,
266constCallBase *Call2,AAQueryInfo &AAQI) {
267ModRefInfo Result =ModRefInfo::ModRef;
268
269for (constauto &AA : AAs) {
270 Result &= AA->getModRefInfo(Call1, Call2, AAQI);
271
272// Early-exit the moment we reach the bottom of the lattice.
273if (isNoModRef(Result))
274returnModRefInfo::NoModRef;
275 }
276
277// Try to refine the mod-ref info further using other API entry points to the
278// aggregate set of AA results.
279
280// If Call1 or Call2 are readnone, they don't interact.
281auto Call1B =getMemoryEffects(Call1, AAQI);
282if (Call1B.doesNotAccessMemory())
283returnModRefInfo::NoModRef;
284
285auto Call2B =getMemoryEffects(Call2, AAQI);
286if (Call2B.doesNotAccessMemory())
287returnModRefInfo::NoModRef;
288
289// If they both only read from memory, there is no dependence.
290if (Call1B.onlyReadsMemory() && Call2B.onlyReadsMemory())
291returnModRefInfo::NoModRef;
292
293// If Call1 only reads memory, the only dependence on Call2 can be
294// from Call1 reading memory written by Call2.
295if (Call1B.onlyReadsMemory())
296 Result &=ModRefInfo::Ref;
297elseif (Call1B.onlyWritesMemory())
298 Result &=ModRefInfo::Mod;
299
300// If Call2 only access memory through arguments, accumulate the mod/ref
301// information from Call1's references to the memory referenced by
302// Call2's arguments.
303if (Call2B.onlyAccessesArgPointees()) {
304if (!Call2B.doesAccessArgPointees())
305returnModRefInfo::NoModRef;
306ModRefInfo R =ModRefInfo::NoModRef;
307for (autoI = Call2->arg_begin(), E = Call2->arg_end();I != E; ++I) {
308constValue *Arg = *I;
309if (!Arg->getType()->isPointerTy())
310continue;
311unsigned Call2ArgIdx = std::distance(Call2->arg_begin(),I);
312auto Call2ArgLoc =
313MemoryLocation::getForArgument(Call2, Call2ArgIdx, TLI);
314
315// ArgModRefC2 indicates what Call2 might do to Call2ArgLoc, and the
316// dependence of Call1 on that location is the inverse:
317// - If Call2 modifies location, dependence exists if Call1 reads or
318// writes.
319// - If Call2 only reads location, dependence exists if Call1 writes.
320ModRefInfo ArgModRefC2 =getArgModRefInfo(Call2, Call2ArgIdx);
321ModRefInfo ArgMask =ModRefInfo::NoModRef;
322if (isModSet(ArgModRefC2))
323 ArgMask =ModRefInfo::ModRef;
324elseif (isRefSet(ArgModRefC2))
325 ArgMask =ModRefInfo::Mod;
326
327// ModRefC1 indicates what Call1 might do to Call2ArgLoc, and we use
328// above ArgMask to update dependence info.
329 ArgMask &=getModRefInfo(Call1, Call2ArgLoc, AAQI);
330
331 R = (R | ArgMask) & Result;
332if (R == Result)
333break;
334 }
335
336return R;
337 }
338
339// If Call1 only accesses memory through arguments, check if Call2 references
340// any of the memory referenced by Call1's arguments. If not, return NoModRef.
341if (Call1B.onlyAccessesArgPointees()) {
342if (!Call1B.doesAccessArgPointees())
343returnModRefInfo::NoModRef;
344ModRefInfo R =ModRefInfo::NoModRef;
345for (autoI = Call1->arg_begin(), E = Call1->arg_end();I != E; ++I) {
346constValue *Arg = *I;
347if (!Arg->getType()->isPointerTy())
348continue;
349unsigned Call1ArgIdx = std::distance(Call1->arg_begin(),I);
350auto Call1ArgLoc =
351MemoryLocation::getForArgument(Call1, Call1ArgIdx, TLI);
352
353// ArgModRefC1 indicates what Call1 might do to Call1ArgLoc; if Call1
354// might Mod Call1ArgLoc, then we care about either a Mod or a Ref by
355// Call2. If Call1 might Ref, then we care only about a Mod by Call2.
356ModRefInfo ArgModRefC1 =getArgModRefInfo(Call1, Call1ArgIdx);
357ModRefInfo ModRefC2 =getModRefInfo(Call2, Call1ArgLoc, AAQI);
358if ((isModSet(ArgModRefC1) &&isModOrRefSet(ModRefC2)) ||
359 (isRefSet(ArgModRefC1) &&isModSet(ModRefC2)))
360 R = (R | ArgModRefC1) & Result;
361
362if (R == Result)
363break;
364 }
365
366return R;
367 }
368
369return Result;
370}
371
372MemoryEffectsAAResults::getMemoryEffects(constCallBase *Call,
373AAQueryInfo &AAQI) {
374MemoryEffects Result =MemoryEffects::unknown();
375
376for (constauto &AA : AAs) {
377 Result &= AA->getMemoryEffects(Call, AAQI);
378
379// Early-exit the moment we reach the bottom of the lattice.
380if (Result.doesNotAccessMemory())
381return Result;
382 }
383
384return Result;
385}
386
387MemoryEffectsAAResults::getMemoryEffects(constCallBase *Call) {
388SimpleAAQueryInfo AAQI(*this);
389returngetMemoryEffects(Call, AAQI);
390}
391
392MemoryEffectsAAResults::getMemoryEffects(constFunction *F) {
393MemoryEffects Result =MemoryEffects::unknown();
394
395for (constauto &AA : AAs) {
396 Result &= AA->getMemoryEffects(F);
397
398// Early-exit the moment we reach the bottom of the lattice.
399if (Result.doesNotAccessMemory())
400return Result;
401 }
402
403return Result;
404}
405
406raw_ostream &llvm::operator<<(raw_ostream &OS,AliasResult AR) {
407switch (AR) {
408caseAliasResult::NoAlias:
409OS <<"NoAlias";
410break;
411caseAliasResult::MustAlias:
412OS <<"MustAlias";
413break;
414caseAliasResult::MayAlias:
415OS <<"MayAlias";
416break;
417caseAliasResult::PartialAlias:
418OS <<"PartialAlias";
419if (AR.hasOffset())
420OS <<" (off " << AR.getOffset() <<")";
421break;
422 }
423returnOS;
424}
425
426//===----------------------------------------------------------------------===//
427// Helper method implementation
428//===----------------------------------------------------------------------===//
429
430ModRefInfoAAResults::getModRefInfo(constLoadInst *L,
431constMemoryLocation &Loc,
432AAQueryInfo &AAQI) {
433// Be conservative in the face of atomic.
434if (isStrongerThan(L->getOrdering(),AtomicOrdering::Unordered))
435returnModRefInfo::ModRef;
436
437// If the load address doesn't alias the given address, it doesn't read
438// or write the specified memory.
439if (Loc.Ptr) {
440AliasResult AR =alias(MemoryLocation::get(L), Loc, AAQI, L);
441if (AR ==AliasResult::NoAlias)
442returnModRefInfo::NoModRef;
443 }
444// Otherwise, a load just reads.
445returnModRefInfo::Ref;
446}
447
448ModRefInfoAAResults::getModRefInfo(constStoreInst *S,
449constMemoryLocation &Loc,
450AAQueryInfo &AAQI) {
451// Be conservative in the face of atomic.
452if (isStrongerThan(S->getOrdering(),AtomicOrdering::Unordered))
453returnModRefInfo::ModRef;
454
455if (Loc.Ptr) {
456AliasResult AR =alias(MemoryLocation::get(S), Loc, AAQI, S);
457// If the store address cannot alias the pointer in question, then the
458// specified memory cannot be modified by the store.
459if (AR ==AliasResult::NoAlias)
460returnModRefInfo::NoModRef;
461
462// Examine the ModRef mask. If Mod isn't present, then return NoModRef.
463// This ensures that if Loc is a constant memory location, we take into
464// account the fact that the store definitely could not modify the memory
465// location.
466if (!isModSet(getModRefInfoMask(Loc)))
467returnModRefInfo::NoModRef;
468 }
469
470// Otherwise, a store just writes.
471returnModRefInfo::Mod;
472}
473
474ModRefInfoAAResults::getModRefInfo(constFenceInst *S,
475constMemoryLocation &Loc,
476AAQueryInfo &AAQI) {
477// All we know about a fence instruction is what we get from the ModRef
478// mask: if Loc is a constant memory location, the fence definitely could
479// not modify it.
480if (Loc.Ptr)
481returngetModRefInfoMask(Loc);
482returnModRefInfo::ModRef;
483}
484
485ModRefInfoAAResults::getModRefInfo(constVAArgInst *V,
486constMemoryLocation &Loc,
487AAQueryInfo &AAQI) {
488if (Loc.Ptr) {
489AliasResult AR =alias(MemoryLocation::get(V), Loc, AAQI, V);
490// If the va_arg address cannot alias the pointer in question, then the
491// specified memory cannot be accessed by the va_arg.
492if (AR ==AliasResult::NoAlias)
493returnModRefInfo::NoModRef;
494
495// If the pointer is a pointer to invariant memory, then it could not have
496// been modified by this va_arg.
497returngetModRefInfoMask(Loc, AAQI);
498 }
499
500// Otherwise, a va_arg reads and writes.
501returnModRefInfo::ModRef;
502}
503
504ModRefInfoAAResults::getModRefInfo(constCatchPadInst *CatchPad,
505constMemoryLocation &Loc,
506AAQueryInfo &AAQI) {
507if (Loc.Ptr) {
508// If the pointer is a pointer to invariant memory,
509// then it could not have been modified by this catchpad.
510returngetModRefInfoMask(Loc, AAQI);
511 }
512
513// Otherwise, a catchpad reads and writes.
514returnModRefInfo::ModRef;
515}
516
517ModRefInfoAAResults::getModRefInfo(constCatchReturnInst *CatchRet,
518constMemoryLocation &Loc,
519AAQueryInfo &AAQI) {
520if (Loc.Ptr) {
521// If the pointer is a pointer to invariant memory,
522// then it could not have been modified by this catchpad.
523returngetModRefInfoMask(Loc, AAQI);
524 }
525
526// Otherwise, a catchret reads and writes.
527returnModRefInfo::ModRef;
528}
529
530ModRefInfoAAResults::getModRefInfo(constAtomicCmpXchgInst *CX,
531constMemoryLocation &Loc,
532AAQueryInfo &AAQI) {
533// Acquire/Release cmpxchg has properties that matter for arbitrary addresses.
534if (isStrongerThanMonotonic(CX->getSuccessOrdering()))
535returnModRefInfo::ModRef;
536
537if (Loc.Ptr) {
538AliasResult AR =alias(MemoryLocation::get(CX), Loc, AAQI, CX);
539// If the cmpxchg address does not alias the location, it does not access
540// it.
541if (AR ==AliasResult::NoAlias)
542returnModRefInfo::NoModRef;
543 }
544
545returnModRefInfo::ModRef;
546}
547
548ModRefInfoAAResults::getModRefInfo(constAtomicRMWInst *RMW,
549constMemoryLocation &Loc,
550AAQueryInfo &AAQI) {
551// Acquire/Release atomicrmw has properties that matter for arbitrary addresses.
552if (isStrongerThanMonotonic(RMW->getOrdering()))
553returnModRefInfo::ModRef;
554
555if (Loc.Ptr) {
556AliasResult AR =alias(MemoryLocation::get(RMW), Loc, AAQI, RMW);
557// If the atomicrmw address does not alias the location, it does not access
558// it.
559if (AR ==AliasResult::NoAlias)
560returnModRefInfo::NoModRef;
561 }
562
563returnModRefInfo::ModRef;
564}
565
566ModRefInfoAAResults::getModRefInfo(constInstruction *I,
567const std::optional<MemoryLocation> &OptLoc,
568AAQueryInfo &AAQIP) {
569if (OptLoc == std::nullopt) {
570if (constauto *Call = dyn_cast<CallBase>(I))
571returngetMemoryEffects(Call, AAQIP).getModRef();
572 }
573
574constMemoryLocation &Loc = OptLoc.value_or(MemoryLocation());
575
576switch (I->getOpcode()) {
577case Instruction::VAArg:
578returngetModRefInfo((constVAArgInst *)I, Loc, AAQIP);
579case Instruction::Load:
580returngetModRefInfo((constLoadInst *)I, Loc, AAQIP);
581case Instruction::Store:
582returngetModRefInfo((constStoreInst *)I, Loc, AAQIP);
583case Instruction::Fence:
584returngetModRefInfo((constFenceInst *)I, Loc, AAQIP);
585case Instruction::AtomicCmpXchg:
586returngetModRefInfo((constAtomicCmpXchgInst *)I, Loc, AAQIP);
587case Instruction::AtomicRMW:
588returngetModRefInfo((constAtomicRMWInst *)I, Loc, AAQIP);
589case Instruction::Call:
590case Instruction::CallBr:
591case Instruction::Invoke:
592returngetModRefInfo((constCallBase *)I, Loc, AAQIP);
593case Instruction::CatchPad:
594returngetModRefInfo((constCatchPadInst *)I, Loc, AAQIP);
595case Instruction::CatchRet:
596returngetModRefInfo((constCatchReturnInst *)I, Loc, AAQIP);
597default:
598assert(!I->mayReadOrWriteMemory() &&
599"Unhandled memory access instruction!");
600returnModRefInfo::NoModRef;
601 }
602}
603
604/// Return information about whether a particular call site modifies
605/// or reads the specified memory location \p MemLoc before instruction \p I
606/// in a BasicBlock.
607/// FIXME: this is really just shoring-up a deficiency in alias analysis.
608/// BasicAA isn't willing to spend linear time determining whether an alloca
609/// was captured before or after this particular call, while we are. However,
610/// with a smarter AA in place, this test is just wasting compile time.
611ModRefInfoAAResults::callCapturesBefore(constInstruction *I,
612constMemoryLocation &MemLoc,
613DominatorTree *DT,
614AAQueryInfo &AAQI) {
615if (!DT)
616returnModRefInfo::ModRef;
617
618constValue *Object =getUnderlyingObject(MemLoc.Ptr);
619if (!isIdentifiedFunctionLocal(Object))
620returnModRefInfo::ModRef;
621
622constauto *Call = dyn_cast<CallBase>(I);
623if (!Call || Call == Object)
624returnModRefInfo::ModRef;
625
626if (PointerMayBeCapturedBefore(Object,/* ReturnCaptures */true,
627/* StoreCaptures */true,I, DT,
628/* include Object */true))
629returnModRefInfo::ModRef;
630
631unsigned ArgNo = 0;
632ModRefInfo R =ModRefInfo::NoModRef;
633// Set flag only if no May found and all operands processed.
634for (auto CI = Call->data_operands_begin(), CE = Call->data_operands_end();
635 CI != CE; ++CI, ++ArgNo) {
636// Only look at the no-capture or byval pointer arguments. If this
637// pointer were passed to arguments that were neither of these, then it
638// couldn't be no-capture.
639if (!(*CI)->getType()->isPointerTy() || !Call->doesNotCapture(ArgNo))
640continue;
641
642AliasResult AR =
643alias(MemoryLocation::getBeforeOrAfter(*CI),
644MemoryLocation::getBeforeOrAfter(Object), AAQI, Call);
645// If this is a no-capture pointer argument, see if we can tell that it
646// is impossible to alias the pointer we're checking. If not, we have to
647// assume that the call could touch the pointer, even though it doesn't
648// escape.
649if (AR ==AliasResult::NoAlias)
650continue;
651if (Call->doesNotAccessMemory(ArgNo))
652continue;
653if (Call->onlyReadsMemory(ArgNo)) {
654 R =ModRefInfo::Ref;
655continue;
656 }
657returnModRefInfo::ModRef;
658 }
659return R;
660}
661
662/// canBasicBlockModify - Return true if it is possible for execution of the
663/// specified basic block to modify the location Loc.
664///
665boolAAResults::canBasicBlockModify(constBasicBlock &BB,
666constMemoryLocation &Loc) {
667returncanInstructionRangeModRef(BB.front(), BB.back(), Loc,ModRefInfo::Mod);
668}
669
670/// canInstructionRangeModRef - Return true if it is possible for the
671/// execution of the specified instructions to mod\ref (according to the
672/// mode) the location Loc. The instructions to consider are all
673/// of the instructions in the range of [I1,I2] INCLUSIVE.
674/// I1 and I2 must be in the same basic block.
675boolAAResults::canInstructionRangeModRef(constInstruction &I1,
676constInstruction &I2,
677constMemoryLocation &Loc,
678constModRefInfo Mode) {
679assert(I1.getParent() == I2.getParent() &&
680"Instructions not in same basic block!");
681BasicBlock::const_iteratorI = I1.getIterator();
682BasicBlock::const_iterator E = I2.getIterator();
683 ++E;// Convert from inclusive to exclusive range.
684
685for (;I != E; ++I)// Check every instruction in range
686if (isModOrRefSet(getModRefInfo(&*I, Loc) & Mode))
687returntrue;
688returnfalse;
689}
690
691// Provide a definition for the root virtual destructor.
692AAResults::Concept::~Concept() =default;
693
694// Provide a definition for the static object used to identify passes.
695AnalysisKey AAManager::Key;
696
697ExternalAAWrapperPass::ExternalAAWrapperPass() :ImmutablePass(ID) {
698initializeExternalAAWrapperPassPass(*PassRegistry::getPassRegistry());
699}
700
701ExternalAAWrapperPass::ExternalAAWrapperPass(CallbackT CB)
702 :ImmutablePass(ID), CB(std::move(CB)) {
703initializeExternalAAWrapperPassPass(*PassRegistry::getPassRegistry());
704}
705
706charExternalAAWrapperPass::ID = 0;
707
708INITIALIZE_PASS(ExternalAAWrapperPass,"external-aa","External Alias Analysis",
709false,true)
710
711ImmutablePass *
712llvm::createExternalAAWrapperPass(ExternalAAWrapperPass::CallbackT Callback) {
713returnnewExternalAAWrapperPass(std::move(Callback));
714}
715
716AAResultsWrapperPass::AAResultsWrapperPass() :FunctionPass(ID) {
717initializeAAResultsWrapperPassPass(*PassRegistry::getPassRegistry());
718}
719
720charAAResultsWrapperPass::ID = 0;
721
722INITIALIZE_PASS_BEGIN(AAResultsWrapperPass,"aa",
723"Function Alias Analysis Results",false,true)
724INITIALIZE_PASS_DEPENDENCY(BasicAAWrapperPass)
725INITIALIZE_PASS_DEPENDENCY(ExternalAAWrapperPass)
726INITIALIZE_PASS_DEPENDENCY(GlobalsAAWrapperPass)
727INITIALIZE_PASS_DEPENDENCY(SCEVAAWrapperPass)
728INITIALIZE_PASS_DEPENDENCY(ScopedNoAliasAAWrapperPass)
729INITIALIZE_PASS_DEPENDENCY(TypeBasedAAWrapperPass)
730INITIALIZE_PASS_END(AAResultsWrapperPass, "aa",
731 "Function AliasAnalysisResults",false,true)
732
733/// Run the wrapper pass to rebuild an aggregation over known AA passes.
734///
735/// This is the legacy pass manager's interface to the new-style AA results
736/// aggregation object. Because this is somewhat shoe-horned into the legacy
737/// pass manager, we hard code all the specific alias analyses available into
738/// it. While the particular set enabled is configured via commandline flags,
739/// adding a new alias analysis to LLVM will require adding support for it to
740/// this list.
741boolAAResultsWrapperPass::runOnFunction(Function &F) {
742// NB! This *must* be reset before adding new AA results to the new
743// AAResults object because in the legacy pass manager, each instance
744// of these will refer to the *same* immutable analyses, registering and
745// unregistering themselves with them. We need to carefully tear down the
746// previous object first, in this case replacing it with an empty one, before
747// registering new results.
748 AAR.reset(
749newAAResults(getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F)));
750
751// BasicAA is always available for function analyses. Also, we add it first
752// so that it can trump TBAA results when it proves MustAlias.
753// FIXME: TBAA should have an explicit mode to support this and then we
754// should reconsider the ordering here.
755if (!DisableBasicAA)
756 AAR->addAAResult(getAnalysis<BasicAAWrapperPass>().getResult());
757
758// Populate the results with the currently available AAs.
759if (auto *WrapperPass = getAnalysisIfAvailable<ScopedNoAliasAAWrapperPass>())
760 AAR->addAAResult(WrapperPass->getResult());
761if (auto *WrapperPass = getAnalysisIfAvailable<TypeBasedAAWrapperPass>())
762 AAR->addAAResult(WrapperPass->getResult());
763if (auto *WrapperPass = getAnalysisIfAvailable<GlobalsAAWrapperPass>())
764 AAR->addAAResult(WrapperPass->getResult());
765if (auto *WrapperPass = getAnalysisIfAvailable<SCEVAAWrapperPass>())
766 AAR->addAAResult(WrapperPass->getResult());
767
768// If available, run an external AA providing callback over the results as
769// well.
770if (auto *WrapperPass = getAnalysisIfAvailable<ExternalAAWrapperPass>())
771if (WrapperPass->CB)
772 WrapperPass->CB(*this,F, *AAR);
773
774// Analyses don't mutate the IR, so return false.
775returnfalse;
776}
777
778voidAAResultsWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const{
779 AU.setPreservesAll();
780 AU.addRequiredTransitive<BasicAAWrapperPass>();
781 AU.addRequiredTransitive<TargetLibraryInfoWrapperPass>();
782
783// We also need to mark all the alias analysis passes we will potentially
784// probe in runOnFunction as used here to ensure the legacy pass manager
785// preserves them. This hard coding of lists of alias analyses is specific to
786// the legacy pass manager.
787 AU.addUsedIfAvailable<ScopedNoAliasAAWrapperPass>();
788 AU.addUsedIfAvailable<TypeBasedAAWrapperPass>();
789 AU.addUsedIfAvailable<GlobalsAAWrapperPass>();
790 AU.addUsedIfAvailable<SCEVAAWrapperPass>();
791 AU.addUsedIfAvailable<ExternalAAWrapperPass>();
792}
793
794AAManager::ResultAAManager::run(Function &F,FunctionAnalysisManager &AM) {
795Result R(AM.getResult<TargetLibraryAnalysis>(F));
796for (auto &Getter : ResultGetters)
797 (*Getter)(F, AM, R);
798return R;
799}
800
801boolllvm::isNoAliasCall(constValue *V) {
802if (constauto *Call = dyn_cast<CallBase>(V))
803return Call->hasRetAttr(Attribute::NoAlias);
804returnfalse;
805}
806
807staticboolisNoAliasOrByValArgument(constValue *V) {
808if (constArgument *A = dyn_cast<Argument>(V))
809returnA->hasNoAliasAttr() ||A->hasByValAttr();
810returnfalse;
811}
812
813boolllvm::isIdentifiedObject(constValue *V) {
814if (isa<AllocaInst>(V))
815returntrue;
816if (isa<GlobalValue>(V) && !isa<GlobalAlias>(V))
817returntrue;
818if (isNoAliasCall(V))
819returntrue;
820if (isNoAliasOrByValArgument(V))
821returntrue;
822returnfalse;
823}
824
825boolllvm::isIdentifiedFunctionLocal(constValue *V) {
826return isa<AllocaInst>(V) ||isNoAliasCall(V) ||isNoAliasOrByValArgument(V);
827}
828
829boolllvm::isBaseOfObject(constValue *V) {
830// TODO: We can handle other cases here
831// 1) For GC languages, arguments to functions are often required to be
832// base pointers.
833// 2) Result of allocation routines are often base pointers. Leverage TLI.
834return (isa<AllocaInst>(V) || isa<GlobalVariable>(V));
835}
836
837boolllvm::isEscapeSource(constValue *V) {
838if (auto *CB = dyn_cast<CallBase>(V))
839return !isIntrinsicReturningPointerAliasingArgumentWithoutCapturing(CB,
840true);
841
842// The load case works because isNonEscapingLocalObject considers all
843// stores to be escapes (it passes true for the StoreCaptures argument
844// to PointerMayBeCaptured).
845if (isa<LoadInst>(V))
846returntrue;
847
848// The inttoptr case works because isNonEscapingLocalObject considers all
849// means of converting or equating a pointer to an int (ptrtoint, ptr store
850// which could be followed by an integer load, ptr<->int compare) as
851// escaping, and objects located at well-known addresses via platform-specific
852// means cannot be considered non-escaping local objects.
853if (isa<IntToPtrInst>(V))
854returntrue;
855
856// Same for inttoptr constant expressions.
857if (auto *CE = dyn_cast<ConstantExpr>(V))
858if (CE->getOpcode() == Instruction::IntToPtr)
859returntrue;
860
861returnfalse;
862}
863
864boolllvm::isNotVisibleOnUnwind(constValue *Object,
865bool &RequiresNoCaptureBeforeUnwind) {
866 RequiresNoCaptureBeforeUnwind =false;
867
868// Alloca goes out of scope on unwind.
869if (isa<AllocaInst>(Object))
870returntrue;
871
872// Byval goes out of scope on unwind.
873if (auto *A = dyn_cast<Argument>(Object))
874returnA->hasByValAttr() ||A->hasAttribute(Attribute::DeadOnUnwind);
875
876// A noalias return is not accessible from any other code. If the pointer
877// does not escape prior to the unwind, then the caller cannot access the
878// memory either.
879if (isNoAliasCall(Object)) {
880 RequiresNoCaptureBeforeUnwind =true;
881returntrue;
882 }
883
884returnfalse;
885}
886
887// We don't consider globals as writable: While the physical memory is writable,
888// we may not have provenance to perform the write.
889boolllvm::isWritableObject(constValue *Object,
890bool &ExplicitlyDereferenceableOnly) {
891 ExplicitlyDereferenceableOnly =false;
892
893// TODO: Alloca might not be writable after its lifetime ends.
894// See https://github.com/llvm/llvm-project/issues/51838.
895if (isa<AllocaInst>(Object))
896returntrue;
897
898if (auto *A = dyn_cast<Argument>(Object)) {
899// Also require noalias, otherwise writability at function entry cannot be
900// generalized to writability at other program points, even if the pointer
901// does not escape.
902if (A->hasAttribute(Attribute::Writable) &&A->hasNoAliasAttr()) {
903 ExplicitlyDereferenceableOnly =true;
904returntrue;
905 }
906
907returnA->hasByValAttr();
908 }
909
910// TODO: Noalias shouldn't imply writability, this should check for an
911// allocator function instead.
912returnisNoAliasCall(Object);
913}
EnableAATrace
static cl::opt< bool > EnableAATrace("aa-trace", cl::Hidden, cl::init(false))
Print a trace of alias analysis queries and their results.
isNoAliasOrByValArgument
static bool isNoAliasOrByValArgument(const Value *V)
Definition:AliasAnalysis.cpp:807
aa
aa
Definition:AliasAnalysis.cpp:730
Results
Function Alias Analysis Results
Definition:AliasAnalysis.cpp:731
AliasAnalysis.h
AtomicOrdering.h
Atomic ordering constants.
Attributes.h
This file contains the simple types necessary to represent the attributes associated with functions a...
true
basic Basic Alias true
Definition:BasicAliasAnalysis.cpp:1981
BasicAliasAnalysis.h
This is the interface for LLVM's primary stateless and local alias analysis.
Analysis
block Block Frequency Analysis
Definition:BlockFrequencyInfo.cpp:300
A
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
CaptureTracking.h
Casting.h
CommandLine.h
runOnFunction
static bool runOnFunction(Function &F, bool PostInlining)
Definition:EntryExitInstrumenter.cpp:98
GlobalsModRef.h
This is the interface for a simple mod/ref and alias analysis over globals.
Argument.h
BasicBlock.h
Instruction.h
Type.h
Value.h
InitializePasses.h
Instructions.h
F
#define F(x, y, z)
Definition:MD5.cpp:55
I
#define I(x, y, z)
Definition:MD5.cpp:58
MemoryLocation.h
This file provides utility analysis objects describing memory locations.
INITIALIZE_PASS_DEPENDENCY
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition:PassSupport.h:55
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition:PassSupport.h:57
INITIALIZE_PASS_BEGIN
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition:PassSupport.h:52
INITIALIZE_PASS
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition:PassSupport.h:38
Pass.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OS
raw_pwrite_stream & OS
Definition:SampleProfWriter.cpp:51
ScalarEvolutionAliasAnalysis.h
This is the interface for a SCEV-based alias analysis.
ScopedNoAliasAA.h
This is the interface for a metadata-based scoped no-alias analysis.
Statistic.h
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
STATISTIC
#define STATISTIC(VARNAME, DESC)
Definition:Statistic.h:166
TargetLibraryInfo.h
TypeBasedAliasAnalysis.h
This is the interface for a metadata-based TBAA.
ValueTracking.h
llvm::AAManager
A manager for alias analyses.
Definition:AliasAnalysis.h:933
llvm::AAManager::run
Result run(Function &F, FunctionAnalysisManager &AM)
Definition:AliasAnalysis.cpp:794
llvm::AAQueryInfo
This class stores info we want to provide to or retain within an alias query.
Definition:AliasAnalysis.h:238
llvm::AAQueryInfo::Depth
unsigned Depth
Query depth used to distinguish recursive queries.
Definition:AliasAnalysis.h:271
llvm::AAResultsWrapperPass
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
Definition:AliasAnalysis.h:981
llvm::AAResultsWrapperPass::ID
static char ID
Definition:AliasAnalysis.h:985
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:778
llvm::AAResultsWrapperPass::AAResultsWrapperPass
AAResultsWrapperPass()
Definition:AliasAnalysis.cpp:716
llvm::AAResults::Concept::~Concept
virtual ~Concept()=0
llvm::AAResults
Definition:AliasAnalysis.h:314
llvm::AAResults::getModRefInfo
ModRefInfo getModRefInfo(const Instruction *I, const std::optional< MemoryLocation > &OptLoc)
Check whether or not an instruction may read or write the optionally specified memory location.
Definition:AliasAnalysis.h:508
llvm::AAResults::alias
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
The main low level interface to the alias analysis implementation.
Definition:AliasAnalysis.cpp:105
llvm::AAResults::getModRefInfoMask
ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, bool IgnoreLocals=false)
Returns a bitmask that should be unconditionally applied to the ModRef info of a memory location.
Definition:AliasAnalysis.cpp:149
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:527
llvm::AAResults::AAResults
AAResults(const TargetLibraryInfo &TLI)
Definition:AliasAnalysis.cpp:74
llvm::AAResults::getMemoryEffects
MemoryEffects getMemoryEffects(const CallBase *Call)
Return the behavior of the given call site.
Definition:AliasAnalysis.cpp:387
llvm::AAResults::invalidate
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)
Handle invalidation events in the new pass manager.
Definition:AliasAnalysis.cpp:81
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:170
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:675
llvm::AAResults::~AAResults
~AAResults()
Definition:AliasAnalysis.cpp:79
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:665
llvm::AliasResult
The possible results of an alias query.
Definition:AliasAnalysis.h:77
llvm::AliasResult::MayAlias
@ MayAlias
The two locations may or may not alias.
Definition:AliasAnalysis.h:98
llvm::AliasResult::NoAlias
@ NoAlias
The two locations do not alias at all.
Definition:AliasAnalysis.h:95
llvm::AliasResult::PartialAlias
@ PartialAlias
The two locations alias, but only due to a partial overlap.
Definition:AliasAnalysis.h:100
llvm::AliasResult::MustAlias
@ MustAlias
The two locations precisely alias each other.
Definition:AliasAnalysis.h:102
llvm::AliasResult::getOffset
constexpr int32_t getOffset() const
Definition:AliasAnalysis.h:123
llvm::AliasResult::hasOffset
constexpr bool hasOffset() const
Definition:AliasAnalysis.h:122
llvm::AnalysisManager::Invalidator
API to communicate dependencies between analyses during invalidation.
Definition:PassManager.h:292
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:310
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition:PassManager.h:253
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:410
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition:PassAnalysisSupport.h:47
llvm::AnalysisUsage::addUsedIfAvailable
AnalysisUsage & addUsedIfAvailable()
Add the specified Pass class to the set of analyses used by this pass.
Definition:PassAnalysisSupport.h:117
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition:PassAnalysisSupport.h:130
llvm::AnalysisUsage::addRequiredTransitive
AnalysisUsage & addRequiredTransitive()
Definition:PassAnalysisSupport.h:81
llvm::Argument
This class represents an incoming formal argument to a Function.
Definition:Argument.h:31
llvm::AtomicCmpXchgInst
An instruction that atomically checks whether a specified value is in a memory location,...
Definition:Instructions.h:501
llvm::AtomicCmpXchgInst::getSuccessOrdering
AtomicOrdering getSuccessOrdering() const
Returns the success ordering constraint of this cmpxchg instruction.
Definition:Instructions.h:582
llvm::AtomicRMWInst
an instruction that atomically reads a memory location, combines it with another value,...
Definition:Instructions.h:704
llvm::AtomicRMWInst::getOrdering
AtomicOrdering getOrdering() const
Returns the ordering constraint of this rmw instruction.
Definition:Instructions.h:847
llvm::BasicAAWrapperPass
Legacy wrapper pass to provide the BasicAAResult object.
Definition:BasicAliasAnalysis.h:164
llvm::BasicBlock
LLVM Basic Block Representation.
Definition:BasicBlock.h:61
llvm::BasicBlock::const_iterator
InstListType::const_iterator const_iterator
Definition:BasicBlock.h:178
llvm::BasicBlock::front
const Instruction & front() const
Definition:BasicBlock.h:474
llvm::BasicBlock::back
const Instruction & back() const
Definition:BasicBlock.h:476
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition:InstrTypes.h:1112
llvm::CallBase::arg_begin
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
Definition:InstrTypes.h:1261
llvm::CallBase::arg_end
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
Definition:InstrTypes.h:1267
llvm::CatchPadInst
Definition:Instructions.h:4250
llvm::CatchReturnInst
Definition:Instructions.h:4289
llvm::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition:Dominators.h:162
llvm::FenceInst
An instruction for ordering other memory operations.
Definition:Instructions.h:424
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition:Pass.h:310
llvm::Function
Definition:Function.h:63
llvm::GlobalsAAWrapperPass
Legacy wrapper pass to provide the GlobalsAAResult object.
Definition:GlobalsModRef.h:142
llvm::ImmutablePass
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition:Pass.h:281
llvm::Instruction
Definition:Instruction.h:68
llvm::LoadInst
An instruction for reading from memory.
Definition:Instructions.h:176
llvm::MemoryEffectsBase
Definition:ModRef.h:72
llvm::MemoryEffectsBase::getWithoutLoc
MemoryEffectsBase getWithoutLoc(Location Loc) const
Get new MemoryEffectsBase with NoModRef on the given Loc.
Definition:ModRef.h:177
llvm::MemoryEffectsBase::getModRef
ModRefInfo getModRef(Location Loc) const
Get ModRefInfo for the given Location.
Definition:ModRef.h:165
llvm::MemoryEffectsBase::unknown
static MemoryEffectsBase unknown()
Create MemoryEffectsBase that can read and write any memory.
Definition:ModRef.h:112
llvm::MemoryLocation
Representation for a specific memory location.
Definition:MemoryLocation.h:227
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::MemoryLocation::Size
LocationSize Size
The maximum size of the location, in address-units, or UnknownSize if the size is not known.
Definition:MemoryLocation.h:244
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:295
llvm::MemoryLocation::Ptr
const Value * Ptr
The address of the start of the location.
Definition:MemoryLocation.h:235
llvm::MemoryLocation::getForArgument
static MemoryLocation getForArgument(const CallBase *Call, unsigned ArgIdx, const TargetLibraryInfo *TLI)
Return a location representing a particular argument of a call.
Definition:MemoryLocation.cpp:159
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition:PassRegistry.cpp:24
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition:Analysis.h:111
llvm::PreservedAnalyses::getChecker
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
Definition:Analysis.h:264
llvm::SCEVAAWrapperPass
Legacy wrapper pass to provide the SCEVAAResult object.
Definition:ScalarEvolutionAliasAnalysis.h:56
llvm::ScopedNoAliasAAWrapperPass
Legacy wrapper pass to provide the ScopedNoAliasAAResult object.
Definition:ScopedNoAliasAA.h:63
llvm::SimpleAAQueryInfo
AAQueryInfo that uses SimpleCaptureAnalysis.
Definition:AliasAnalysis.h:305
llvm::StoreInst
An instruction for storing to memory.
Definition:Instructions.h:292
llvm::StoreInst::getOrdering
AtomicOrdering getOrdering() const
Returns the ordering constraint of this store instruction.
Definition:Instructions.h:342
llvm::TargetLibraryAnalysis
Analysis pass providing the TargetLibraryInfo.
Definition:TargetLibraryInfo.h:614
llvm::TargetLibraryInfoWrapperPass
Definition:TargetLibraryInfo.h:639
llvm::TargetLibraryInfo
Provides information about what library functions are available for the current target.
Definition:TargetLibraryInfo.h:280
llvm::TypeBasedAAWrapperPass
Legacy wrapper pass to provide the TypeBasedAAResult object.
Definition:TypeBasedAliasAnalysis.h:82
llvm::Type::isPointerTy
bool isPointerTy() const
True if this is an instance of PointerType.
Definition:Type.h:264
llvm::VAArgInst
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
Definition:Instructions.h:1741
llvm::Value
LLVM Value Representation.
Definition:Value.h:74
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition:Value.h:255
llvm::cl::opt
Definition:CommandLine.h:1423
llvm::ilist_detail::node_parent_access::getParent
const ParentTy * getParent() const
Definition:ilist_node.h:32
llvm::ilist_node_impl::getIterator
self_iterator getIterator()
Definition:ilist_node.h:132
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition:raw_ostream.h:52
unsigned
false
Definition:StackSlotColoring.cpp:193
llvm::cl::Hidden
@ Hidden
Definition:CommandLine.h:137
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition:CommandLine.h:443
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::DisableBasicAA
cl::opt< bool > DisableBasicAA("disable-basic-aa", cl::Hidden, cl::init(false))
Allow disabling BasicAA from the AA results.
llvm::enumerate
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
Definition:STLExtras.h:2448
llvm::isStrongerThanMonotonic
bool isStrongerThanMonotonic(AtomicOrdering AO)
Definition:AtomicOrdering.h:125
llvm::isBaseOfObject
bool isBaseOfObject(const Value *V)
Return true if we know V to the base address of the corresponding memory object.
Definition:AliasAnalysis.cpp:829
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:237
llvm::getUnderlyingObject
const Value * getUnderlyingObject(const Value *V, unsigned MaxLookup=6)
This method strips off any GEP address adjustments, pointer casts or llvm.threadlocal....
Definition:ValueTracking.cpp:6768
llvm::isNoAliasCall
bool isNoAliasCall(const Value *V)
Return true if this pointer is returned by a noalias function.
Definition:AliasAnalysis.cpp:801
llvm::initializeAAResultsWrapperPassPass
void initializeAAResultsWrapperPassPass(PassRegistry &)
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:6712
llvm::isModSet
bool isModSet(const ModRefInfo MRI)
Definition:ModRef.h:48
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition:Debug.cpp:163
llvm::isModOrRefSet
bool isModOrRefSet(const ModRefInfo MRI)
Definition:ModRef.h:42
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:864
llvm::AtomicOrdering::Unordered
@ Unordered
llvm::ModRefInfo
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
Definition:ModRef.h:27
llvm::ModRefInfo::Ref
@ Ref
The access may reference the value stored in memory.
llvm::ModRefInfo::ModRef
@ ModRef
The access may reference and may modify the value stored in memory.
llvm::ModRefInfo::Mod
@ Mod
The access may modify the value stored in memory.
llvm::ModRefInfo::NoModRef
@ NoModRef
The access neither references nor modifies the value stored in memory.
llvm::IRMemLocation::ArgMem
@ ArgMem
Access to memory via argument pointers.
llvm::IRMemLocation::InaccessibleMem
@ InaccessibleMem
Memory that is inaccessible via LLVM IR.
llvm::operator<<
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition:APFixedPoint.h:303
llvm::isIdentifiedFunctionLocal
bool isIdentifiedFunctionLocal(const Value *V)
Return true if V is umabigously identified at the function-level.
Definition:AliasAnalysis.cpp:825
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:1873
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:837
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::initializeExternalAAWrapperPassPass
void initializeExternalAAWrapperPassPass(PassRegistry &)
llvm::isNoModRef
bool isNoModRef(const ModRefInfo MRI)
Definition:ModRef.h:39
llvm::isIdentifiedObject
bool isIdentifiedObject(const Value *V)
Return true if this pointer refers to a distinct and identifiable object.
Definition:AliasAnalysis.cpp:813
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:91
llvm::isRefSet
bool isRefSet(const ModRefInfo MRI)
Definition:ModRef.h:51
llvm::isWritableObject
bool isWritableObject(const Value *Object, bool &ExplicitlyDereferenceableOnly)
Return true if the Object is writable, in the sense that any location based on this pointer that can ...
Definition:AliasAnalysis.cpp:889
std
Implement std::hash so that hash_code can be used in STL containers.
Definition:BitVector.h:858
llvm::AnalysisKey
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition:Analysis.h:28
llvm::ExternalAAWrapperPass
A wrapper pass for external alias analyses.
Definition:AliasAnalysis.h:999
llvm::ExternalAAWrapperPass::CallbackT
std::function< void(Pass &, Function &, AAResults &)> CallbackT
Definition:AliasAnalysis.h:1000
llvm::ExternalAAWrapperPass::ExternalAAWrapperPass
ExternalAAWrapperPass()
Definition:AliasAnalysis.cpp:697
llvm::ExternalAAWrapperPass::ID
static char ID
Definition:AliasAnalysis.h:1004

Generated on Thu Jul 17 2025 10:43:22 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp