1 //===-- DCE.h - Functions that perform Dead Code Elimination -----*- C++ -*--=//
3 // This family of functions is useful for performing dead code elimination of
6 //===----------------------------------------------------------------------===//
11 #include "llvm/Pass.h"
12 #include "llvm/BasicBlock.h"
16 struct DeadCodeElimination : public Pass {
17 // External Interface:
19 static bool doDCE(Method *M);
21 // dceInstruction - Inspect the instruction at *BBI and figure out if it's
22 // [trivially] dead. If so, remove the instruction and update the iterator
23 // to point to the instruction that immediately succeeded the original
26 static bool dceInstruction(BasicBlock::InstListType &BBIL,
27 BasicBlock::iterator &BBI);
29 // Remove unused global values - This removes unused global values of no
30 // possible value. This currently includes unused method prototypes and
31 // unitialized global variables.
33 static bool RemoveUnusedGlobalValues(Module *M);
36 virtual bool doPassInitialization(Module *M) {
37 return RemoveUnusedGlobalValues(M);
39 virtual bool doPerMethodWork(Method *M) { return doDCE(M); }
40 virtual bool doPassFinalization(Module *M) {
41 return RemoveUnusedGlobalValues(M);
47 struct AgressiveDCE : public Pass {
48 // DoADCE - Execute the Agressive Dead Code Elimination Algorithm
50 static bool doADCE(Method *M); // Defined in ADCE.cpp
52 virtual bool doPerMethodWork(Method *M) {
58 // SimplifyCFG - This function is used to do simplification of a CFG. For
59 // example, it adjusts branches to branches to eliminate the extra hop, it
60 // eliminates unreachable basic blocks, and does other "peephole" optimization
61 // of the CFG. It returns true if a modification was made, and returns an
62 // iterator that designates the first element remaining after the block that
65 // WARNING: The entry node of a method may not be simplified.
67 bool SimplifyCFG(Method::iterator &BBIt);
69 } // End namespace opt