summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/SymbolStripping.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-11-22 01:29:35 +0000
committerChris Lattner <sabre@nondot.org>2003-11-22 01:29:35 +0000
commit1ad805977d7406e7337e9a8dd3fc6d4fff136c5b (patch)
tree3dc373585b8d0f84f5be27b9d06adca692606755 /llvm/lib/Transforms/Scalar/SymbolStripping.cpp
parente8e932a67177d559268c7b7cfc8a2b0149f13dd1 (diff)
downloadbcm5719-llvm-1ad805977d7406e7337e9a8dd3fc6d4fff136c5b.tar.gz
bcm5719-llvm-1ad805977d7406e7337e9a8dd3fc6d4fff136c5b.zip
Finegrainify namespacification
The module stripping pass should not strip symbols on external globals llvm-svn: 10157
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SymbolStripping.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/SymbolStripping.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/llvm/lib/Transforms/Scalar/SymbolStripping.cpp b/llvm/lib/Transforms/Scalar/SymbolStripping.cpp
index 9e058e7939d..32ebdd36cbc 100644
--- a/llvm/lib/Transforms/Scalar/SymbolStripping.cpp
+++ b/llvm/lib/Transforms/Scalar/SymbolStripping.cpp
@@ -25,8 +25,7 @@
#include "llvm/Module.h"
#include "llvm/SymbolTable.h"
#include "llvm/Pass.h"
-
-namespace llvm {
+using namespace llvm;
static bool StripSymbolTable(SymbolTable &SymTab) {
bool RemovedSymbol = false;
@@ -34,15 +33,20 @@ static bool StripSymbolTable(SymbolTable &SymTab) {
for (SymbolTable::iterator I = SymTab.begin(); I != SymTab.end(); ++I) {
std::map<const std::string, Value *> &Plane = I->second;
- SymbolTable::type_iterator B;
- while ((B = Plane.begin()) != Plane.end()) { // Found nonempty type plane!
+ SymbolTable::type_iterator B = Plane.begin();
+ while (B != Plane.end()) { // Found nonempty type plane!
Value *V = B->second;
- if (isa<Constant>(V) || isa<Type>(V))
- SymTab.type_remove(B);
- else
- V->setName("", &SymTab); // Set name to "", removing from symbol table!
- RemovedSymbol = true;
- assert(Plane.begin() != B && "Symbol not removed from table!");
+ if (isa<Constant>(V) || isa<Type>(V)) {
+ SymTab.type_remove(B++);
+ RemovedSymbol = true;
+ } else {
+ ++B;
+ 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");
}
-Pass *createSymbolStrippingPass() {
+Pass *llvm::createSymbolStrippingPass() {
return new SymbolStripping();
}
-Pass *createFullSymbolStrippingPass() {
+Pass *llvm::createFullSymbolStrippingPass() {
return new FullSymbolStripping();
}
-
-} // End llvm namespace
OpenPOWER on IntegriCloud