2001-06-30 04:34:07 +00:00
|
|
|
//===-- DCE.h - Functions that perform Dead Code Elimination -----*- C++ -*--=//
|
|
|
|
//
|
|
|
|
// This family of functions is useful for performing dead code elimination of
|
|
|
|
// various sorts.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_OPT_DCE_H
|
|
|
|
#define LLVM_OPT_DCE_H
|
|
|
|
|
2001-10-18 20:19:09 +00:00
|
|
|
#include "llvm/Pass.h"
|
2001-06-30 04:34:07 +00:00
|
|
|
|
|
|
|
namespace opt {
|
|
|
|
|
2001-10-18 05:21:56 +00:00
|
|
|
struct DeadCodeElimination : public Pass {
|
2001-10-18 01:31:58 +00:00
|
|
|
// External Interface:
|
|
|
|
//
|
|
|
|
static bool doDCE(Method *M);
|
|
|
|
|
|
|
|
// Remove unused global values - This removes unused global values of no
|
|
|
|
// possible value. This currently includes unused method prototypes and
|
|
|
|
// unitialized global variables.
|
|
|
|
//
|
|
|
|
static bool RemoveUnusedGlobalValues(Module *M);
|
|
|
|
|
|
|
|
// RemoveUnusedGlobalValuesAfterLink - This function is only to be used after
|
|
|
|
// linking the application. It removes global variables with initializers and
|
|
|
|
// unreachable methods. This should only be used after an application is
|
|
|
|
// linked, when it is not possible for an external entity to make a global
|
|
|
|
// value live again.
|
|
|
|
//
|
|
|
|
// static bool RemoveUnusedGlobalValuesAfterLink(Module *M); // TODO
|
|
|
|
|
|
|
|
// Pass Interface...
|
2001-10-18 05:21:56 +00:00
|
|
|
virtual bool doPassInitialization(Module *M) {
|
2001-10-18 01:31:58 +00:00
|
|
|
return RemoveUnusedGlobalValues(M);
|
|
|
|
}
|
2001-10-18 05:21:56 +00:00
|
|
|
virtual bool doPerMethodWork(Method *M) { return doDCE(M); }
|
|
|
|
virtual bool doPassFinalization(Module *M) {
|
2001-10-18 01:31:58 +00:00
|
|
|
return RemoveUnusedGlobalValues(M);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-10-18 05:21:56 +00:00
|
|
|
struct AgressiveDCE : public Pass {
|
2001-10-18 01:31:58 +00:00
|
|
|
// DoADCE - Execute the Agressive Dead Code Elimination Algorithm
|
|
|
|
//
|
|
|
|
static bool doADCE(Method *M); // Defined in ADCE.cpp
|
|
|
|
|
2001-10-18 05:21:56 +00:00
|
|
|
virtual bool doPerMethodWork(Method *M) {
|
2001-10-18 01:31:58 +00:00
|
|
|
return doADCE(M);
|
|
|
|
}
|
|
|
|
};
|
2001-06-30 04:34:07 +00:00
|
|
|
|
2001-06-30 06:37:16 +00:00
|
|
|
|
|
|
|
|
2001-06-30 04:34:07 +00:00
|
|
|
// SimplifyCFG - This function is used to do simplification of a CFG. For
|
|
|
|
// example, it adjusts branches to branches to eliminate the extra hop, it
|
|
|
|
// eliminates unreachable basic blocks, and does other "peephole" optimization
|
|
|
|
// of the CFG. It returns true if a modification was made, and returns an
|
|
|
|
// iterator that designates the first element remaining after the block that
|
|
|
|
// was deleted.
|
|
|
|
//
|
|
|
|
// WARNING: The entry node of a method may not be simplified.
|
|
|
|
//
|
|
|
|
bool SimplifyCFG(Method::iterator &BBIt);
|
|
|
|
|
|
|
|
} // End namespace opt
|
|
|
|
|
|
|
|
#endif
|