summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Sotkin <alexey.sotkin@intel.com>2018-04-07 10:23:59 +0300
committerAlexey Sotkin <alexey.sotkin@intel.com>2018-04-11 22:46:03 +0300
commit622f3ae9b48dd18e5142c204de23dfe83f7e8497 (patch)
tree6879e8c7680b8c746a9666ae2203ab0bb0c95fca
parentcc3e0f0b690ec774a0522d22b7ceaf2a3702566b (diff)
Update SPIR-V/LLVM Translator to use new MemIntrinsics API
Fixes #1
-rw-r--r--lib/SPIRV/SPIRVLowerMemmove.cpp9
-rw-r--r--lib/SPIRV/SPIRVWriter.cpp9
2 files changed, 10 insertions, 8 deletions
diff --git a/lib/SPIRV/SPIRVLowerMemmove.cpp b/lib/SPIRV/SPIRVLowerMemmove.cpp
index 8f4154a..ff269d6 100644
--- a/lib/SPIRV/SPIRVLowerMemmove.cpp
+++ b/lib/SPIRV/SPIRVLowerMemmove.cpp
@@ -79,7 +79,7 @@ public:
// The source could be bit-cast from another type,
// need the original type for the allocation of the temporary variable
SrcTy = cast<BitCastInst>(Src)->getOperand(0)->getType();
- auto Align = I.getAlignment();
+ auto Align = I.getSourceAlignment();
auto Volatile = I.isVolatile();
Value *NumElements = nullptr;
uint64_t ElementsCount = 1;
@@ -94,10 +94,11 @@ public:
auto *Alloca = Builder.CreateAlloca(SrcTy->getPointerElementType(),
NumElements);
+ Alloca->setAlignment(Align);
Builder.CreateLifetimeStart(Alloca);
- Builder.CreateMemCpy(Alloca, Src, Length, Align, Volatile);
- auto *SecondCpy = Builder.CreateMemCpy(Dest, Alloca, Length, Align,
- Volatile);
+ Builder.CreateMemCpy(Alloca, Align, Src, Align, Length, Volatile);
+ auto *SecondCpy = Builder.CreateMemCpy(Dest, I.getDestAlignment(), Alloca,
+ Align, Length, Volatile);
Builder.CreateLifetimeEnd(Alloca);
SecondCpy->takeName(&I);
diff --git a/lib/SPIRV/SPIRVWriter.cpp b/lib/SPIRV/SPIRVWriter.cpp
index c4a2541..4a42173 100644
--- a/lib/SPIRV/SPIRVWriter.cpp
+++ b/lib/SPIRV/SPIRVWriter.cpp
@@ -1257,7 +1257,7 @@ SPIRVValue *
LLVMToSPIRV::transIntrinsicInst(IntrinsicInst *II, SPIRVBasicBlock *BB) {
auto getMemoryAccess = [](MemIntrinsic *MI)->std::vector<SPIRVWord> {
std::vector<SPIRVWord> MemoryAccess(1, MemoryAccessMaskNone);
- if (SPIRVWord AlignVal = MI->getAlignment()) {
+ if (SPIRVWord AlignVal = MI->getDestAlignment()) {
MemoryAccess[0] |= MemoryAccessAlignedMask;
MemoryAccess.push_back(AlignVal);
}
@@ -1313,9 +1313,10 @@ LLVMToSPIRV::transIntrinsicInst(IntrinsicInst *II, SPIRVBasicBlock *BB) {
SPIRVValue *Target = transValue(MSI->getRawDest(), BB);
return BM->addCopyMemorySizedInst(Target, Source, CompositeTy->getLength(),
getMemoryAccess(MSI), BB);
- }
- break;
- case Intrinsic::memcpy :
+ } break;
+ case Intrinsic::memcpy:
+ assert(cast<MemCpyInst>(II)->getSourceAlignment() ==
+ cast<MemCpyInst>(II)->getDestAlignment() && "Alignment mismatch!");
return BM->addCopyMemorySizedInst(
transValue(II->getOperand(0), BB),
transValue(II->getOperand(1), BB),