Commit e6c94972 by Nicolas Capens Committed by Nicolas Capens

Fix LLVM pointer element type

llvm::PointerType::isValidElementType() checks that the pointee type is not void. Use a byte pointer instead. Bug: b/155148722 Change-Id: Ibf2fd23ce0a19a6947a6817f0b73753cfa170832 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/49568Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com>
parent 00c30ce8
...@@ -408,9 +408,10 @@ void createScatter(llvm::Value *base, llvm::Value *val, llvm::Value *offsets, ll ...@@ -408,9 +408,10 @@ void createScatter(llvm::Value *base, llvm::Value *val, llvm::Value *offsets, ll
{ {
// void __msan_unpoison(const volatile void *a, size_t size) // void __msan_unpoison(const volatile void *a, size_t size)
auto voidTy = ::llvm::Type::getVoidTy(jit->context); auto voidTy = ::llvm::Type::getVoidTy(jit->context);
auto voidPtrTy = voidTy->getPointerTo(); auto int8Ty = ::llvm::Type::getInt8Ty(jit->context);
auto int8PtrTy = int8Ty->getPointerTo();
auto sizetTy = ::llvm::IntegerType::get(jit->context, sizeof(size_t) * 8); auto sizetTy = ::llvm::IntegerType::get(jit->context, sizeof(size_t) * 8);
auto funcTy = ::llvm::FunctionType::get(voidTy, { voidPtrTy, sizetTy }, false); auto funcTy = ::llvm::FunctionType::get(voidTy, { int8PtrTy, sizetTy }, false);
auto func = jit->module->getOrInsertFunction("__msan_unpoison", funcTy); auto func = jit->module->getOrInsertFunction("__msan_unpoison", funcTy);
auto size = jit->module->getDataLayout().getTypeStoreSize(elTy); auto size = jit->module->getDataLayout().getTypeStoreSize(elTy);
for(unsigned i = 0; i < numEls; i++) for(unsigned i = 0; i < numEls; i++)
...@@ -424,7 +425,7 @@ void createScatter(llvm::Value *base, llvm::Value *val, llvm::Value *offsets, ll ...@@ -424,7 +425,7 @@ void createScatter(llvm::Value *base, llvm::Value *val, llvm::Value *offsets, ll
// Insert __msan_unpoison call in conditional block // Insert __msan_unpoison call in conditional block
auto elPtr = jit->builder->CreateExtractElement(elPtrs, idx); auto elPtr = jit->builder->CreateExtractElement(elPtrs, idx);
jit->builder->CreateCall(func, { jit->builder->CreatePointerCast(elPtr, voidPtrTy), jit->builder->CreateCall(func, { jit->builder->CreatePointerCast(elPtr, int8PtrTy),
::llvm::ConstantInt::get(sizetTy, size) }); ::llvm::ConstantInt::get(sizetTy, size) });
jit->builder->CreateBr(mergeBlock); jit->builder->CreateBr(mergeBlock);
jit->builder->SetInsertPoint(mergeBlock); jit->builder->SetInsertPoint(mergeBlock);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment