@@ -1859,9 +1859,28 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
18591859 return mapValue (BV, LI);
18601860 }
18611861
1862+ case OpCopyMemory: {
1863+ auto *BC = static_cast <SPIRVCopyMemory *>(BV);
1864+ llvm::Value *Dst = transValue (BC->getTarget (), F, BB);
1865+ MaybeAlign Align (BC->getAlignment ());
1866+ MaybeAlign SrcAlign =
1867+ BC->getSrcAlignment () ? MaybeAlign (BC->getSrcAlignment ()) : Align;
1868+ Type *EltTy =
1869+ transType (BC->getSource ()->getType ()->getPointerElementType ());
1870+ uint64_t Size = M->getDataLayout ().getTypeStoreSize (EltTy).getFixedValue ();
1871+ bool IsVolatile = BC->SPIRVMemoryAccess ::isVolatile ();
1872+ IRBuilder<> Builder (BB);
1873+
1874+ llvm::Value *Src = transValue (BC->getSource (), F, BB);
1875+ CallInst *CI =
1876+ Builder.CreateMemCpy (Dst, Align, Src, SrcAlign, Size, IsVolatile);
1877+ if (isFuncNoUnwind ())
1878+ CI->getFunction ()->addFnAttr (Attribute::NoUnwind);
1879+ return mapValue (BV, CI);
1880+ }
1881+
18621882 case OpCopyMemorySized: {
18631883 SPIRVCopyMemorySized *BC = static_cast <SPIRVCopyMemorySized *>(BV);
1864- CallInst *CI = nullptr ;
18651884 llvm::Value *Dst = transValue (BC->getTarget (), F, BB);
18661885 MaybeAlign Align (BC->getAlignment ());
18671886 MaybeAlign SrcAlign =
@@ -1873,13 +1892,12 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
18731892 // A ptr.annotation may have been generated for the destination variable.
18741893 replaceOperandWithAnnotationIntrinsicCallResult (F, Dst);
18751894
1876- if (!CI) {
1877- llvm::Value *Src = transValue (BC->getSource (), F, BB);
1895+ llvm::Value *Src = transValue (BC->getSource (), F, BB);
18781896
1879- // A ptr.annotation may have been generated for the source variable.
1880- replaceOperandWithAnnotationIntrinsicCallResult (F, Src);
1881- CI = Builder. CreateMemCpy (Dst, Align, Src, SrcAlign, Size, IsVolatile);
1882- }
1897+ // A ptr.annotation may have been generated for the source variable.
1898+ replaceOperandWithAnnotationIntrinsicCallResult (F, Src);
1899+ CallInst * CI =
1900+ Builder. CreateMemCpy (Dst, Align, Src, SrcAlign, Size, IsVolatile);
18831901 if (isFuncNoUnwind ())
18841902 CI->getFunction ()->addFnAttr (Attribute::NoUnwind);
18851903 return mapValue (BV, CI);
0 commit comments