diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -4547,8 +4547,9 @@ } // Create the new alias itself, but don't set a name yet. + unsigned AS = cast(Aliasee->getType())->getAddressSpace(); auto *GA = - llvm::GlobalAlias::create(DeclTy, 0, LT, "", Aliasee, &getModule()); + llvm::GlobalAlias::create(DeclTy, AS, LT, "", Aliasee, &getModule()); if (Entry) { if (GA->getAliasee() == Entry) {