SmallPtrSet<StructType*, 16> DstResolvedOpaqueTypes;
public:
- TypeMapTy(TypeSet &Set) : DstStructTypesSet(Set) {}
+ TypeMapTy() {}
- TypeSet &DstStructTypesSet;
/// Indicate that the specified type in the destination module is conceptually
/// equivalent to the specified type in the source module.
void addTypeMapping(Type *DstTy, Type *SrcTy);
SpeculativeDstOpaqueTypes.size());
for (StructType *Ty : SpeculativeDstOpaqueTypes)
DstResolvedOpaqueTypes.erase(Ty);
+ } else {
+ for (Type *Ty : SpeculativeTypes)
+ if (auto *STy = dyn_cast<StructType>(Ty))
+ if (STy->hasName())
+ STy->setName("");
}
SpeculativeTypes.clear();
SpeculativeDstOpaqueTypes.clear();
if (STy->isOpaque()) {
// A named structure type from src module is used. Add it to the Set of
// identified structs in the destination module.
- DstStructTypesSet.insert(STy);
return *Entry = STy;
}
StructType *DTy = StructType::create(STy->getContext());
// A new identified structure type was created. Add it to the set of
// identified structs in the destination module.
- DstStructTypesSet.insert(DTy);
*Entry = DTy;
SmallVector<Type*, 4> ElementTypes;
Linker::DiagnosticHandlerFunction DiagnosticHandler;
public:
- ModuleLinker(Module *dstM, TypeSet &Set, Module *srcM,
+ ModuleLinker(Module *dstM, Module *srcM,
Linker::DiagnosticHandlerFunction DiagnosticHandler)
- : DstM(dstM), SrcM(srcM), TypeMap(Set),
+ : DstM(dstM), SrcM(srcM),
ValMaterializer(TypeMap, DstM, LazilyLinkFunctions),
DiagnosticHandler(DiagnosticHandler) {}
// we prefer to take the '%C' version. So we are then left with both
// '%C.1' and '%C' being used for the same types. This leads to some
// variables using one type and some using the other.
- if (!SrcStructTypesSet.count(DST) && TypeMap.DstStructTypesSet.count(DST))
+ if (!SrcStructTypesSet.count(DST))
TypeMap.addTypeMapping(DST, ST);
}
void Linker::init(Module *M, DiagnosticHandlerFunction DiagnosticHandler) {
this->Composite = M;
this->DiagnosticHandler = DiagnosticHandler;
-
- TypeFinder StructTypes;
- StructTypes.run(*M, true);
- IdentifiedStructTypes.insert(StructTypes.begin(), StructTypes.end());
}
Linker::Linker(Module *M, DiagnosticHandlerFunction DiagnosticHandler) {
}
bool Linker::linkInModule(Module *Src) {
- ModuleLinker TheLinker(Composite, IdentifiedStructTypes, Src,
- DiagnosticHandler);
+ ModuleLinker TheLinker(Composite, Src, DiagnosticHandler);
return TheLinker.run();
}