/// Creates prototypes for functions that are lazily linked on the fly. This
/// speeds up linking for modules with many/ lazily linked functions of which
/// few get used.
-class ValueMaterializerTy : public ValueMaterializer {
+class ValueMaterializerTy final : public ValueMaterializer {
TypeMapTy &TypeMap;
Module *DstM;
std::vector<GlobalValue *> &LazilyLinkGlobalValues;
const GlobalAlias *SGA) {
// If there is no linkage to be performed or we're linking from the source,
// bring over SGA.
- auto *PTy = cast<PointerType>(TypeMap.get(SGA->getType()));
- return GlobalAlias::create(PTy, SGA->getLinkage(), SGA->getName(), &DstM);
+ auto *Ty = TypeMap.get(SGA->getValueType());
+ return GlobalAlias::create(Ty, SGA->getType()->getPointerAddressSpace(),
+ SGA->getLinkage(), SGA->getName(), &DstM);
}
static GlobalValue *copyGlobalValueProto(TypeMapTy &TypeMap, Module &DstM,
DI->setName(Arg.getName()); // Copy the name over.
// Add a mapping to our mapping.
- ValueMap[&Arg] = DI;
+ ValueMap[&Arg] = &*DI;
++DI;
}