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/+/49888
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index 7966da7..4aee82d 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -622,7 +622,8 @@
 
 	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 @@
 			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)
 {