diff options
| author | Chris Lattner <sabre@nondot.org> | 2002-01-21 07:31:50 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2002-01-21 07:31:50 +0000 |
| commit | f4de63f65fa995e68e3cd268117ab065068be413 (patch) | |
| tree | 2fd8cd44af0f23dafd94102c1c0152b1cd82fe4d /lib/Transforms/IPO/GlobalDCE.cpp | |
| parent | aff5bcebb7fb9880e0a3518a8e7c999e738d531c (diff) | |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1507 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/GlobalDCE.cpp')
| -rw-r--r-- | lib/Transforms/IPO/GlobalDCE.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index dacd3295ef..664381cec6 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/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 @@ static bool RemoveUnreachableMethods(Module *M, cfg::CallGraph *CG) { } // 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 @@ static bool RemoveUnreachableMethods(Module *M, cfg::CallGraph *CG) { 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); } |
