[llvm-commits] CVS: llvm/lib/VMCore/SymbolTable.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Aug 28 23:51:01 PDT 2003
Changes in directory llvm/lib/VMCore:
SymbolTable.cpp updated: 1.30 -> 1.31
---
Log message:
Fix bug: Linker/2003-08-28-TypeResolvesGlobal.ll
---
Diffs of the changes:
Index: llvm/lib/VMCore/SymbolTable.cpp
diff -u llvm/lib/VMCore/SymbolTable.cpp:1.30 llvm/lib/VMCore/SymbolTable.cpp:1.31
--- llvm/lib/VMCore/SymbolTable.cpp:1.30 Wed Jul 23 10:30:06 2003
+++ llvm/lib/VMCore/SymbolTable.cpp Thu Aug 28 23:49:54 2003
@@ -231,11 +231,21 @@
GlobalValue *ExistGV = dyn_cast<GlobalValue>(TI->second);
GlobalValue *NewGV = dyn_cast<GlobalValue>(V.second);
- if (ExistGV && NewGV && ExistGV->isExternal() && NewGV->isExternal()) {
+ if (ExistGV && NewGV) {
+ assert((ExistGV->isExternal() || NewGV->isExternal()) &&
+ "Two planes folded together with overlapping value names!");
+
+ // Make sure that ExistGV is the one we want to keep!
+ if (!NewGV->isExternal() || !NewGV->use_empty()) {
+ std::swap(NewGV, ExistGV);
+ }
+
// Ok we have two external global values. Make all uses of the new
// one use the old one...
//
- assert(ExistGV->use_empty() && "No uses allowed on untyped value!");
+ assert(NewGV->use_empty() && "No uses allowed on untyped value!");
+
+ // We cannot replaceAllUsesWith, because they have different types!
//NewGV->replaceAllUsesWith(ExistGV);
// Now we just convert it to an unnamed method... which won't get
@@ -261,10 +271,6 @@
else
M->getGlobalList().remove(cast<GlobalVariable>(NewGV));
delete NewGV;
-
- } else {
- assert(0 && "Two planes folded together with overlapping "
- "value names!");
}
} else {
insertEntry(V.first, NewType, V.second);
More information about the llvm-commits
mailing list