summaryrefslogtreecommitdiff
path: root/lib/VMCore/SymbolTable.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-29 04:49:54 +0000
committerChris Lattner <sabre@nondot.org>2003-08-29 04:49:54 +0000
commit652f032ce9d57dbe613bbd57f76e1f54056e6b11 (patch)
tree6795f320cd5c03a1fc074315207dfb0a9e35a802 /lib/VMCore/SymbolTable.cpp
parent0c49b892987687c9eb6f855f00d8c24552100b74 (diff)
downloadllvm-652f032ce9d57dbe613bbd57f76e1f54056e6b11.tar.gz
llvm-652f032ce9d57dbe613bbd57f76e1f54056e6b11.tar.bz2
llvm-652f032ce9d57dbe613bbd57f76e1f54056e6b11.tar.xz
Fix bug: Linker/2003-08-28-TypeResolvesGlobal.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8202 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/SymbolTable.cpp')
-rw-r--r--lib/VMCore/SymbolTable.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/VMCore/SymbolTable.cpp b/lib/VMCore/SymbolTable.cpp
index ddd769d075..b5476178db 100644
--- a/lib/VMCore/SymbolTable.cpp
+++ b/lib/VMCore/SymbolTable.cpp
@@ -231,11 +231,21 @@ void SymbolTable::refineAbstractType(const DerivedType *OldType,
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 @@ void SymbolTable::refineAbstractType(const DerivedType *OldType,
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);