Function *IRLinker::copyFunctionProto(const Function *SF) {
// If there is no linkage to be performed or we are linking from the source,
// bring SF over.
- auto *F =
- Function::Create(TypeMap.get(SF->getFunctionType()),
- GlobalValue::ExternalLinkage, SF->getName(), &DstM);
+ auto *F = Function::Create(TypeMap.get(SF->getFunctionType()),
+ GlobalValue::ExternalLinkage,
+ SF->getAddressSpace(), SF->getName(), &DstM);
F->copyAttributesFrom(SF);
F->setAttributes(mapAttributeTypes(F->getContext(), F->getAttributes()));
return F;
else if (SGV->getValueType()->isFunctionTy())
NewGV =
Function::Create(cast<FunctionType>(TypeMap.get(SGV->getValueType())),
- GlobalValue::ExternalLinkage, SGV->getName(), &DstM);
+ GlobalValue::ExternalLinkage, SGV->getAddressSpace(),
+ SGV->getName(), &DstM);
else
NewGV =
new GlobalVariable(DstM, TypeMap.get(SGV->getValueType()),
--- /dev/null
+; RUN: llvm-link %s -S | FileCheck %s
+
+@G = addrspace(2) global i32 256
+; CHECK: @G = addrspace(2) global i32
+
+@GA = alias i32, i32 addrspace(2)* @G
+; CHECK: @GA = alias i32, i32 addrspace(2)* @G
+
+define void @foo() addrspace(3) {
+; CHECK: define void @foo() addrspace(3)
+ ret void
+}