summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO/GlobalDCE.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-06-25 16:13:21 +0000
committerChris Lattner <sabre@nondot.org>2002-06-25 16:13:21 +0000
commit0b12b5f50ec77a8bd01b92d287c52d748619bb4b (patch)
tree5764db59facb124b023f1de96f0e45d37657c82e /lib/Transforms/IPO/GlobalDCE.cpp
parent18961504fc2b299578dba817900a0696cf3ccc4d (diff)
downloadllvm-0b12b5f50ec77a8bd01b92d287c52d748619bb4b.tar.gz
llvm-0b12b5f50ec77a8bd01b92d287c52d748619bb4b.tar.bz2
llvm-0b12b5f50ec77a8bd01b92d287c52d748619bb4b.tar.xz
MEGAPATCH checkin.
For details, See: docs/2002-06-25-MegaPatchInfo.txt git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2778 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/GlobalDCE.cpp')
-rw-r--r--lib/Transforms/IPO/GlobalDCE.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp
index 8da9f0481e..d69a998cb0 100644
--- a/lib/Transforms/IPO/GlobalDCE.cpp
+++ b/lib/Transforms/IPO/GlobalDCE.cpp
@@ -15,7 +15,7 @@
static Statistic<> NumRemoved("globaldce\t- Number of global values removed");
-static bool RemoveUnreachableFunctions(Module *M, CallGraph &CallGraph) {
+static bool RemoveUnreachableFunctions(Module &M, CallGraph &CallGraph) {
// Calculate which functions are reachable from the external functions in the
// call graph.
//
@@ -27,10 +27,10 @@ static bool RemoveUnreachableFunctions(Module *M, CallGraph &CallGraph) {
// The second pass removes the functions that need to be removed.
//
std::vector<CallGraphNode*> FunctionsToDelete; // Track unused functions
- for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) {
- CallGraphNode *N = CallGraph[*I];
+ for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
+ CallGraphNode *N = CallGraph[I];
if (!ReachableNodes.count(N)) { // Not reachable??
- (*I)->dropAllReferences();
+ I->dropAllReferences();
N->removeAllCalledMethods();
FunctionsToDelete.push_back(N);
++NumRemoved;
@@ -50,17 +50,16 @@ static bool RemoveUnreachableFunctions(Module *M, CallGraph &CallGraph) {
return true;
}
-static bool RemoveUnreachableGlobalVariables(Module *M) {
+static bool RemoveUnreachableGlobalVariables(Module &M) {
bool Changed = false;
// Eliminate all global variables that are unused, and that are internal, or
// do not have an initializer.
//
- for (Module::giterator I = M->gbegin(); I != M->gend(); )
- if (!(*I)->use_empty() ||
- ((*I)->hasExternalLinkage() && (*I)->hasInitializer()))
+ for (Module::giterator I = M.gbegin(); I != M.gend(); )
+ if (!I->use_empty() || (I->hasExternalLinkage() && I->hasInitializer()))
++I; // Cannot eliminate global variable
else {
- delete M->getGlobalList().remove(I);
+ I = M.getGlobalList().erase(I);
++NumRemoved;
Changed = true;
}
@@ -74,7 +73,7 @@ namespace {
// run - Do the GlobalDCE pass on the specified module, optionally updating
// the specified callgraph to reflect the changes.
//
- bool run(Module *M) {
+ bool run(Module &M) {
return RemoveUnreachableFunctions(M, getAnalysis<CallGraph>()) |
RemoveUnreachableGlobalVariables(M);
}