Revert "Support for ThinLTO function importing and symbol linking."
[oota-llvm.git] / lib / Linker / LinkModules.cpp
index 9d5e0b475d8b2a470316aa9bf98c639218d6cda3..94b12aae1f09f1519fce99801669bcf8b79dcd7d 100644 (file)
@@ -365,7 +365,7 @@ class ModuleLinker;
 /// 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;
@@ -585,8 +585,9 @@ static GlobalAlias *copyGlobalAliasProto(TypeMapTy &TypeMap, Module &DstM,
                                          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,
@@ -1218,7 +1219,7 @@ bool ModuleLinker::linkFunctionBody(Function &Dst, Function &Src) {
     DI->setName(Arg.getName());  // Copy the name over.
 
     // Add a mapping to our mapping.
-    ValueMap[&Arg] = DI;
+    ValueMap[&Arg] = &*DI;
     ++DI;
   }