summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-07-28 17:51:49 +0000
committerChris Lattner <sabre@nondot.org>2001-07-28 17:51:49 +0000
commitb62b602fe264a28d48229a94a7a6e9b5ee466feb (patch)
treeb50fa2a643a58ddb18d4076589cf263b0283bcc0 /llvm/lib/Transforms
parentf324dc82a1eada1561bc43793e477b933f9fc7e0 (diff)
downloadbcm5719-llvm-b62b602fe264a28d48229a94a7a6e9b5ee466feb.tar.gz
bcm5719-llvm-b62b602fe264a28d48229a94a7a6e9b5ee466feb.zip
Enable the elimination of method prototypes that are not referenced
llvm-svn: 325
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/DCE.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/DCE.cpp b/llvm/lib/Transforms/Scalar/DCE.cpp
index 515fd00f81a..53b00e1649d 100644
--- a/llvm/lib/Transforms/Scalar/DCE.cpp
+++ b/llvm/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;
}
OpenPOWER on IntegriCloud