LLVM 23.0.0git
MemoryDependenceAnalysis.h
Go to the documentation of this file.
1//===- llvm/Analysis/MemoryDependenceAnalysis.h - Memory Deps ---*- C++ -*-===//
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 defines the MemoryDependenceAnalysis analysis pass.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
14#define LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
15
16#include "llvm/ADT/DenseMap.h"
24#include "llvm/IR/PassManager.h"
26#include "llvm/IR/ValueHandle.h"
27#include "llvm/Pass.h"
28#include <optional>
29
30namespace llvm {
31
32class AssumptionCache;
33class DominatorTree;
34class PHITransAddr;
35
36/// A memory dependence query can return one of three different answers.
37class MemDepResult {
38 enum DepType {
39 /// Clients of MemDep never see this.
40 ///
41 /// Entries with this marker occur in a LocalDeps map or NonLocalDeps map
42 /// when the instruction they previously referenced was removed from
43 /// MemDep. In either case, the entry may include an instruction pointer.
44 /// If so, the pointer is an instruction in the block where scanning can
45 /// start from, saving some work.
46 ///
47 /// In a default-constructed MemDepResult object, the type will be Invalid
48 /// and the instruction pointer will be null.
49 Invalid = 0,
50
51 /// This is a dependence on the specified instruction which clobbers the
52 /// desired value. The pointer member of the MemDepResult pair holds the
53 /// instruction that clobbers the memory. For example, this occurs when we
54 /// see a may-aliased store to the memory location we care about.
55 ///
56 /// There are several cases that may be interesting here:
57 /// 1. Loads are clobbered by may-alias stores.
58 /// 2. Loads are considered clobbered by partially-aliased loads. The
59 /// client may choose to analyze deeper into these cases.
60 Clobber,
61
62 /// This is a dependence on the specified instruction which defines or
63 /// produces the desired memory location. The pointer member of the
64 /// MemDepResult pair holds the instruction that defines the memory.
65 ///
66 /// Cases of interest:
67 /// 1. This could be a load or store for dependence queries on
68 /// load/store. The value loaded or stored is the produced value.
69 /// Note that the pointer operand may be different than that of the
70 /// queried pointer due to must aliases and phi translation. Note
71 /// that the def may not be the same type as the query, the pointers
72 /// may just be must aliases.
73 /// 2. For loads and stores, this could be an allocation instruction. In
74 /// this case, the load is loading an undef value or a store is the
75 /// first store to (that part of) the allocation.
76 /// 3. Dependence queries on calls return Def only when they are readonly
77 /// calls or memory use intrinsics with identical callees and no
78 /// intervening clobbers. No validation is done that the operands to
79 /// the calls are the same.
80 /// 4. For loads and stores, this could be a select instruction that
81 /// defines pointer to this memory location. In this case, users can
82 /// find non-clobbered Defs for both select values that are reaching
83 // the desired memory location (there is still a guarantee that there
84 // are no clobbers between analyzed memory location and select).
85 Def,
86
87 /// This marker indicates that the query has no known dependency in the
88 /// specified block.
89 ///
90 /// More detailed state info is encoded in the upper part of the pair (i.e.
91 /// the Instruction*)
92 Other
93 };
94
95 /// If DepType is "Other", the upper part of the sum type is an encoding of
96 /// the following more detailed type information.
97 enum OtherType {
98 /// This marker indicates that the query has no dependency in the specified
99 /// block.
100 ///
101 /// To find out more, the client should query other predecessor blocks.
102 NonLocal = 1,
103 /// This marker indicates that the query has no dependency in the specified
104 /// function.
105 NonFuncLocal,
106 /// This marker indicates that the query depends on a select instruction,
107 /// i.e. the address loaded is a select whose two sides each reach a
108 /// non-clobbered value (see the \p Def documentation, item 4).
109 Select,
110 /// This marker indicates that the query dependency is unknown.
111 Unknown
112 };
113
114 using ValueTy = PointerSumType<
119 ValueTy Value;
120
121 explicit MemDepResult(ValueTy V) : Value(V) {}
122
123public:
124 MemDepResult() = default;
125
126 /// get methods: These are static ctor methods for creating various
127 /// MemDepResult kinds.
128 static MemDepResult getDef(Instruction *Inst) {
129 assert(Inst && "Def requires inst");
131 }
132 static MemDepResult getClobber(Instruction *Inst) {
133 assert(Inst && "Clobber requires inst");
135 }
136 static MemDepResult getNonLocal() {
137 return MemDepResult(ValueTy::create<Other>(NonLocal));
138 }
139 static MemDepResult getNonFuncLocal() {
140 return MemDepResult(ValueTy::create<Other>(NonFuncLocal));
141 }
142 static MemDepResult getSelect() {
143 return MemDepResult(ValueTy::create<Other>(Select));
144 }
145 static MemDepResult getUnknown() {
146 return MemDepResult(ValueTy::create<Other>(Unknown));
147 }
148
149 /// Tests if this MemDepResult represents a query that is an instruction
150 /// clobber dependency.
151 bool isClobber() const { return Value.is<Clobber>(); }
152
153 /// Tests if this MemDepResult represents a query that is an instruction
154 /// definition dependency.
155 bool isDef() const { return Value.is<Def>(); }
156
157 /// Tests if this MemDepResult represents a valid local query (Clobber/Def).
158 bool isLocal() const { return isClobber() || isDef(); }
159
160 /// Tests if this MemDepResult represents a query that is transparent to the
161 /// start of the block, but where a non-local hasn't been done.
162 bool isNonLocal() const {
163 return Value.is<Other>() && Value.cast<Other>() == NonLocal;
164 }
165
166 /// Tests if this MemDepResult represents a query that is transparent to the
167 /// start of the function.
168 bool isNonFuncLocal() const {
169 return Value.is<Other>() && Value.cast<Other>() == NonFuncLocal;
170 }
171
172 /// Tests if this MemDepResult represents a query that depends on a select
173 /// instruction whose two sides each reach a non-clobbered value.
174 bool isSelect() const {
175 return Value.is<Other>() && Value.cast<Other>() == Select;
176 }
177
178 /// Tests if this MemDepResult represents a query which cannot and/or will
179 /// not be computed.
180 bool isUnknown() const {
181 return Value.is<Other>() && Value.cast<Other>() == Unknown;
182 }
183
184 /// If this is a normal dependency, returns the instruction that is depended
185 /// on. Otherwise, returns null.
187 switch (Value.getTag()) {
188 case Invalid:
189 return Value.cast<Invalid>();
190 case Clobber:
191 return Value.cast<Clobber>();
192 case Def:
193 return Value.cast<Def>();
194 case Other:
195 return nullptr;
196 }
197 llvm_unreachable("Unknown discriminant!");
198 }
199
200 bool operator==(const MemDepResult &M) const { return Value == M.Value; }
201 bool operator!=(const MemDepResult &M) const { return Value != M.Value; }
202 bool operator<(const MemDepResult &M) const { return Value < M.Value; }
203 bool operator>(const MemDepResult &M) const { return Value > M.Value; }
204
205private:
207
208 /// Tests if this is a MemDepResult in its dirty/invalid. state.
209 bool isDirty() const { return Value.is<Invalid>(); }
210
211 static MemDepResult getDirty(Instruction *Inst) {
213 }
214};
215
216/// This is an entry in the NonLocalDepInfo cache.
217///
218/// For each BasicBlock (the BB entry) it keeps a MemDepResult.
220 BasicBlock *BB;
221 MemDepResult Result;
222
223public:
225 : BB(BB), Result(Result) {}
226
227 // This is used for searches.
229
230 // BB is the sort key, it can't be changed.
231 BasicBlock *getBB() const { return BB; }
232
233 void setResult(const MemDepResult &R) { Result = R; }
234
235 const MemDepResult &getResult() const { return Result; }
236
237 bool operator<(const NonLocalDepEntry &RHS) const { return BB < RHS.BB; }
238};
239
240/// This is a result from a NonLocal dependence query.
241///
242/// For each BasicBlock (the BB entry) it keeps a MemDepResult and the
243/// (potentially phi translated) address that was live in the block.
245 NonLocalDepEntry Entry;
246 SelectAddr Address;
247
248public:
250 const SelectAddr &Address)
251 : Entry(BB, Result), Address(Address) {}
252
253 // BB is the sort key, it can't be changed.
254 BasicBlock *getBB() const { return Entry.getBB(); }
255
256 void setResult(const MemDepResult &R, const SelectAddr &Addr) {
257 Entry.setResult(R);
258 Address = Addr;
259 }
260
261 const MemDepResult &getResult() const { return Entry.getResult(); }
262
263 /// Returns the address of this pointer in this block.
264 ///
265 /// This can be different than the address queried for the non-local result
266 /// because of phi translation. This returns null if the address was not
267 /// available in a block (i.e. because phi translation failed) or if this is
268 /// a cached result and that address was deleted.
269 ///
270 /// The address is always null for a non-local 'call' dependence.
271 ///
272 /// If the result is a select dependency (\see MemDepResult::isSelect), the
273 /// returned SelectAddr instead carries the select condition and the two
274 /// translated addresses (true/false side).
275 SelectAddr getAddress() const { return Address; }
276};
277
278/// Provides a lazy, caching interface for making common memory aliasing
279/// information queries, backed by LLVM's alias analysis passes.
280///
281/// The dependency information returned is somewhat unusual, but is pragmatic.
282/// If queried about a store or call that might modify memory, the analysis
283/// will return the instruction[s] that may either load from that memory or
284/// store to it. If queried with a load or call that can never modify memory,
285/// the analysis will return calls and stores that might modify the pointer,
286/// but generally does not return loads unless a) they are volatile, or
287/// b) they load from *must-aliased* pointers. Returning a dependence on
288/// must-alias'd pointers instead of all pointers interacts well with the
289/// internal caching mechanism.
291 // A map from instructions to their dependency.
292 using LocalDepMapType = DenseMap<Instruction *, MemDepResult>;
293 LocalDepMapType LocalDeps;
294
295public:
296 using NonLocalDepInfo = std::vector<NonLocalDepEntry>;
297
298private:
299 /// A pair<Value*, bool> where the bool is true if the dependence is a read
300 /// only dependence, false if read/write.
301 using ValueIsLoadPair = PointerIntPair<const Value *, 1, bool>;
302
303 /// This pair is used when caching information for a block.
304 ///
305 /// If the pointer is null, the cache value is not a full query that starts
306 /// at the specified block. If non-null, the bool indicates whether or not
307 /// the contents of the block was skipped.
308 using BBSkipFirstBlockPair = PointerIntPair<BasicBlock *, 1, bool>;
309
310 /// This record is the information kept for each (value, is load) pair.
311 struct NonLocalPointerInfo {
312 /// The pair of the block and the skip-first-block flag.
313 BBSkipFirstBlockPair Pair;
314 /// The results of the query for each relevant block.
315 NonLocalDepInfo NonLocalDeps;
316 /// The maximum size of the dereferences of the pointer.
317 ///
318 /// May be UnknownSize if the sizes are unknown.
320 /// The AA tags associated with dereferences of the pointer.
321 ///
322 /// The members may be null if there are no tags or conflicting tags.
323 AAMDNodes AATags;
324
325 NonLocalPointerInfo() = default;
326 };
327
328 /// Cache storing single nonlocal def for the instruction.
329 /// It is set when nonlocal def would be found in function returning only
330 /// local dependencies.
332 using ReverseNonLocalDefsCacheTy =
334 ReverseNonLocalDefsCacheTy ReverseNonLocalDefsCache;
335
336 /// This map stores the cached results of doing a pointer lookup at the
337 /// bottom of a block.
338 ///
339 /// The key of this map is the pointer+isload bit, the value is a list of
340 /// <bb->result> mappings.
341 using CachedNonLocalPointerInfo =
343 CachedNonLocalPointerInfo NonLocalPointerDeps;
344
345 // A map from instructions to their non-local pointer dependencies.
346 using ReverseNonLocalPtrDepTy =
348 ReverseNonLocalPtrDepTy ReverseNonLocalPtrDeps;
349
350 /// This is the instruction we keep for each cached access that we have for
351 /// an instruction.
352 ///
353 /// The pointer is an owning pointer and the bool indicates whether we have
354 /// any dirty bits in the set.
355 using PerInstNLInfo = std::pair<NonLocalDepInfo, bool>;
356
357 // A map from instructions to their non-local dependencies.
358 using NonLocalDepMapType = DenseMap<Instruction *, PerInstNLInfo>;
359
360 NonLocalDepMapType NonLocalDepsMap;
361
362 // A reverse mapping from dependencies to the dependees. This is
363 // used when removing instructions to keep the cache coherent.
364 using ReverseDepMapType =
366 ReverseDepMapType ReverseLocalDeps;
367
368 // A reverse mapping from dependencies to the non-local dependees.
369 ReverseDepMapType ReverseNonLocalDeps;
370
371 /// Visited map for getNonLocalPointerDependency. Stored here to reuse the
372 /// allocation. Map from block number to Value; second value is epoch to
373 /// avoid clearing the vector for each query.
374 SmallVector<std::pair<Value *, unsigned>, 0> NonLocalPointerDepVisited;
375 unsigned NonLocalPointerDepEpoch = 0;
376
377 /// Current AA implementation, just a cache.
378 AAResults &AA;
379 AssumptionCache &AC;
380 const TargetLibraryInfo &TLI;
381 DominatorTree &DT;
382 PredIteratorCache PredCache;
384
385 unsigned DefaultBlockScanLimit;
386
387 /// Offsets to dependant clobber loads.
388 using ClobberOffsetsMapType = DenseMap<LoadInst *, int32_t>;
389 ClobberOffsetsMapType ClobberOffsets;
390
391public:
393 const TargetLibraryInfo &TLI, DominatorTree &DT,
394 unsigned DefaultBlockScanLimit)
395 : AA(AA), AC(AC), TLI(TLI), DT(DT), EEA(DT),
396 DefaultBlockScanLimit(DefaultBlockScanLimit) {}
397
398 /// Handle invalidation in the new PM.
400 FunctionAnalysisManager::Invalidator &Inv);
401
402 /// Some methods limit the number of instructions they will examine.
403 /// The return value of this method is the default limit that will be
404 /// used if no limit is explicitly passed in.
405 LLVM_ABI unsigned getDefaultBlockScanLimit() const;
406
407 /// Returns the instruction on which a memory operation depends.
408 ///
409 /// See the class comment for more details. It is illegal to call this on
410 /// non-memory instructions.
412
413 /// Perform a full dependency query for the specified call, returning the set
414 /// of blocks that the value is potentially live across.
415 ///
416 /// The returned set of results will include a "NonLocal" result for all
417 /// blocks where the value is live across.
418 ///
419 /// This method assumes the instruction returns a "NonLocal" dependency
420 /// within its own block.
421 ///
422 /// This returns a reference to an internal data structure that may be
423 /// invalidated on the next non-local query or when an instruction is
424 /// removed. Clients must copy this data if they want it around longer than
425 /// that.
428
429 /// Perform a full dependency query for an access to the QueryInst's
430 /// specified memory location, returning the set of instructions that either
431 /// define or clobber the value.
432 ///
433 /// Warning: For a volatile query instruction, the dependencies will be
434 /// accurate, and thus usable for reordering, but it is never legal to
435 /// remove the query instruction.
436 ///
437 /// This method assumes the pointer has a "NonLocal" dependency within
438 /// QueryInst's parent basic block.
439 LLVM_ABI void
442
443 /// Removes an instruction from the dependence analysis, updating the
444 /// dependence of instructions that previously depended on it.
445 LLVM_ABI void removeInstruction(Instruction *InstToRemove);
446
447 /// Invalidates cached information about the specified pointer, because it
448 /// may be too conservative in memdep.
449 ///
450 /// This is an optional call that can be used when the client detects an
451 /// equivalence between the pointer and some other value and replaces the
452 /// other value with ptr. This can make Ptr available in more places that
453 /// cached info does not necessarily keep.
455
456 /// Clears the PredIteratorCache info.
457 ///
458 /// This needs to be done when the CFG changes, e.g., due to splitting
459 /// critical edges.
461
462 /// Returns the instruction on which a memory location depends.
463 ///
464 /// If isLoad is true, this routine ignores may-aliases with read-only
465 /// operations. If isLoad is false, this routine ignores may-aliases
466 /// with reads from read-only locations. If possible, pass the query
467 /// instruction as well; this function may take advantage of the metadata
468 /// annotated to the query instruction to refine the result. \p Limit
469 /// can be used to set the maximum number of instructions that will be
470 /// examined to find the pointer dependency. On return, it will be set to
471 /// the number of instructions left to examine. If a null pointer is passed
472 /// in, the limit will default to the value of -memdep-block-scan-limit.
473 ///
474 /// Note that this is an uncached query, and thus may be inefficient.
476 const MemoryLocation &Loc, bool isLoad, BasicBlock::iterator ScanIt,
477 BasicBlock *BB, Instruction *QueryInst = nullptr,
478 unsigned *Limit = nullptr);
479
481 const MemoryLocation &Loc, bool isLoad, BasicBlock::iterator ScanIt,
482 BasicBlock *BB, Instruction *QueryInst, unsigned *Limit,
483 BatchAAResults &BatchAA);
484
486 const MemoryLocation &MemLoc, bool isLoad, BasicBlock::iterator ScanIt,
487 BasicBlock *BB, Instruction *QueryInst, unsigned *Limit,
488 BatchAAResults &BatchAA);
489
490 /// This analysis looks for other loads and stores with invariant.group
491 /// metadata and the same pointer operand. Returns Unknown if it does not
492 /// find anything, and Def if it can be assumed that 2 instructions load or
493 /// store the same value and NonLocal which indicate that non-local Def was
494 /// found, which can be retrieved by calling getNonLocalPointerDependency
495 /// with the same queried instruction.
497 BasicBlock *BB);
498
499 /// Release memory in caches.
501
502 /// Return the clobber offset to dependent instruction.
503 std::optional<int32_t> getClobberOffset(LoadInst *DepInst) const {
504 const auto Off = ClobberOffsets.find(DepInst);
505 if (Off != ClobberOffsets.end())
506 return Off->getSecond();
507 return std::nullopt;
508 }
509
510private:
511 MemDepResult getCallDependencyFrom(CallBase *Call, bool isReadOnlyCall,
513 BasicBlock *BB);
514 void setNonLocalPointerDepVisited(BasicBlock *BB, Value *V);
515 bool isNonLocalPointerDepVisited(BasicBlock *BB) const;
516 Value *lookupNonLocalPointerDepVisited(BasicBlock *BB) const;
517 bool getNonLocalPointerDepFromBB(Instruction *QueryInst,
518 const PHITransAddr &Pointer,
519 const MemoryLocation &Loc, bool isLoad,
520 BasicBlock *BB,
522 bool SkipFirstBlock = false,
523 bool IsIncomplete = false);
524 MemDepResult getNonLocalInfoForBlock(Instruction *QueryInst,
525 const MemoryLocation &Loc, bool isLoad,
526 BasicBlock *BB, NonLocalDepInfo *Cache,
527 unsigned NumSortedEntries,
528 BatchAAResults &BatchAA);
529
530 void removeCachedNonLocalPointerDependencies(ValueIsLoadPair P);
531
532 void verifyRemoved(Instruction *Inst) const;
533};
534
535/// An analysis that produces \c MemoryDependenceResults for a function.
536///
537/// This is essentially a no-op because the results are computed entirely
538/// lazily.
540 : public AnalysisInfoMixin<MemoryDependenceAnalysis> {
542
543 static AnalysisKey Key;
544
545 unsigned DefaultBlockScanLimit;
546
547public:
549
551 MemoryDependenceAnalysis(unsigned DefaultBlockScanLimit) : DefaultBlockScanLimit(DefaultBlockScanLimit) { }
552
555};
556
557/// A wrapper analysis pass for the legacy pass manager that exposes a \c
558/// MemoryDepnedenceResults instance.
560 std::optional<MemoryDependenceResults> MemDep;
561
562public:
563 static char ID;
564
567
568 /// Pass Implementation stuff. This doesn't do any analysis eagerly.
569 bool runOnFunction(Function &) override;
570
571 /// Clean up memory in between runs
572 void releaseMemory() override;
573
574 /// Does not modify anything. It uses Value Numbering and Alias Analysis.
575 void getAnalysisUsage(AnalysisUsage &AU) const override;
576
577 MemoryDependenceResults &getMemDep() { return *MemDep; }
578};
579
580} // end namespace llvm
581
582#endif // LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool isLoad(int Opcode)
#define LLVM_ABI
Definition Compiler.h:215
This file defines the DenseMap class.
static bool runOnFunction(Function &F, bool PostInlining)
This header defines various interfaces for pass management in LLVM.
#define F(x, y, z)
Definition MD5.cpp:54
This file provides utility analysis objects describing memory locations.
#define P(N)
This file defines the PointerIntPair class.
This file defines the SmallPtrSet class.
Value * RHS
Represent the analysis usage information of a pass.
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
Definition BasicBlock.h:62
InstListType::iterator iterator
Instruction iterators...
Definition BasicBlock.h:170
This class is a wrapper over an AAResults, and it is intended to be used only when there are no IR ch...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition Dominators.h:151
Context-sensitive CaptureAnalysis provider, which computes and caches the earliest common dominator c...
FunctionPass(char &pid)
Definition Pass.h:316
An instruction for reading from memory.
static constexpr LocationSize afterPointer()
Any location after the base pointer (but still within the underlying object).
A memory dependence query can return one of three different answers.
bool isClobber() const
Tests if this MemDepResult represents a query that is an instruction clobber dependency.
bool operator!=(const MemDepResult &M) const
bool isNonLocal() const
Tests if this MemDepResult represents a query that is transparent to the start of the block,...
static MemDepResult getNonLocal()
bool isNonFuncLocal() const
Tests if this MemDepResult represents a query that is transparent to the start of the function.
static MemDepResult getSelect()
bool operator>(const MemDepResult &M) const
static MemDepResult getClobber(Instruction *Inst)
bool isDef() const
Tests if this MemDepResult represents a query that is an instruction definition dependency.
bool operator==(const MemDepResult &M) const
static MemDepResult getUnknown()
bool isSelect() const
Tests if this MemDepResult represents a query that depends on a select instruction whose two sides ea...
bool operator<(const MemDepResult &M) const
MemDepResult()=default
bool isLocal() const
Tests if this MemDepResult represents a valid local query (Clobber/Def).
bool isUnknown() const
Tests if this MemDepResult represents a query which cannot and/or will not be computed.
static MemDepResult getNonFuncLocal()
static MemDepResult getDef(Instruction *Inst)
get methods: These are static ctor methods for creating various MemDepResult kinds.
Instruction * getInst() const
If this is a normal dependency, returns the instruction that is depended on.
LLVM_ABI MemoryDependenceResults run(Function &F, FunctionAnalysisManager &AM)
MemoryDependenceAnalysis(unsigned DefaultBlockScanLimit)
Provides a lazy, caching interface for making common memory aliasing information queries,...
LLVM_ABI MemDepResult getSimplePointerDependencyFrom(const MemoryLocation &MemLoc, bool isLoad, BasicBlock::iterator ScanIt, BasicBlock *BB, Instruction *QueryInst, unsigned *Limit, BatchAAResults &BatchAA)
LLVM_ABI void releaseMemory()
Release memory in caches.
std::vector< NonLocalDepEntry > NonLocalDepInfo
LLVM_ABI void invalidateCachedPredecessors()
Clears the PredIteratorCache info.
LLVM_ABI void invalidateCachedPointerInfo(Value *Ptr)
Invalidates cached information about the specified pointer, because it may be too conservative in mem...
MemoryDependenceResults(AAResults &AA, AssumptionCache &AC, const TargetLibraryInfo &TLI, DominatorTree &DT, unsigned DefaultBlockScanLimit)
LLVM_ABI MemDepResult getPointerDependencyFrom(const MemoryLocation &Loc, bool isLoad, BasicBlock::iterator ScanIt, BasicBlock *BB, Instruction *QueryInst=nullptr, unsigned *Limit=nullptr)
Returns the instruction on which a memory location depends.
std::optional< int32_t > getClobberOffset(LoadInst *DepInst) const
Return the clobber offset to dependent instruction.
LLVM_ABI void removeInstruction(Instruction *InstToRemove)
Removes an instruction from the dependence analysis, updating the dependence of instructions that pre...
LLVM_ABI MemDepResult getInvariantGroupPointerDependency(LoadInst *LI, BasicBlock *BB)
This analysis looks for other loads and stores with invariant.group metadata and the same pointer ope...
LLVM_ABI unsigned getDefaultBlockScanLimit() const
Some methods limit the number of instructions they will examine.
LLVM_ABI MemDepResult getDependency(Instruction *QueryInst)
Returns the instruction on which a memory operation depends.
LLVM_ABI const NonLocalDepInfo & getNonLocalCallDependency(CallBase *QueryCall)
Perform a full dependency query for the specified call, returning the set of blocks that the value is...
LLVM_ABI void getNonLocalPointerDependency(Instruction *QueryInst, SmallVectorImpl< NonLocalDepResult > &Result)
Perform a full dependency query for an access to the QueryInst's specified memory location,...
LLVM_ABI bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)
Handle invalidation in the new PM.
void getAnalysisUsage(AnalysisUsage &AU) const override
Does not modify anything. It uses Value Numbering and Alias Analysis.
void releaseMemory() override
Clean up memory in between runs.
Representation for a specific memory location.
This is an entry in the NonLocalDepInfo cache.
void setResult(const MemDepResult &R)
NonLocalDepEntry(BasicBlock *BB, MemDepResult Result)
bool operator<(const NonLocalDepEntry &RHS) const
const MemDepResult & getResult() const
This is a result from a NonLocal dependence query.
void setResult(const MemDepResult &R, const SelectAddr &Addr)
const MemDepResult & getResult() const
NonLocalDepResult(BasicBlock *BB, MemDepResult Result, const SelectAddr &Address)
SelectAddr getAddress() const
Returns the address of this pointer in this block.
PHITransAddr - An address value which tracks and handles phi translation.
PointerIntPair - This class implements a pair of a pointer and small integer.
A sum type over pointer-like types.
PredIteratorCache - This class is an extremely trivial cache for predecessor iterator queries.
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
Storage of either a normal Value address, or a select condition together with a pair of addresses for...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Provides information about what library functions are available for the current target.
LLVM Value Representation.
Definition Value.h:75
CallInst * Call
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Abstract Attribute helper functions.
Definition Attributor.h:165
This is an optimization pass for GlobalISel generic memory operations.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition Metadata.h:763
A CRTP mix-in that provides informational APIs needed for analysis passes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition Analysis.h:29
A compile time pair of an integer tag and the pointer-like type which it indexes within a sum type.