30 #define DEBUG_TYPE "dce"
32 STATISTIC(DIEEliminated,
"Number of insts removed by DIE pass");
33 STATISTIC(DCEEliminated,
"Number of insts removed");
45 if (skipBasicBlock(BB))
47 auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
69 "Dead Instruction Elimination",
false,
false)
72 return new DeadInstElimination();
104 bool MadeChange =
false;
115 if (!WorkList.
count(I))
119 while (!WorkList.
empty()) {
139 bool runOnFunction(
Function &
F)
override {
143 auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
156 INITIALIZE_PASS(DCELegacyPass,
"dce",
"Dead Code Elimination",
false,
false)
159 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...
STATISTIC(NumFunctions,"Total number of functions")
LLVM_NODISCARD T pop_back_val()
Pass * createDeadInstEliminationPass()
unsigned getNumOperands() const
static bool runOnBasicBlock(BasicBlock &BB)
iterator begin()
Instruction iterator methods.
PassT::Result * getCachedResult(IRUnitT &IR) const
Get the cached result of an analysis pass for a given IR unit.
inst_iterator inst_begin(Function *F)
bool insert(const value_type &X)
Insert a new element into the SetVector.
FunctionPass * createDeadCodeEliminationPass()
bool empty() const
Determine if the SetVector is empty or not.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
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.
Value * getOperand(unsigned i) const
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
BasicBlockPass class - This class is used to implement most local optimizations.
INITIALIZE_PASS(DeadInstElimination,"die","Dead Instruction Elimination", false, false) Pass *llvm
A SetVector that performs no allocations if smaller than a certain size.
Iterator for intrusive lists based on ilist_node.
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 DCEInstruction(Instruction *I, SmallSetVector< Instruction *, 16 > &WorkList, const TargetLibraryInfo *TLI)
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
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 &)