Skip to content

Commit

Permalink
Added a fix in lowering OpCopyMemorySized.
Browse files Browse the repository at this point in the history
Our issues was that we assumed that the src was an i8 type when it could be any float type as well.
Because we know the value is 0 the type does not matter so we can just set it to i8.
Also forcing the dst pointer to be a i8* so llvm.memset has compatible parameters.

This fixes #115

Change-Id: I71966ac54d1b3c706083fc2c4a49c49b97393933
  • Loading branch information
paigeale authored and sys_zuul committed Oct 16, 2019
1 parent aa98386 commit 7ee98f6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2649,11 +2649,16 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
if (Init && Init->getOpCode() == OpConstantNull) {
SPIRVType *Ty = static_cast<SPIRVConstantNull *>(Init)->getType();
if (Ty->isTypeArray()) {
SPIRVTypeArray *AT = static_cast<SPIRVTypeArray *>(Ty);
Type *SrcTy = transType(AT->getArrayElementType());
assert(SrcTy->isIntegerTy(8));
llvm::Value *Src = ConstantInt::get(SrcTy, 0);
CI = Builder.CreateMemSet(Dst, Src, Size, Align, IsVolatile);
Type* Int8Ty = Type::getInt8Ty(Dst->getContext());
llvm::Value* Src = ConstantInt::get(Int8Ty, 0);
llvm::Value* newDst = Dst;
if (!Dst->getType()->getPointerElementType()->isIntegerTy(8)) {
Type* Int8PointerTy = Type::getInt8PtrTy(Dst->getContext(),
Dst->getType()->getPointerAddressSpace());
newDst = llvm::BitCastInst::CreatePointerCast(Dst,
Int8PointerTy, "", BB);
}
CI = Builder.CreateMemSet(newDst, Src, Size, Align, IsVolatile);
}
}
}
Expand Down

0 comments on commit 7ee98f6

Please sign in to comment.