diff options
author | Chris Lattner <sabre@nondot.org> | 2001-07-28 17:51:49 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-07-28 17:51:49 +0000 |
commit | ee7cb2986657411de6e2eab9ab896d5275d9e1b4 (patch) | |
tree | 0d0b9ff547ba6e8f66507b81d736c27e7c90a1e0 /lib/Transforms | |
parent | 7c5014767f8f4696365f663bf0f4ddb4abfbe068 (diff) | |
download | external_llvm-ee7cb2986657411de6e2eab9ab896d5275d9e1b4.zip external_llvm-ee7cb2986657411de6e2eab9ab896d5275d9e1b4.tar.gz external_llvm-ee7cb2986657411de6e2eab9ab896d5275d9e1b4.tar.bz2 |
Enable the elimination of method prototypes that are not referenced
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/DCE.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp index 515fd00..53b00e1 100644 --- a/lib/Transforms/Scalar/DCE.cpp +++ b/lib/Transforms/Scalar/DCE.cpp @@ -9,6 +9,7 @@ // predecessor only has one successor. // * Eliminates PHI nodes for basic blocks with a single predecessor // * Eliminates a basic block that only contains an unconditional branch +// * Eliminates method prototypes that are not referenced // // TODO: This should REALLY be worklist driven instead of iterative. Right now, // we scan linearly through values, removing unused ones as we go. The problem @@ -323,9 +324,23 @@ bool opt::DoDeadCodeElimination(Method *M) { return Changed; } -bool opt::DoDeadCodeElimination(Module *C) { - bool Val = C->reduceApply(DoDeadCodeElimination); +bool opt::DoDeadCodeElimination(Module *Mod) { + bool Changed = false; + + for (Module::iterator MI = Mod->begin(); MI != Mod->end(); ) { + Method *Meth = *MI; + if (!Meth->isExternal()) { // DCE normal methods + Changed |= DoDeadCodeElimination(Meth); + ++MI; // Next method please + } else if (Meth->use_size() == 0) { // No references to prototype? + //cerr << "Removing method proto: " << Meth->getName() << endl; + delete Mod->getMethodList().remove(MI); // Remove prototype + // Remove moves iterator to point to the next one automatically + } else { + ++MI; // Skip prototype in use. + } + } - while (DoRemoveUnusedConstants(C)) Val = true; - return Val; + while (DoRemoveUnusedConstants(Mod)) Changed = true; + return Changed; } |