aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Linker
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-12-20 23:14:57 +0000
committerChris Lattner <sabre@nondot.org>2011-12-20 23:14:57 +0000
commit1a31f3b90c012b067f8509546e1e037051e6482d (patch)
tree34dac90a600612229631eb3ec484b47d030c525f /lib/Linker
parentaee718beac4fada5914d773db38002d95cae5e0d (diff)
downloadexternal_llvm-1a31f3b90c012b067f8509546e1e037051e6482d.zip
external_llvm-1a31f3b90c012b067f8509546e1e037051e6482d.tar.gz
external_llvm-1a31f3b90c012b067f8509546e1e037051e6482d.tar.bz2
Fix a nasty bug in the type remapping stuff that I added that is breaking kc++ on
the build bot in some cases. The basic issue happens when a source module contains both a "%foo" type and a "%foo.42" type. It will see the later one, check to see if the destination module contains a "%foo" type, and it will return true... because both the source and destination modules are in the same LLVMContext. We don't want to map source types to other source types, so don't do the remapping if the mapped type came from the source module. Unfortunately, I've been unable to reduce a decent testcase for this, kc++ is pretty great that way. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147010 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Linker')
-rw-r--r--lib/Linker/LinkModules.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index 4f6013e..ba4221d 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.cpp
@@ -148,6 +148,7 @@ bool TypeMapTy::areTypesIsomorphic(Type *DstTy, Type *SrcTy) {
if (PointerType *PT = dyn_cast<PointerType>(DstTy)) {
if (PT->getAddressSpace() != cast<PointerType>(SrcTy)->getAddressSpace())
return false;
+
} else if (FunctionType *FT = dyn_cast<FunctionType>(DstTy)) {
if (FT->isVarArg() != cast<FunctionType>(SrcTy)->isVarArg())
return false;
@@ -567,6 +568,9 @@ void ModuleLinker::computeTypeMapping() {
std::vector<StructType*> SrcStructTypes;
SrcM->findUsedStructTypes(SrcStructTypes);
+ SmallPtrSet<StructType*, 32> SrcStructTypesSet(SrcStructTypes.begin(),
+ SrcStructTypes.end());
+
for (unsigned i = 0, e = SrcStructTypes.size(); i != e; ++i) {
StructType *ST = SrcStructTypes[i];
if (!ST->hasName()) continue;
@@ -579,7 +583,10 @@ void ModuleLinker::computeTypeMapping() {
// Check to see if the destination module has a struct with the prefix name.
if (StructType *DST = DstM->getTypeByName(ST->getName().substr(0, DotPos)))
- TypeMap.addTypeMapping(DST, ST);
+ // Don't use it if this actually came from the source module. They're in
+ // the same LLVMContext after all.
+ if (!SrcStructTypesSet.count(DST))
+ TypeMap.addTypeMapping(DST, ST);
}