Change the GlobalAlias constructor to look a bit more like GlobalVariable.
[oota-llvm.git] / lib / Transforms / Utils / CloneModule.cpp
index 5d180a5478c5e5f02d6a7effdabcbe777b118d68..1a3641452d9e498ca8e2fb85989f044407798722 100644 (file)
@@ -67,8 +67,10 @@ Module *llvm::CloneModule(const Module *M, ValueToValueMapTy &VMap) {
   // Loop over the aliases in the module
   for (Module::const_alias_iterator I = M->alias_begin(), E = M->alias_end();
        I != E; ++I) {
-    GlobalAlias *GA = new GlobalAlias(I->getType(), I->getLinkage(),
-                                      I->getName(), nullptr, New);
+    auto *PTy = cast<PointerType>(I->getType());
+    auto *GA =
+        new GlobalAlias(PTy->getElementType(), I->getLinkage(), I->getName(),
+                        nullptr, New, PTy->getAddressSpace());
     GA->copyAttributesFrom(I);
     VMap[I] = GA;
   }