comparison gen/passes/StripExternals.cpp @ 1551:ed0feda76820

DOUT is deprecated, use DEBUG(errs()) instead
author Benjamin Kramer <benny.kra@gmail.com>
date Mon, 27 Jul 2009 11:44:01 +0200
parents 259b031f3d22
children
comparison
equal deleted inserted replaced
1550:c704fea92f80 1551:ed0feda76820
22 #include "llvm/Module.h" 22 #include "llvm/Module.h"
23 #include "llvm/Pass.h" 23 #include "llvm/Pass.h"
24 #include "llvm/ADT/Statistic.h" 24 #include "llvm/ADT/Statistic.h"
25 #include "llvm/Support/Compiler.h" 25 #include "llvm/Support/Compiler.h"
26 #include "llvm/Support/Debug.h" 26 #include "llvm/Support/Debug.h"
27 #include "llvm/Support/raw_ostream.h"
27 using namespace llvm; 28 using namespace llvm;
28 29
29 STATISTIC(NumFunctions, "Number of function bodies removed"); 30 STATISTIC(NumFunctions, "Number of function bodies removed");
30 STATISTIC(NumVariables, "Number of global initializers removed"); 31 STATISTIC(NumVariables, "Number of global initializers removed");
31 32
53 if (I->hasAvailableExternallyLinkage()) { 54 if (I->hasAvailableExternallyLinkage()) {
54 assert(!I->isDeclaration()&&"Declarations can't be available_externally"); 55 assert(!I->isDeclaration()&&"Declarations can't be available_externally");
55 Changed = true; 56 Changed = true;
56 ++NumFunctions; 57 ++NumFunctions;
57 if (I->use_empty()) { 58 if (I->use_empty()) {
58 DOUT << "Deleting function: " << *I; 59 DEBUG(errs() << "Deleting function: " << *I);
59 Module::iterator todelete = I; 60 Module::iterator todelete = I;
60 ++I; 61 ++I;
61 todelete->eraseFromParent(); 62 todelete->eraseFromParent();
62 continue; 63 continue;
63 } else { 64 } else {
64 I->deleteBody(); 65 I->deleteBody();
65 DOUT << "Deleted function body: " << *I; 66 DEBUG(errs() << "Deleted function body: " << *I);
66 } 67 }
67 } 68 }
68 ++I; 69 ++I;
69 } 70 }
70 71
73 if (I->hasAvailableExternallyLinkage()) { 74 if (I->hasAvailableExternallyLinkage()) {
74 assert(!I->isDeclaration()&&"Declarations can't be available_externally"); 75 assert(!I->isDeclaration()&&"Declarations can't be available_externally");
75 Changed = true; 76 Changed = true;
76 ++NumVariables; 77 ++NumVariables;
77 if (I->use_empty()) { 78 if (I->use_empty()) {
78 DOUT << "Deleting global: " << *I; 79 DEBUG(errs() << "Deleting global: " << *I);
79 Module::global_iterator todelete = I; 80 Module::global_iterator todelete = I;
80 ++I; 81 ++I;
81 todelete->eraseFromParent(); 82 todelete->eraseFromParent();
82 continue; 83 continue;
83 } else { 84 } else {
84 I->setInitializer(0); 85 I->setInitializer(0);
85 I->setLinkage(GlobalValue::ExternalLinkage); 86 I->setLinkage(GlobalValue::ExternalLinkage);
86 DOUT << "Deleted initializer: " << *I; 87 DEBUG(errs() << "Deleted initializer: " << *I);
87 } 88 }
88 } 89 }
89 ++I; 90 ++I;
90 } 91 }
91 92