LLVM 23.0.0git
GVN.h
Go to the documentation of this file.
1//===- GVN.h - Eliminate redundant values and loads -------------*- 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/// \file
9/// This file provides the interface for LLVM's Global Value Numbering pass
10/// which eliminates fully redundant instructions. It also does somewhat Ad-Hoc
11/// PRE and dead load elimination.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_TRANSFORMS_SCALAR_GVN_H
16#define LLVM_TRANSFORMS_SCALAR_GVN_H
17
18#include "llvm/ADT/DenseMap.h"
19#include "llvm/ADT/MapVector.h"
20#include "llvm/ADT/SetVector.h"
23#include "llvm/IR/Dominators.h"
24#include "llvm/IR/InstrTypes.h"
25#include "llvm/IR/PassManager.h"
26#include "llvm/IR/ValueHandle.h"
29#include <cstdint>
30#include <optional>
31#include <utility>
32#include <variant>
33#include <vector>
34
35namespace llvm {
36
37class AAResults;
38class AssumeInst;
39class AssumptionCache;
40class BasicBlock;
41class BatchAAResults;
42class CallInst;
43class CondBrInst;
46class Function;
47class FunctionPass;
50class LoadInst;
51class LoopInfo;
52class MemDepResult;
53class MemoryAccess;
55class MemoryLocation;
56class MemorySSA;
60class PHINode;
62class Value;
63class IntrinsicInst;
64/// A private "module" namespace for types and utilities used by GVN. These
65/// are implementation details and should not be used by clients.
67
68struct AvailableValue;
70class GVNLegacyPass;
71
72} // end namespace gvn
73
74/// A set of parameters to control various transforms performed by GVN pass.
75// Each of the optional boolean parameters can be set to:
76/// true - enabling the transformation.
77/// false - disabling the transformation.
78/// None - relying on a global default.
79/// Intended use is to create a default object, modify parameters with
80/// additional setters and then pass it to GVN.
81struct GVNOptions {
82 std::optional<bool> AllowScalarPRE;
83 std::optional<bool> AllowLoadPRE;
84 std::optional<bool> AllowLoadInLoopPRE;
85 std::optional<bool> AllowLoadPRESplitBackedge;
86 std::optional<bool> AllowMemDep;
87 std::optional<bool> AllowMemorySSA;
88
89 GVNOptions() = default;
90
91 /// Enables or disables PRE of scalars in GVN.
92 GVNOptions &setScalarPRE(bool ScalarPRE) {
93 AllowScalarPRE = ScalarPRE;
94 return *this;
95 }
96
97 /// Enables or disables PRE of loads in GVN.
98 GVNOptions &setLoadPRE(bool LoadPRE) {
99 AllowLoadPRE = LoadPRE;
100 return *this;
101 }
102
103 GVNOptions &setLoadInLoopPRE(bool LoadInLoopPRE) {
104 AllowLoadInLoopPRE = LoadInLoopPRE;
105 return *this;
106 }
107
108 /// Enables or disables PRE of loads in GVN.
109 GVNOptions &setLoadPRESplitBackedge(bool LoadPRESplitBackedge) {
110 AllowLoadPRESplitBackedge = LoadPRESplitBackedge;
111 return *this;
112 }
113
114 /// Enables or disables use of MemDepAnalysis.
115 GVNOptions &setMemDep(bool MemDep) {
116 AllowMemDep = MemDep;
117 return *this;
118 }
119
120 /// Enables or disables use of MemorySSA.
121 GVNOptions &setMemorySSA(bool MemSSA) {
122 AllowMemorySSA = MemSSA;
123 return *this;
124 }
125};
126
127/// The core GVN pass object.
128///
129/// FIXME: We should have a good summary of the GVN algorithm implemented by
130/// this particular pass here.
131class GVNPass : public OptionalPassInfoMixin<GVNPass> {
132 GVNOptions Options;
133
134public:
135 struct Expression;
136
137 GVNPass(GVNOptions Options = {}) : Options(Options) {}
138
139 /// Run the pass over the function.
140 LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
141
142 LLVM_ABI void
143 printPipeline(raw_ostream &OS,
144 function_ref<StringRef(StringRef)> MapClassName2PassName);
145
146 /// This removes the specified instruction from
147 /// our various maps and marks it for deletion.
148 LLVM_ABI void salvageAndRemoveInstruction(Instruction *I);
149
150 DominatorTree &getDominatorTree() const { return *DT; }
151 AAResults *getAliasAnalysis() const { return VN.getAliasAnalysis(); }
152 MemoryDependenceResults &getMemDep() const { return *MD; }
153
154 LLVM_ABI bool isScalarPREEnabled() const;
155 LLVM_ABI bool isLoadPREEnabled() const;
156 LLVM_ABI bool isLoadInLoopPREEnabled() const;
158 LLVM_ABI bool isMemDepEnabled() const;
159 LLVM_ABI bool isMemorySSAEnabled() const;
160
161 /// This class holds the mapping between values and value numbers. It is used
162 /// as an efficient mechanism to determine the expression-wise equivalence of
163 /// two values.
165 DenseMap<Value *, uint32_t> ValueNumbering;
166 DenseMap<Expression, uint32_t> ExpressionNumbering;
167
168 // Expressions is the vector of Expression. ExprIdx is the mapping from
169 // value number to the index of Expression in Expressions. We use it
170 // instead of a DenseMap because filling such mapping is faster than
171 // filling a DenseMap and the compile time is a little better.
172 uint32_t NextExprNumber = 0;
173
174 std::vector<Expression> Expressions;
175 std::vector<uint32_t> ExprIdx;
176
177 // Value number to PHINode mapping. Used for phi-translate in scalarpre.
179
180 // Value number to BasicBlock mapping. Used for phi-translate across
181 // MemoryPhis.
183
184 // Cache for phi-translate in scalarpre.
185 using PhiTranslateMap =
187 PhiTranslateMap PhiTranslateTable;
188
189 AAResults *AA = nullptr;
190 MemoryDependenceResults *MD = nullptr;
191 bool IsMDEnabled = false;
192 MemorySSA *MSSA = nullptr;
193 bool IsMSSAEnabled = false;
194 DominatorTree *DT = nullptr;
195
196 uint32_t NextValueNumber = 1;
197
198 Expression createExpr(Instruction *I);
199 Expression createCmpExpr(unsigned Opcode, CmpInst::Predicate Predicate,
200 Value *LHS, Value *RHS);
201 Expression createExtractvalueExpr(ExtractValueInst *EI);
202 Expression createGEPExpr(GetElementPtrInst *GEP);
203 uint32_t lookupOrAddCall(CallInst *C);
204 uint32_t computeLoadStoreVN(Instruction *I);
205 uint32_t phiTranslateImpl(const BasicBlock *BB, const BasicBlock *PhiBlock,
206 uint32_t Num, GVNPass &GVN);
207 bool areCallValsEqual(uint32_t Num, uint32_t NewNum, const BasicBlock *Pred,
208 const BasicBlock *PhiBlock, GVNPass &GVN);
209 std::pair<uint32_t, bool> assignExpNewValueNum(Expression &Exp);
210 bool areAllValsInBB(uint32_t Num, const BasicBlock *BB, GVNPass &GVN);
211 void addMemoryStateToExp(Instruction *I, Expression &Exp);
212
213 public:
219
222 LLVM_ABI uint32_t lookup(Value *V, bool Verify = true) const;
224 Value *LHS, Value *RHS);
226 const BasicBlock *PhiBlock, uint32_t Num,
227 GVNPass &GVN);
229 const BasicBlock &CurrBlock);
230 LLVM_ABI bool exists(Value *V) const;
231 LLVM_ABI void add(Value *V, uint32_t Num);
232 LLVM_ABI void clear();
233 LLVM_ABI void erase(Value *V);
234 void setAliasAnalysis(AAResults *A) { AA = A; }
235 AAResults *getAliasAnalysis() const { return AA; }
236 void setMemDep(MemoryDependenceResults *M, bool MDEnabled = true) {
237 MD = M;
238 IsMDEnabled = MDEnabled;
239 }
240 void setMemorySSA(MemorySSA *M, bool MSSAEnabled = false) {
241 MSSA = M;
242 IsMSSAEnabled = MSSAEnabled;
243 }
244 void setDomTree(DominatorTree *D) { DT = D; }
245 uint32_t getNextUnusedValueNumber() { return NextValueNumber; }
246 LLVM_ABI void verifyRemoved(const Value *) const;
247 };
248
249private:
250 friend class gvn::GVNLegacyPass;
251 friend struct DenseMapInfo<Expression>;
252
253 MemoryDependenceResults *MD = nullptr;
254 DominatorTree *DT = nullptr;
255 const TargetLibraryInfo *TLI = nullptr;
256 AssumptionCache *AC = nullptr;
257 SetVector<BasicBlock *> DeadBlocks;
258 OptimizationRemarkEmitter *ORE = nullptr;
259 ImplicitControlFlowTracking *ICF = nullptr;
260 LoopInfo *LI = nullptr;
261 AAResults *AA = nullptr;
262 MemorySSAUpdater *MSSAU = nullptr;
263
264 ValueTable VN;
265
266 /// A mapping from value numbers to lists of Value*'s that
267 /// have that value number. Use findLeader to query it.
268 class LeaderMap {
269 public:
271 // Use AssertingVH here to catch dangling Value*'s in the leader table.
272 // Will crash if the value gets deleted before the AssertingVH is
273 // destroyed.
277 };
278
279 private:
280 struct LeaderListNode {
281 LeaderTableEntry Entry;
282 LeaderListNode *Next;
283 LeaderListNode(Value *V, const BasicBlock *BB, LeaderListNode *Next)
284 : Entry(V, BB), Next(Next) {}
285 };
286 DenseMap<uint32_t, LeaderListNode> NumToLeaders;
287 BumpPtrAllocator TableAllocator;
288
289 public:
291 const LeaderListNode *Current;
292
293 public:
294 using iterator_category = std::forward_iterator_tag;
296 using difference_type = std::ptrdiff_t;
299
300 leader_iterator(const LeaderListNode *C) : Current(C) {}
302 assert(Current && "Dereferenced end of leader list!");
303 Current = Current->Next;
304 return *this;
305 }
306 bool operator==(const leader_iterator &Other) const {
307 return Current == Other.Current;
308 }
309 bool operator!=(const leader_iterator &Other) const {
310 return Current != Other.Current;
311 }
312 reference operator*() const { return Current->Entry; }
313 };
314
316 auto I = NumToLeaders.find(N);
317 if (I == NumToLeaders.end()) {
318 return iterator_range(leader_iterator(nullptr),
319 leader_iterator(nullptr));
320 }
321
322 return iterator_range(leader_iterator(&I->second),
323 leader_iterator(nullptr));
324 }
325
326 LLVM_ABI void insert(uint32_t N, Value *V, const BasicBlock *BB);
327 LLVM_ABI void erase(uint32_t N, Instruction *I, const BasicBlock *BB);
328 void clear() {
329 // Manually destroy non-head nodes (in BumpPtrAllocator) to properly
330 // clean up AssertingVH handles before Reset(). Head nodes are destroyed
331 // by NumToLeaders.clear() below.
332 for (auto &[_, HeadNode] : NumToLeaders) {
333 LeaderListNode *N = HeadNode.Next;
334 while (N) {
335 auto *Next = N->Next;
336 N->~LeaderListNode();
337 N = Next;
338 }
339 }
340 NumToLeaders.clear();
341 TableAllocator.Reset();
342 }
343 };
344 LeaderMap LeaderTable;
345
346 // Map the block to reversed postorder traversal number. It is used to
347 // find back edge easily.
348 DenseMap<AssertingVH<BasicBlock>, uint32_t> BlockRPONumber;
349
350 // This is set 'true' initially and also when new blocks have been added to
351 // the function being analyzed. This boolean is used to control the updating
352 // of BlockRPONumber prior to accessing the contents of BlockRPONumber.
353 bool InvalidBlockRPONumbers = true;
354
355 using LoadDepVect = SmallVector<NonLocalDepResult, 64>;
356 using AvailValInBlkVect = SmallVector<gvn::AvailableValueInBlock, 64>;
357 using UnavailBlkVect = SmallVector<BasicBlock *, 64>;
358
359 bool runImpl(Function &F, AssumptionCache &RunAC, DominatorTree &RunDT,
360 const TargetLibraryInfo &RunTLI, AAResults &RunAA,
361 MemoryDependenceResults *RunMD, LoopInfo &LI,
362 OptimizationRemarkEmitter *ORE, MemorySSA *MSSA = nullptr);
363
364 // List of critical edges to be split between iterations.
366
367 enum class DepKind {
368 Other = 0, // Unknown value.
369 Def, // Exactly overlapping locations.
370 Clobber, // Reaching value superset of needed bits.
371 Select, // Reaching value is a select of two reaching addresses.
372 };
373
374 // Describe a memory location value, such that there exists a path to a point
375 // in the program, along which that memory location is not modified.
376 struct ReachingMemVal {
377 DepKind Kind;
378 BasicBlock *Block;
379 const Value *Addr;
380 Instruction *Inst;
381 int32_t Offset;
382 // For DepKind::Select only: the condition and the two addresses referenced
383 // by the "true" and "false" side of the select-dependent load.
384 const Value *SelCond = nullptr;
385 const Value *SelTrueAddr = nullptr;
386 const Value *SelFalseAddr = nullptr;
387
388 static ReachingMemVal getUnknown(BasicBlock *BB, const Value *Addr,
389 Instruction *Inst = nullptr) {
390 return {DepKind::Other, BB, Addr, Inst, -1};
391 }
392
393 static ReachingMemVal getDef(const Value *Addr, Instruction *Inst) {
394 return {DepKind::Def, Inst->getParent(), Addr, Inst, -1};
395 }
396
397 static ReachingMemVal getClobber(const Value *Addr, Instruction *Inst,
398 int32_t Offset = -1) {
399 return {DepKind::Clobber, Inst->getParent(), Addr, Inst, Offset};
400 }
401
402 static ReachingMemVal getSelect(BasicBlock *BB, const Value *Cond,
403 const Value *TrueAddr,
404 const Value *FalseAddr) {
405 return {DepKind::Select, BB, nullptr, nullptr, -1, Cond,
406 TrueAddr, FalseAddr};
407 }
408 };
409
410 struct DependencyBlockInfo {
411 DependencyBlockInfo() = delete;
412 DependencyBlockInfo(const PHITransAddr &Addr, MemoryAccess *ClobberMA)
413 : Addr(Addr), InitialClobberMA(ClobberMA), ClobberMA(ClobberMA),
414 ForceUnknown(false), Visited(false) {}
415 PHITransAddr Addr;
416 MemoryAccess *InitialClobberMA;
417 MemoryAccess *ClobberMA;
418 std::optional<ReachingMemVal> MemVal;
419 bool ForceUnknown : 1;
420 bool Visited : 1;
421 };
422
423 using DependencyBlockSet = DenseMap<BasicBlock *, DependencyBlockInfo>;
424
425 std::optional<GVNPass::ReachingMemVal> scanMemoryAccessesUsers(
426 const MemoryLocation &Loc, bool IsInvariantLoad, BasicBlock *BB,
427 const SmallVectorImpl<MemoryAccess *> &ClobbersList, MemorySSA &MSSA,
428 BatchAAResults &AA, LoadInst *L = nullptr);
429
430 std::optional<GVNPass::ReachingMemVal>
431 accessMayModifyLocation(MemoryAccess *ClobberMA, const MemoryLocation &Loc,
432 bool IsInvariantLoad, BasicBlock *BB, MemorySSA &MSSA,
433 BatchAAResults &AA);
434
435 bool collectPredecessors(BasicBlock *BB, const PHITransAddr &Addr,
436 MemoryAccess *ClobberMA, DependencyBlockSet &Blocks,
437 SmallVectorImpl<BasicBlock *> &Worklist);
438
439 void collectClobberList(SmallVectorImpl<MemoryAccess *> &Clobbers,
440 BasicBlock *BB, const DependencyBlockInfo &StartInfo,
441 const DependencyBlockSet &Blocks, MemorySSA &MSSA);
442
443 bool findReachingValuesForLoad(LoadInst *Inst,
444 SmallVectorImpl<ReachingMemVal> &Values,
445 MemorySSA &MSSA, AAResults &AA);
446
447 // Helper functions of redundant load elimination.
448 bool processLoad(LoadInst *L);
449 bool processMaskedLoad(IntrinsicInst *I);
450 bool processNonLocalLoad(LoadInst *L);
451 bool processNonLocalLoad(LoadInst *L, SmallVectorImpl<ReachingMemVal> &Deps);
452 bool processAssumeIntrinsic(AssumeInst *II);
453
454 /// Given a local dependency (Def or Clobber) determine if a value is
455 /// available for the load.
456 std::optional<gvn::AvailableValue>
457 AnalyzeLoadAvailability(LoadInst *Load, const ReachingMemVal &Dep,
458 Value *Address);
459
460 /// Given a select-dependency for the load (the load address is a select of
461 /// \p TrueAddr and \p FalseAddr guarded by \p Cond), determine whether a
462 /// value is available by finding dominating values for both addresses. If
463 /// so, the load can be rematerialized as a select of those two values.
464 std::optional<gvn::AvailableValue>
465 AnalyzeSelectAvailability(LoadInst *Load, Value *Cond, Value *TrueAddr,
466 Value *FalseAddr, Instruction *From);
467
468 /// Given a list of non-local dependencies, determine if a value is
469 /// available for the load in each specified block. If it is, add it to
470 /// ValuesPerBlock. If not, add it to UnavailableBlocks.
471 void AnalyzeLoadAvailability(LoadInst *Load,
472 SmallVectorImpl<ReachingMemVal> &Deps,
473 AvailValInBlkVect &ValuesPerBlock,
474 UnavailBlkVect &UnavailableBlocks);
475
476 /// Given a critical edge from Pred to LoadBB, find a load instruction
477 /// which is identical to Load from another successor of Pred.
478 LoadInst *findLoadToHoistIntoPred(BasicBlock *Pred, BasicBlock *LoadBB,
479 LoadInst *Load);
480
481 bool PerformLoadPRE(LoadInst *Load, AvailValInBlkVect &ValuesPerBlock,
482 UnavailBlkVect &UnavailableBlocks);
483
484 /// Try to replace a load which executes on each loop iteraiton with Phi
485 /// translation of load in preheader and load(s) in conditionally executed
486 /// paths.
487 bool performLoopLoadPRE(LoadInst *Load, AvailValInBlkVect &ValuesPerBlock,
488 UnavailBlkVect &UnavailableBlocks);
489
490 /// Eliminates partially redundant \p Load, replacing it with \p
491 /// AvailableLoads (connected by Phis if needed).
492 void eliminatePartiallyRedundantLoad(
493 LoadInst *Load, AvailValInBlkVect &ValuesPerBlock,
494 MapVector<BasicBlock *, Value *> &AvailableLoads,
495 MapVector<BasicBlock *, LoadInst *> *CriticalEdgePredAndLoad);
496
497 // Other helper routines.
498 bool processInstruction(Instruction *I);
499 bool processBlock(BasicBlock *BB);
500 void dump(DenseMap<uint32_t, Value *> &Map) const;
501 bool iterateOnFunction(Function &F);
502 bool performPRE(Function &F);
503 bool performScalarPRE(Instruction *I);
504 bool performScalarPREInsertion(Instruction *Instr, BasicBlock *Pred,
505 BasicBlock *Curr, unsigned int ValNo);
506 Value *findLeader(const BasicBlock *BB, uint32_t Num);
507 void cleanupGlobalSets();
508 void removeInstruction(Instruction *I);
509 void verifyRemoved(const Instruction *I) const;
510 bool splitCriticalEdges();
511 BasicBlock *splitCriticalEdges(BasicBlock *Pred, BasicBlock *Succ);
512 bool
513 propagateEquality(Value *LHS, Value *RHS,
514 const std::variant<BasicBlockEdge, Instruction *> &Root);
515 bool processFoldableCondBr(CondBrInst *BI);
516 void addDeadBlock(BasicBlock *BB);
517 void assignValNumForDeadCode();
518 void assignBlockRPONumber(Function &F);
519};
520
521/// Create a legacy GVN pass.
522LLVM_ABI FunctionPass *createGVNPass(bool ScalarPRE);
524
525/// A simple and fast domtree-based GVN pass to hoist common expressions
526/// from sibling branches.
527struct GVNHoistPass : OptionalPassInfoMixin<GVNHoistPass> {
528 /// Run the pass over the function.
530};
531
532/// Uses an "inverted" value numbering to decide the similarity of
533/// expressions and sinks similar expressions into successors.
534struct GVNSinkPass : OptionalPassInfoMixin<GVNSinkPass> {
535 /// Run the pass over the function.
537};
538
539} // end namespace llvm
540
541#endif // LLVM_TRANSFORMS_SCALAR_GVN_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Function Alias Analysis false
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
#define LLVM_ABI
Definition Compiler.h:215
#define LLVM_LIBRARY_VISIBILITY_NAMESPACE
Definition Compiler.h:143
This file defines the DenseMap class.
early cse Early CSE w MemorySSA
Hexagon Common GEP
#define _
This header defines various interfaces for pass management in LLVM.
static LVOptions Options
Definition LVOptions.cpp:25
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
This file implements a map that provides insertion order iteration.
uint64_t IntrinsicInst * II
ppc ctr loops PowerPC CTR Loops Verify
const SmallVectorImpl< MachineOperand > & Cond
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallVector class.
Value * RHS
Value * LHS
Value handle that asserts if the Value is deleted.
This represents the llvm.assume intrinsic.
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
Definition BasicBlock.h:62
This class is a wrapper over an AAResults, and it is intended to be used only when there are no IR ch...
This class represents a function call, abstracting a target machine's calling convention.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:740
Conditional Branch instruction.
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...
This instruction extracts a struct member or array element value from an aggregate value.
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:314
const LeaderTableEntry value_type
Definition GVN.h:295
std::forward_iterator_tag iterator_category
Definition GVN.h:294
bool operator==(const leader_iterator &Other) const
Definition GVN.h:306
bool operator!=(const leader_iterator &Other) const
Definition GVN.h:309
leader_iterator(const LeaderListNode *C)
Definition GVN.h:300
This class holds the mapping between values and value numbers.
Definition GVN.h:164
void setMemDep(MemoryDependenceResults *M, bool MDEnabled=true)
Definition GVN.h:236
LLVM_ABI ValueTable(ValueTable &&Arg)
void setMemorySSA(MemorySSA *M, bool MSSAEnabled=false)
Definition GVN.h:240
LLVM_ABI uint32_t lookupOrAddCmp(unsigned Opcode, CmpInst::Predicate Pred, Value *LHS, Value *RHS)
Returns the value number of the given comparison, assigning it a new number if it did not have one be...
Definition GVN.cpp:746
uint32_t getNextUnusedValueNumber()
Definition GVN.h:245
LLVM_ABI uint32_t lookup(Value *V, bool Verify=true) const
Returns the value number of the specified value.
Definition GVN.cpp:733
LLVM_ABI ValueTable & operator=(const ValueTable &Arg)
void setAliasAnalysis(AAResults *A)
Definition GVN.h:234
LLVM_ABI void add(Value *V, uint32_t Num)
add - Insert a value into the table with a specified value number.
Definition GVN.cpp:465
LLVM_ABI void clear()
Remove all entries from the ValueTable.
Definition GVN.cpp:754
LLVM_ABI bool exists(Value *V) const
Returns true if a value number exists for the specified value.
Definition GVN.cpp:636
LLVM_ABI ValueTable(const ValueTable &Arg)
LLVM_ABI uint32_t lookupOrAdd(MemoryAccess *MA)
Definition GVN.cpp:640
AAResults * getAliasAnalysis() const
Definition GVN.h:235
LLVM_ABI uint32_t phiTranslate(const BasicBlock *BB, const BasicBlock *PhiBlock, uint32_t Num, GVNPass &GVN)
Wrap phiTranslateImpl to provide caching functionality.
Definition GVN.cpp:2902
void setDomTree(DominatorTree *D)
Definition GVN.h:244
LLVM_ABI void eraseTranslateCacheEntry(uint32_t Num, const BasicBlock &CurrBlock)
Erase stale entry from phiTranslate cache so phiTranslate can be computed again.
Definition GVN.cpp:3032
LLVM_ABI void erase(Value *V)
Remove a value from the value numbering.
Definition GVN.cpp:767
LLVM_ABI void verifyRemoved(const Value *) const
verifyRemoved - Verify that the value is removed from all internal data structures.
Definition GVN.cpp:779
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Run the pass over the function.
Definition GVN.cpp:869
LLVM_ABI void salvageAndRemoveInstruction(Instruction *I)
This removes the specified instruction from our various maps and marks it for deletion.
Definition GVN.cpp:921
AAResults * getAliasAnalysis() const
Definition GVN.h:151
LLVM_ABI bool isLoadPREEnabled() const
Definition GVN.cpp:848
GVNPass(GVNOptions Options={})
Definition GVN.h:137
LLVM_ABI void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
Definition GVN.cpp:901
LLVM_ABI bool isMemorySSAEnabled() const
Definition GVN.cpp:865
DominatorTree & getDominatorTree() const
Definition GVN.h:150
LLVM_ABI bool isLoadInLoopPREEnabled() const
Definition GVN.cpp:852
LLVM_ABI bool isScalarPREEnabled() const
Definition GVN.cpp:844
LLVM_ABI bool isLoadPRESplitBackedgeEnabled() const
Definition GVN.cpp:856
LLVM_ABI bool isMemDepEnabled() const
Definition GVN.cpp:861
MemoryDependenceResults & getMemDep() const
Definition GVN.h:152
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
This class allows to keep track on instructions with implicit control flow.
A wrapper class for inspecting calls to intrinsic functions.
An instruction for reading from memory.
A memory dependence query can return one of three different answers.
Provides a lazy, caching interface for making common memory aliasing information queries,...
Representation for a specific memory location.
Encapsulates MemorySSA, including all data associated with memory accesses.
Definition MemorySSA.h:702
This is a result from a NonLocal dependence query.
The optimization diagnostic interface.
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
A vector that has set insertion semantics.
Definition SetVector.h:57
Provides information about what library functions are available for the current target.
LLVM Value Representation.
Definition Value.h:75
A range adaptor for a pair of iterators.
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
@ BasicBlock
Various leaf nodes.
Definition ISDOpcodes.h:81
A private "module" namespace for types and utilities used by GVN.
Definition GVN.h:66
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition BasicBlock.h:73
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
Definition InstrProf.h:137
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
iterator_range(Container &&) -> iterator_range< llvm::detail::IterOfRange< Container > >
LLVM_ABI FunctionPass * createGVNPass()
Definition GVN.cpp:4043
FunctionAddr VTableAddr Next
Definition InstrProf.h:141
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:390
#define N
An information struct used to provide DenseMap with the various necessary components for a given valu...
A simple and fast domtree-based GVN pass to hoist common expressions from sibling branches.
Definition GVN.h:527
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Run the pass over the function.
A set of parameters to control various transforms performed by GVN pass.
Definition GVN.h:81
GVNOptions & setLoadPRE(bool LoadPRE)
Enables or disables PRE of loads in GVN.
Definition GVN.h:98
std::optional< bool > AllowLoadPRESplitBackedge
Definition GVN.h:85
std::optional< bool > AllowScalarPRE
Definition GVN.h:82
GVNOptions & setLoadInLoopPRE(bool LoadInLoopPRE)
Definition GVN.h:103
std::optional< bool > AllowLoadInLoopPRE
Definition GVN.h:84
std::optional< bool > AllowMemDep
Definition GVN.h:86
GVNOptions & setMemDep(bool MemDep)
Enables or disables use of MemDepAnalysis.
Definition GVN.h:115
GVNOptions & setScalarPRE(bool ScalarPRE)
Enables or disables PRE of scalars in GVN.
Definition GVN.h:92
std::optional< bool > AllowLoadPRE
Definition GVN.h:83
GVNOptions & setLoadPRESplitBackedge(bool LoadPRESplitBackedge)
Enables or disables PRE of loads in GVN.
Definition GVN.h:109
std::optional< bool > AllowMemorySSA
Definition GVN.h:87
GVNOptions()=default
GVNOptions & setMemorySSA(bool MemSSA)
Enables or disables use of MemorySSA.
Definition GVN.h:121
LeaderTableEntry(Value *V, const BasicBlock *BB)
Definition GVN.h:276
Uses an "inverted" value numbering to decide the similarity of expressions and sinks similar expressi...
Definition GVN.h:534
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Run the pass over the function.
Definition GVNSink.cpp:844
A CRTP mix-in for passes that can be skipped.
Represents an AvailableValue which can be rematerialized at the end of the associated BasicBlock.
Definition GVN.cpp:292
Represents a particular available value that we know how to materialize.
Definition GVN.cpp:196