Commit 19f01495 by Nicolas Capens Committed by Nicolas Capens

Fix LLVM alloca array size type

https://llvm.org/docs/LangRef.html#alloca-instruction does not specify the type of the 'NumElements' parameter explicitly, but it is multiplied by sizeof(<type>), which itself is of type size_t and thus 64-bit on a 64-bit platform. This assumption is made by MemorySanitizer when it emits instructions corresponding to this multiplication, which get constant folded and requires both operands to be of the same bit size. Bug: b/155148722 Change-Id: I432e69bfcea4d40ce7b593637fd242bc1a25a714 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/49888Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com>
parent 47c3ca10
......@@ -622,7 +622,8 @@ Value *Nucleus::allocateStackVariable(Type *type, int arraySize)
if(arraySize)
{
declaration = new llvm::AllocaInst(T(type), 0, V(Nucleus::createConstantInt(arraySize)), align);
Value *size = (sizeof(size_t) == 8) ? Nucleus::createConstantLong(arraySize) : Nucleus::createConstantInt(arraySize);
declaration = new llvm::AllocaInst(T(type), 0, V(size), align);
}
else
{
......@@ -1101,7 +1102,7 @@ void Nucleus::createMaskedStore(Value *ptr, Value *val, Value *mask, unsigned in
jit->builder->SetInsertPoint(mergeBlock);
}
}
} // namespace rr
}
static llvm::Value *createGather(llvm::Value *base, llvm::Type *elTy, llvm::Value *offsets, llvm::Value *mask, unsigned int alignment, bool zeroMaskedLanes)
{
......
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