Mesa (master): ac/llvm: Fix nonportable sizeof.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Sep 14 22:37:50 UTC 2020
Module: Mesa
Branch: master
Commit: 50f1cd40767469c96628331aa0ce91fcde328030
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=50f1cd40767469c96628331aa0ce91fcde328030
Author: Vinson Lee <vlee at freedesktop.org>
Date: Thu Sep 10 17:52:16 2020 -0700
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: ca74603b4f6e ("ac/llvm: add better code for isign")
Signed-off-by: Vinson Lee <vlee at freedesktop.org>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6682>
---
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;
More information about the mesa-commit
mailing list