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 };
372
373 // Describe a memory location value, such that there exists a path to a point
374 // in the program, along which that memory location is not modified.
375 struct ReachingMemVal {
376 DepKind Kind;
377 BasicBlock *Block;
378 const Value *Addr;
379 Instruction *Inst;
380 int32_t Offset;
381
382 static ReachingMemVal getUnknown(BasicBlock *BB, const Value *Addr,
383 Instruction *Inst = nullptr) {
384 return {DepKind::Other, BB, Addr, Inst, -1};
385 }
386
387 static ReachingMemVal getDef(const Value *Addr, Instruction *Inst) {
388 return {DepKind::Def, Inst->getParent(), Addr, Inst, -1};
389 }
390
391 static ReachingMemVal getClobber(const Value *Addr, Instruction *Inst,
392 int32_t Offset = -1) {
393 return {DepKind::Clobber, Inst->getParent(), Addr, Inst, Offset};
394 }
395 };
396
397 struct DependencyBlockInfo {
398 DependencyBlockInfo() = delete;
399 DependencyBlockInfo(const PHITransAddr &Addr, MemoryAccess *ClobberMA)
400 : Addr(Addr), InitialClobberMA(ClobberMA), ClobberMA(ClobberMA),
401 ForceUnknown(false), Visited(false) {}
402 PHITransAddr Addr;
403 MemoryAccess *InitialClobberMA;
404 MemoryAccess *ClobberMA;
405 std::optional<ReachingMemVal> MemVal;
406 bool ForceUnknown : 1;
407 bool Visited : 1;
408 };
409
410 using DependencyBlockSet = DenseMap<BasicBlock *, DependencyBlockInfo>;
411
412 std::optional<GVNPass::ReachingMemVal> scanMemoryAccessesUsers(
413 const MemoryLocation &Loc, bool IsInvariantLoad, BasicBlock *BB,
414 const SmallVectorImpl<MemoryAccess *> &ClobbersList, MemorySSA &MSSA,
415 BatchAAResults &AA, LoadInst *L = nullptr);
416
417 std::optional<GVNPass::ReachingMemVal>
418 accessMayModifyLocation(MemoryAccess *ClobberMA, const MemoryLocation &Loc,
419 bool IsInvariantLoad, BasicBlock *BB, MemorySSA &MSSA,
420 BatchAAResults &AA);
421
422 bool collectPredecessors(BasicBlock *BB, const PHITransAddr &Addr,
423 MemoryAccess *ClobberMA, DependencyBlockSet &Blocks,
424 SmallVectorImpl<BasicBlock *> &Worklist);
425
426 void collectClobberList(SmallVectorImpl<MemoryAccess *> &Clobbers,
427 BasicBlock *BB, const DependencyBlockInfo &StartInfo,
428 const DependencyBlockSet &Blocks, MemorySSA &MSSA);
429
430 bool findReachingValuesForLoad(LoadInst *Inst,
431 SmallVectorImpl<ReachingMemVal> &Values,
432 MemorySSA &MSSA, AAResults &AA);
433
434 // Helper functions of redundant load elimination.
435 bool processLoad(LoadInst *L);
436 bool processMaskedLoad(IntrinsicInst *I);
437 bool processNonLocalLoad(LoadInst *L);
438 bool processNonLocalLoad(LoadInst *L, SmallVectorImpl<ReachingMemVal> &Deps);
439 bool processAssumeIntrinsic(AssumeInst *II);
440
441 /// Given a local dependency (Def or Clobber) determine if a value is
442 /// available for the load.
443 std::optional<gvn::AvailableValue>
444 AnalyzeLoadAvailability(LoadInst *Load, const ReachingMemVal &Dep,
445 Value *Address);
446
447 /// Given a list of non-local dependencies, determine if a value is
448 /// available for the load in each specified block. If it is, add it to
449 /// ValuesPerBlock. If not, add it to UnavailableBlocks.
450 void AnalyzeLoadAvailability(LoadInst *Load,
451 SmallVectorImpl<ReachingMemVal> &Deps,
452 AvailValInBlkVect &ValuesPerBlock,
453 UnavailBlkVect &UnavailableBlocks);
454
455 /// Given a critical edge from Pred to LoadBB, find a load instruction
456 /// which is identical to Load from another successor of Pred.
457 LoadInst *findLoadToHoistIntoPred(BasicBlock *Pred, BasicBlock *LoadBB,
458 LoadInst *Load);
459
460 bool PerformLoadPRE(LoadInst *Load, AvailValInBlkVect &ValuesPerBlock,
461 UnavailBlkVect &UnavailableBlocks);
462
463 /// Try to replace a load which executes on each loop iteraiton with Phi
464 /// translation of load in preheader and load(s) in conditionally executed
465 /// paths.
466 bool performLoopLoadPRE(LoadInst *Load, AvailValInBlkVect &ValuesPerBlock,
467 UnavailBlkVect &UnavailableBlocks);
468
469 /// Eliminates partially redundant \p Load, replacing it with \p
470 /// AvailableLoads (connected by Phis if needed).
471 void eliminatePartiallyRedundantLoad(
472 LoadInst *Load, AvailValInBlkVect &ValuesPerBlock,
473 MapVector<BasicBlock *, Value *> &AvailableLoads,
474 MapVector<BasicBlock *, LoadInst *> *CriticalEdgePredAndLoad);
475
476 // Other helper routines.
477 bool processInstruction(Instruction *I);
478 bool processBlock(BasicBlock *BB);
479 void dump(DenseMap<uint32_t, Value *> &Map) const;
480 bool iterateOnFunction(Function &F);
481 bool performPRE(Function &F);
482 bool performScalarPRE(Instruction *I);
483 bool performScalarPREInsertion(Instruction *Instr, BasicBlock *Pred,
484 BasicBlock *Curr, unsigned int ValNo);
485 Value *findLeader(const BasicBlock *BB, uint32_t Num);
486 void cleanupGlobalSets();
487 void removeInstruction(Instruction *I);
488 void verifyRemoved(const Instruction *I) const;
489 bool splitCriticalEdges();
490 BasicBlock *splitCriticalEdges(BasicBlock *Pred, BasicBlock *Succ);
491 bool
492 propagateEquality(Value *LHS, Value *RHS,
493 const std::variant<BasicBlockEdge, Instruction *> &Root);
494 bool processFoldableCondBr(CondBrInst *BI);
495 void addDeadBlock(BasicBlock *BB);
496 void assignValNumForDeadCode();
497 void assignBlockRPONumber(Function &F);
498};
499
500/// Create a legacy GVN pass.
501LLVM_ABI FunctionPass *createGVNPass(bool ScalarPRE);
503
504/// A simple and fast domtree-based GVN pass to hoist common expressions
505/// from sibling branches.
506struct GVNHoistPass : OptionalPassInfoMixin<GVNHoistPass> {
507 /// Run the pass over the function.
509};
510
511/// Uses an "inverted" value numbering to decide the similarity of
512/// expressions and sinks similar expressions into successors.
513struct GVNSinkPass : OptionalPassInfoMixin<GVNSinkPass> {
514 /// Run the pass over the function.
516};
517
518} // end namespace llvm
519
520#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:213
#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
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:155
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:753
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:740
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:472
LLVM_ABI void clear()
Remove all entries from the ValueTable.
Definition GVN.cpp:761
LLVM_ABI bool exists(Value *V) const
Returns true if a value number exists for the specified value.
Definition GVN.cpp:643
LLVM_ABI ValueTable(const ValueTable &Arg)
LLVM_ABI uint32_t lookupOrAdd(MemoryAccess *MA)
Definition GVN.cpp:647
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:2872
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:3002
LLVM_ABI void erase(Value *V)
Remove a value from the value numbering.
Definition GVN.cpp:774
LLVM_ABI void verifyRemoved(const Value *) const
verifyRemoved - Verify that the value is removed from all internal data structures.
Definition GVN.cpp:786
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Run the pass over the function.
Definition GVN.cpp:876
LLVM_ABI void salvageAndRemoveInstruction(Instruction *I)
This removes the specified instruction from our various maps and marks it for deletion.
Definition GVN.cpp:928
AAResults * getAliasAnalysis() const
Definition GVN.h:151
LLVM_ABI bool isLoadPREEnabled() const
Definition GVN.cpp:855
GVNPass(GVNOptions Options={})
Definition GVN.h:137
LLVM_ABI void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
Definition GVN.cpp:908
LLVM_ABI bool isMemorySSAEnabled() const
Definition GVN.cpp:872
DominatorTree & getDominatorTree() const
Definition GVN.h:150
LLVM_ABI bool isLoadInLoopPREEnabled() const
Definition GVN.cpp:859
LLVM_ABI bool isScalarPREEnabled() const
Definition GVN.cpp:851
LLVM_ABI bool isLoadPRESplitBackedgeEnabled() const
Definition GVN.cpp:863
LLVM_ABI bool isMemDepEnabled() const
Definition GVN.cpp:868
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:4013
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:383
#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:506
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:513
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Run the pass over the function.
Definition GVNSink.cpp:850
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:294
Represents a particular available value that we know how to materialize.
Definition GVN.cpp:198