ac/llvm: Fix nonportable sizeof.
Fix defect reported by Coverity.
Sizeof not portable (SIZEOF_MISMATCH)
suspicious_sizeof: Passing argument vec_size * 8UL /* sizeof
(LLVMValueRef *) */ to function __builtin_alloca and then casting
the return value to LLVMValueRef * is suspicious. In this
particular case sizeof (LLVMValueRef *) happens to be equal to
sizeof (LLVMValueRef), but this is not a portable assumption.
Fixes: ca74603b4f ("ac/llvm: add better code for isign")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6682>
This commit is contained in:
@@ -2438,7 +2438,7 @@ LLVMValueRef ac_const_uint_vec(struct ac_llvm_context *ctx, LLVMTypeRef type, ui
|
||||
if (LLVMGetTypeKind(type) == LLVMVectorTypeKind) {
|
||||
LLVMValueRef scalar = LLVMConstInt(LLVMGetElementType(type), value, 0);
|
||||
unsigned vec_size = LLVMGetVectorSize(type);
|
||||
LLVMValueRef *scalars = alloca(vec_size * sizeof(LLVMValueRef *));
|
||||
LLVMValueRef *scalars = alloca(vec_size * sizeof(LLVMValueRef));
|
||||
|
||||
for (unsigned i = 0; i < vec_size; i++)
|
||||
scalars[i] = scalar;
|
||||
|
||||
Reference in New Issue
Block a user