mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-02 16:56:39 +00:00
when linking globals, make sure to preserve the address space of the global.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52810 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
83b28890d8
commit
a534b0f7bf
@ -575,7 +575,8 @@ static bool LinkGlobals(Module *Dest, const Module *Src,
|
|||||||
GlobalVariable *NewDGV =
|
GlobalVariable *NewDGV =
|
||||||
new GlobalVariable(SGV->getType()->getElementType(),
|
new GlobalVariable(SGV->getType()->getElementType(),
|
||||||
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
|
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
|
||||||
SGV->getName(), Dest);
|
SGV->getName(), Dest, false,
|
||||||
|
SGV->getType()->getAddressSpace());
|
||||||
// Propagate alignment, visibility and section info.
|
// Propagate alignment, visibility and section info.
|
||||||
CopyGVAttributes(NewDGV, SGV);
|
CopyGVAttributes(NewDGV, SGV);
|
||||||
|
|
||||||
@ -599,7 +600,8 @@ static bool LinkGlobals(Module *Dest, const Module *Src,
|
|||||||
GlobalVariable *NewDGV =
|
GlobalVariable *NewDGV =
|
||||||
new GlobalVariable(SGV->getType()->getElementType(),
|
new GlobalVariable(SGV->getType()->getElementType(),
|
||||||
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
|
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
|
||||||
"", Dest);
|
"", Dest, false,
|
||||||
|
SGV->getType()->getAddressSpace());
|
||||||
|
|
||||||
// Set alignment allowing CopyGVAttributes merge it with alignment of SGV.
|
// Set alignment allowing CopyGVAttributes merge it with alignment of SGV.
|
||||||
NewDGV->setAlignment(DGV->getAlignment());
|
NewDGV->setAlignment(DGV->getAlignment());
|
||||||
@ -634,7 +636,8 @@ static bool LinkGlobals(Module *Dest, const Module *Src,
|
|||||||
GlobalVariable *NewDGV =
|
GlobalVariable *NewDGV =
|
||||||
new GlobalVariable(SGV->getType()->getElementType(),
|
new GlobalVariable(SGV->getType()->getElementType(),
|
||||||
DGVar->isConstant(), DGVar->getLinkage(),
|
DGVar->isConstant(), DGVar->getLinkage(),
|
||||||
/*init*/0, DGVar->getName(), Dest);
|
/*init*/0, DGVar->getName(), Dest, false,
|
||||||
|
SGV->getType()->getAddressSpace());
|
||||||
CopyGVAttributes(NewDGV, DGVar);
|
CopyGVAttributes(NewDGV, DGVar);
|
||||||
DGV->replaceAllUsesWith(ConstantExpr::getBitCast(NewDGV,
|
DGV->replaceAllUsesWith(ConstantExpr::getBitCast(NewDGV,
|
||||||
DGVar->getType()));
|
DGVar->getType()));
|
||||||
@ -1166,7 +1169,8 @@ static bool LinkAppendingVars(Module *M,
|
|||||||
// Create the new global variable...
|
// Create the new global variable...
|
||||||
GlobalVariable *NG =
|
GlobalVariable *NG =
|
||||||
new GlobalVariable(NewType, G1->isConstant(), G1->getLinkage(),
|
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.
|
// Propagate alignment, visibility and section info.
|
||||||
CopyGVAttributes(NG, G1);
|
CopyGVAttributes(NG, G1);
|
||||||
|
9
test/Linker/2008-06-26-AddressSpace.ll
Normal file
9
test/Linker/2008-06-26-AddressSpace.ll
Normal file
@ -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
|
||||||
|
|
||||||
|
@G = global i32 256 addrspace(2)
|
Loading…
Reference in New Issue
Block a user