[llvm-commits] [llvm] r52810 - in /llvm/trunk: lib/Linker/LinkModules.cpp test/Linker/2008-06-26-AddressSpace.ll
Chris Lattner
sabre at nondot.org
Thu Jun 26 20:10:27 PDT 2008
Author: lattner
Date: Thu Jun 26 22:10:24 2008
New Revision: 52810
URL: http://llvm.org/viewvc/llvm-project?rev=52810&view=rev
Log:
when linking globals, make sure to preserve the address space of the global.
Added:
llvm/trunk/test/Linker/2008-06-26-AddressSpace.ll
Modified:
llvm/trunk/lib/Linker/LinkModules.cpp
Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=52810&r1=52809&r2=52810&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Thu Jun 26 22:10:24 2008
@@ -575,7 +575,8 @@
GlobalVariable *NewDGV =
new GlobalVariable(SGV->getType()->getElementType(),
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
- SGV->getName(), Dest);
+ SGV->getName(), Dest, false,
+ SGV->getType()->getAddressSpace());
// Propagate alignment, visibility and section info.
CopyGVAttributes(NewDGV, SGV);
@@ -599,7 +600,8 @@
GlobalVariable *NewDGV =
new GlobalVariable(SGV->getType()->getElementType(),
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
- "", Dest);
+ "", Dest, false,
+ SGV->getType()->getAddressSpace());
// Set alignment allowing CopyGVAttributes merge it with alignment of SGV.
NewDGV->setAlignment(DGV->getAlignment());
@@ -634,7 +636,8 @@
GlobalVariable *NewDGV =
new GlobalVariable(SGV->getType()->getElementType(),
DGVar->isConstant(), DGVar->getLinkage(),
- /*init*/0, DGVar->getName(), Dest);
+ /*init*/0, DGVar->getName(), Dest, false,
+ SGV->getType()->getAddressSpace());
CopyGVAttributes(NewDGV, DGVar);
DGV->replaceAllUsesWith(ConstantExpr::getBitCast(NewDGV,
DGVar->getType()));
@@ -1166,7 +1169,8 @@
// Create the new global variable...
GlobalVariable *NG =
new GlobalVariable(NewType, G1->isConstant(), G1->getLinkage(),
- /*init*/0, First->first, M, G1->isThreadLocal());
+ /*init*/0, First->first, M, G1->isThreadLocal(),
+ G1->getType()->getAddressSpace());
// Propagate alignment, visibility and section info.
CopyGVAttributes(NG, G1);
Added: llvm/trunk/test/Linker/2008-06-26-AddressSpace.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/2008-06-26-AddressSpace.ll?rev=52810&view=auto
==============================================================================
--- llvm/trunk/test/Linker/2008-06-26-AddressSpace.ll (added)
+++ llvm/trunk/test/Linker/2008-06-26-AddressSpace.ll Thu Jun 26 22:10:24 2008
@@ -0,0 +1,9 @@
+; Test linking two functions with different prototypes and two globals
+; in different modules.
+; RUN: llvm-as %s -o %t.foo1.bc -f
+; RUN: echo | llvm-as -o %t.foo2.bc -f
+; RUN: llvm-link %t.foo2.bc %t.foo1.bc | llvm-dis | grep {addrspace(2)}
+; RUN: llvm-link %t.foo1.bc %t.foo2.bc | llvm-dis | grep {addrspace(2)}
+; rdar://6038021
+
+ at G = global i32 256 addrspace(2)
More information about the llvm-commits
mailing list