From 50f1cd40767469c96628331aa0ce91fcde328030 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 10 Sep 2020 17:52:16 -0700 Subject: [PATCH] ac/llvm: Fix nonportable sizeof. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: ca74603b4f6e ("ac/llvm: add better code for isign") Signed-off-by: Vinson Lee Reviewed-by: Bas Nieuwenhuizen Reviewed-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Marek Olšák Part-of: --- src/amd/llvm/ac_llvm_build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c index f1ab80e7f09..9166ba8721c 100644 --- a/src/amd/llvm/ac_llvm_build.c +++ b/src/amd/llvm/ac_llvm_build.c @@ -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;