mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-24 06:30:19 +00:00
Preserve the address space when generating bitcasts for MemTransferInst in ConvertToScalarInfo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122462 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8e68c38735
commit
e90a6333c3
@ -498,7 +498,13 @@ void ConvertToScalarInfo::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI,
|
|||||||
// pointer (bitcasted), then a store to our new alloca.
|
// pointer (bitcasted), then a store to our new alloca.
|
||||||
assert(MTI->getRawDest() == Ptr && "Neither use is of pointer?");
|
assert(MTI->getRawDest() == Ptr && "Neither use is of pointer?");
|
||||||
Value *SrcPtr = MTI->getSource();
|
Value *SrcPtr = MTI->getSource();
|
||||||
SrcPtr = Builder.CreateBitCast(SrcPtr, NewAI->getType());
|
const PointerType* SPTy = cast<PointerType>(SrcPtr->getType());
|
||||||
|
const PointerType* AIPTy = cast<PointerType>(NewAI->getType());
|
||||||
|
if (SPTy->getAddressSpace() != AIPTy->getAddressSpace()) {
|
||||||
|
AIPTy = PointerType::get(AIPTy->getElementType(),
|
||||||
|
SPTy->getAddressSpace());
|
||||||
|
}
|
||||||
|
SrcPtr = Builder.CreateBitCast(SrcPtr, AIPTy);
|
||||||
|
|
||||||
LoadInst *SrcVal = Builder.CreateLoad(SrcPtr, "srcval");
|
LoadInst *SrcVal = Builder.CreateLoad(SrcPtr, "srcval");
|
||||||
SrcVal->setAlignment(MTI->getAlignment());
|
SrcVal->setAlignment(MTI->getAlignment());
|
||||||
@ -509,7 +515,14 @@ void ConvertToScalarInfo::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI,
|
|||||||
assert(MTI->getRawSource() == Ptr && "Neither use is of pointer?");
|
assert(MTI->getRawSource() == Ptr && "Neither use is of pointer?");
|
||||||
LoadInst *SrcVal = Builder.CreateLoad(NewAI, "srcval");
|
LoadInst *SrcVal = Builder.CreateLoad(NewAI, "srcval");
|
||||||
|
|
||||||
Value *DstPtr = Builder.CreateBitCast(MTI->getDest(), NewAI->getType());
|
const PointerType* DPTy = cast<PointerType>(MTI->getDest()->getType());
|
||||||
|
const PointerType* AIPTy = cast<PointerType>(NewAI->getType());
|
||||||
|
if (DPTy->getAddressSpace() != AIPTy->getAddressSpace()) {
|
||||||
|
AIPTy = PointerType::get(AIPTy->getElementType(),
|
||||||
|
DPTy->getAddressSpace());
|
||||||
|
}
|
||||||
|
Value *DstPtr = Builder.CreateBitCast(MTI->getDest(), AIPTy);
|
||||||
|
|
||||||
StoreInst *NewStore = Builder.CreateStore(SrcVal, DstPtr);
|
StoreInst *NewStore = Builder.CreateStore(SrcVal, DstPtr);
|
||||||
NewStore->setAlignment(MTI->getAlignment());
|
NewStore->setAlignment(MTI->getAlignment());
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user