Implement a more powerful, simpler, pass system.  This pass system can figure
out how to run a collection of passes optimially given their behaviors and
charactaristics.

Convert code to use it.

llvm-svn: 1507
diff --git a/llvm/lib/Transforms/IPO/GlobalDCE.cpp b/llvm/lib/Transforms/IPO/GlobalDCE.cpp
index dacd329..664381c 100644
--- a/llvm/lib/Transforms/IPO/GlobalDCE.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalDCE.cpp
@@ -11,10 +11,7 @@
 #include "Support/DepthFirstIterator.h"
 #include <set>
 
-static bool RemoveUnreachableMethods(Module *M, cfg::CallGraph *CG) {
-  // Create a call graph if one is not already available...
-  cfg::CallGraph &CallGraph = CG ? *CG : *new cfg::CallGraph(M);
-  
+static bool RemoveUnreachableMethods(Module *M, cfg::CallGraph &CallGraph) {
   // Calculate which methods are reachable from the external methods in the call
   // graph.
   //
@@ -36,11 +33,7 @@
   }
 
   // Nothing to do if no unreachable methods have been found...
-  if (MethodsToDelete.empty()) {
-    // Free the created call graph if it was not passed in
-    if (&CallGraph != CG) delete &CallGraph;
-    return false;
-  }
+  if (MethodsToDelete.empty()) return false;
 
   // Unreachables methods have been found and should have no references to them,
   // delete them now.
@@ -49,11 +42,12 @@
 	 E = MethodsToDelete.end(); I != E; ++I)
     delete CallGraph.removeMethodFromModule(*I);
 
-  // Free the created call graph if it was not passed in
-  if (&CallGraph != CG) delete &CallGraph;
   return true;
 }
 
-bool GlobalDCE::run(Module *M, cfg::CallGraph *CG = 0) {
-  return RemoveUnreachableMethods(M, CG);
+bool GlobalDCE::run(Module *M) {
+  // TODO: FIXME: GET THE CALL GRAPH FROM THE PASS!
+  // Create a call graph if one is not already available...
+  cfg::CallGraph CallGraph(M);
+  return RemoveUnreachableMethods(M, CallGraph);
 }