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"
15 struct DeadCodeElimination : public Pass {
16 // External Interface:
18 static bool doDCE(Method *M);
20 // Remove unused global values - This removes unused global values of no
21 // possible value. This currently includes unused method prototypes and
22 // unitialized global variables.
24 static bool RemoveUnusedGlobalValues(Module *M);
26 // RemoveUnusedGlobalValuesAfterLink - This function is only to be used after
27 // linking the application. It removes global variables with initializers and
28 // unreachable methods. This should only be used after an application is
29 // linked, when it is not possible for an external entity to make a global
32 // static bool RemoveUnusedGlobalValuesAfterLink(Module *M); // TODO
35 virtual bool doPassInitialization(Module *M) {
36 return RemoveUnusedGlobalValues(M);
38 virtual bool doPerMethodWork(Method *M) { return doDCE(M); }
39 virtual bool doPassFinalization(Module *M) {
40 return RemoveUnusedGlobalValues(M);
46 struct AgressiveDCE : public Pass {
47 // DoADCE - Execute the Agressive Dead Code Elimination Algorithm
49 static bool doADCE(Method *M); // Defined in ADCE.cpp
51 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