@@ -1855,9 +1855,28 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
18551855 return mapValue (BV, LI);
18561856 }
18571857
1858+ case OpCopyMemory: {
1859+ auto *BC = static_cast <SPIRVCopyMemory *>(BV);
1860+ llvm::Value *Dst = transValue (BC->getTarget (), F, BB);
1861+ MaybeAlign Align (BC->getAlignment ());
1862+ MaybeAlign SrcAlign =
1863+ BC->getSrcAlignment () ? MaybeAlign (BC->getSrcAlignment ()) : Align;
1864+ Type *EltTy =
1865+ transType (BC->getSource ()->getType ()->getPointerElementType ());
1866+ uint64_t Size = M->getDataLayout ().getTypeStoreSize (EltTy).getFixedValue ();
1867+ bool IsVolatile = BC->SPIRVMemoryAccess ::isVolatile ();
1868+ IRBuilder<> Builder (BB);
1869+
1870+ llvm::Value *Src = transValue (BC->getSource (), F, BB);
1871+ CallInst *CI =
1872+ Builder.CreateMemCpy (Dst, Align, Src, SrcAlign, Size, IsVolatile);
1873+ if (isFuncNoUnwind ())
1874+ CI->getFunction ()->addFnAttr (Attribute::NoUnwind);
1875+ return mapValue (BV, CI);
1876+ }
1877+
18581878 case OpCopyMemorySized: {
18591879 SPIRVCopyMemorySized *BC = static_cast <SPIRVCopyMemorySized *>(BV);
1860- CallInst *CI = nullptr ;
18611880 llvm::Value *Dst = transValue (BC->getTarget (), F, BB);
18621881 MaybeAlign Align (BC->getAlignment ());
18631882 MaybeAlign SrcAlign =
@@ -1869,13 +1888,12 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
18691888 // A ptr.annotation may have been generated for the destination variable.
18701889 replaceOperandWithAnnotationIntrinsicCallResult (F, Dst);
18711890
1872- if (!CI) {
1873- llvm::Value *Src = transValue (BC->getSource (), F, BB);
1891+ llvm::Value *Src = transValue (BC->getSource (), F, BB);
18741892
1875- // A ptr.annotation may have been generated for the source variable.
1876- replaceOperandWithAnnotationIntrinsicCallResult (F, Src);
1877- CI = Builder. CreateMemCpy (Dst, Align, Src, SrcAlign, Size, IsVolatile);
1878- }
1893+ // A ptr.annotation may have been generated for the source variable.
1894+ replaceOperandWithAnnotationIntrinsicCallResult (F, Src);
1895+ CallInst * CI =
1896+ Builder. CreateMemCpy (Dst, Align, Src, SrcAlign, Size, IsVolatile);
18791897 if (isFuncNoUnwind ())
18801898 CI->getFunction ()->addFnAttr (Attribute::NoUnwind);
18811899 return mapValue (BV, CI);
0 commit comments