31 #define DEBUG_TYPE "dce" 33 STATISTIC(DIEEliminated,
"Number of insts removed by DIE pass");
34 STATISTIC(DCEEliminated,
"Number of insts removed");
36 "Controls which instructions are eliminated");
48 if (skipBasicBlock(BB))
50 auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
75 "Dead Instruction Elimination",
false,
false)
78 return new DeadInstElimination();
115 bool MadeChange =
false;
126 if (!WorkList.
count(I))
130 while (!WorkList.
empty()) {
157 auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
170 INITIALIZE_PASS(DCELegacyPass,
"dce",
"Dead Code Elimination",
false,
false)
173 return new DCELegacyPass();
Pass interface - Implemented by all 'passes'.
void initializeDCELegacyPassPass(PassRegistry &)
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
LLVM_NODISCARD T pop_back_val()
This class represents lattice values for constants.
Pass * createDeadInstEliminationPass()
bool salvageDebugInfo(Instruction &I)
Assuming the instruction I is going to be deleted, attempt to salvage debug users of I by writing the...
STATISTIC(NumFunctions, "Total number of functions")
INITIALIZE_PASS(DeadInstElimination, "die", "Dead Instruction Elimination", false, false) Pass *llvm
iterator begin()
Instruction iterator methods.
inst_iterator inst_begin(Function *F)
This file provides an implementation of debug counters.
bool insert(const value_type &X)
Insert a new element into the SetVector.
FunctionPass * createDeadCodeEliminationPass()
Value * getOperand(unsigned i) const
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
static bool runOnFunction(Function &F, bool PostInlining)
A set of analyses that are preserved following a run of a transformation pass.
static bool eliminateDeadCode(Function &F, TargetLibraryInfo *TLI)
LLVM Basic Block Representation.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
static bool shouldExecute(unsigned CounterName)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
BasicBlockPass class - This class is used to implement most local optimizations.
A SetVector that performs no allocations if smaller than a certain size.
Iterator for intrusive lists based on ilist_node.
unsigned getNumOperands() const
Provides information about what library functions are available for the current target.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
void setOperand(unsigned i, Value *Val)
static bool runOnBasicBlock(MachineBasicBlock *MBB, std::vector< StringRef > &bbNames, std::vector< unsigned > &renamedInOtherBB, unsigned &basicBlockNum, unsigned &VRegGapIndex, NamedVRegCursor &NVC)
Represents analyses that only rely on functions' control flow.
static bool DCEInstruction(Instruction *I, SmallSetVector< Instruction *, 16 > &WorkList, const TargetLibraryInfo *TLI)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
void preserveSet()
Mark an analysis set as preserved.
bool empty() const
Determine if the SetVector is empty or not.
PassT::Result * getCachedResult(IRUnitT &IR) const
Get the cached result of an analysis pass for a given IR unit.
DEBUG_COUNTER(DCECounter, "dce-transform", "Controls which instructions are eliminated")
Analysis pass providing the TargetLibraryInfo.
bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction is not used, and the instruction has no side ef...
LLVM Value Representation.
inst_iterator inst_end(Function *F)
A container for analyses that lazily runs them and caches their results.
void initializeDeadInstEliminationPass(PassRegistry &)