28 #define DEBUG_TYPE "dce"
30 STATISTIC(DIEEliminated,
"Number of insts removed by DIE pass");
31 STATISTIC(DCEEliminated,
"Number of insts removed");
42 bool runOnBasicBlock(
BasicBlock &BB)
override {
43 if (skipOptnoneFunction(BB))
45 auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
67 "Dead Instruction Elimination",
false,
false)
70 return new DeadInstElimination();
96 if (skipOptnoneFunction(F))
99 auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
103 std::vector<Instruction*> WorkList;
105 WorkList.push_back(&*i);
111 bool MadeChange =
false;
112 while (!WorkList.empty()) {
122 if (
Instruction *Used = dyn_cast<Instruction>(*OI))
123 WorkList.push_back(Used);
Pass interface - Implemented by all 'passes'.
iplist< Instruction >::iterator eraseFromParent()
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")
std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
Pass * createDeadInstEliminationPass()
iterator begin()
Instruction iterator methods.
inst_iterator inst_begin(Function *F)
A Use represents the edge between a Value definition and its users.
FunctionPass * createDeadCodeEliminationPass()
LLVM Basic Block Representation.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
iterator erase(iterator where)
BasicBlockPass class - This class is used to implement most local optimizations.
INITIALIZE_PASS(DeadInstElimination,"die","Dead Instruction Elimination", false, false) Pass *llvm
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 initializeDCEPass(PassRegistry &)
bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
isInstructionTriviallyDead - Return true if the result produced by the instruction is not used...
inst_iterator inst_end(Function *F)
void initializeDeadInstEliminationPass(PassRegistry &)