1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

Finegrainify namespacification

The module stripping pass should not strip symbols on external globals

llvm-svn: 10157
This commit is contained in:
Chris Lattner 2003-11-22 01:29:35 +00:00
parent d0f417ffa7
commit 3b71386e30

View File

@ -25,8 +25,7 @@
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/SymbolTable.h" #include "llvm/SymbolTable.h"
#include "llvm/Pass.h" #include "llvm/Pass.h"
using namespace llvm;
namespace llvm {
static bool StripSymbolTable(SymbolTable &SymTab) { static bool StripSymbolTable(SymbolTable &SymTab) {
bool RemovedSymbol = false; bool RemovedSymbol = false;
@ -34,15 +33,20 @@ static bool StripSymbolTable(SymbolTable &SymTab) {
for (SymbolTable::iterator I = SymTab.begin(); I != SymTab.end(); ++I) { for (SymbolTable::iterator I = SymTab.begin(); I != SymTab.end(); ++I) {
std::map<const std::string, Value *> &Plane = I->second; std::map<const std::string, Value *> &Plane = I->second;
SymbolTable::type_iterator B; SymbolTable::type_iterator B = Plane.begin();
while ((B = Plane.begin()) != Plane.end()) { // Found nonempty type plane! while (B != Plane.end()) { // Found nonempty type plane!
Value *V = B->second; Value *V = B->second;
if (isa<Constant>(V) || isa<Type>(V)) if (isa<Constant>(V) || isa<Type>(V)) {
SymTab.type_remove(B); SymTab.type_remove(B++);
else RemovedSymbol = true;
V->setName("", &SymTab); // Set name to "", removing from symbol table! } else {
RemovedSymbol = true; ++B;
assert(Plane.begin() != B && "Symbol not removed from table!"); if (!isa<GlobalValue>(V) || cast<GlobalValue>(V)->hasInternalLinkage()){
// Set name to "", removing from symbol table!
V->setName("", &SymTab);
RemovedSymbol = true;
}
}
} }
} }
@ -69,12 +73,10 @@ namespace {
"Strip symbols from module and functions"); "Strip symbols from module and functions");
} }
Pass *createSymbolStrippingPass() { Pass *llvm::createSymbolStrippingPass() {
return new SymbolStripping(); return new SymbolStripping();
} }
Pass *createFullSymbolStrippingPass() { Pass *llvm::createFullSymbolStrippingPass() {
return new FullSymbolStripping(); return new FullSymbolStripping();
} }
} // End llvm namespace