Mesa (10.2): radeon/llvm: Allocate space for kernel metadata operands
Carl Worth
cworth at kemper.freedesktop.org
Fri Jul 4 04:07:36 UTC 2014
Module: Mesa
Branch: 10.2
Commit: 5ba1cf1893a63907d96f0d49a5c95612e7a9be8f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5ba1cf1893a63907d96f0d49a5c95612e7a9be8f
Author: Aaron Watry <awatry at gmail.com>
Date: Wed Jul 2 16:27:31 2014 -0500
radeon/llvm: Allocate space for kernel metadata operands
Previously, we were assuming that kernel metadata nodes only had 1 operand.
Kernels which have attributes can have more than 1, e.g.:
!0 = metadata !{void (i32 addrspace(1)*)* @testKernel, metadata !1}
!1 = metadata !{metadata !"work_group_size_hint", i32 4, i32 1, i32 1}
Attempting to get the kernel without the correct number of attributes led
to memory corruption and luxrays crashing out.
Fixes the cl/program/execute/attributes.cl piglit test.
Signed-off-by: Aaron Watry <awatry at gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard at amd.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76223
CC: "10.2" <mesa-stable at lists.freedesktop.org>
(cherry picked from commit 824197efd526dec5623b37f2c6078c212c81eb2b)
---
src/gallium/drivers/radeon/radeon_llvm_util.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.c b/src/gallium/drivers/radeon/radeon_llvm_util.c
index 2ace91f..ec11559 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_util.c
+++ b/src/gallium/drivers/radeon/radeon_llvm_util.c
@@ -100,13 +100,17 @@ LLVMModuleRef radeon_llvm_get_kernel_module(LLVMContextRef ctx, unsigned index,
kernel_metadata = MALLOC(num_kernels * sizeof(LLVMValueRef));
LLVMGetNamedMetadataOperands(mod, "opencl.kernels", kernel_metadata);
for (i = 0; i < num_kernels; i++) {
- LLVMValueRef kernel_signature, kernel_function;
+ LLVMValueRef kernel_signature, *kernel_function;
+ unsigned num_kernel_md_operands;
if (i == index) {
continue;
}
kernel_signature = kernel_metadata[i];
- LLVMGetMDNodeOperands(kernel_signature, &kernel_function);
- LLVMDeleteFunction(kernel_function);
+ num_kernel_md_operands = LLVMGetMDNodeNumOperands(kernel_signature);
+ kernel_function = MALLOC(num_kernel_md_operands * sizeof (LLVMValueRef));
+ LLVMGetMDNodeOperands(kernel_signature, kernel_function);
+ LLVMDeleteFunction(*kernel_function);
+ FREE(kernel_function);
}
FREE(kernel_metadata);
radeon_llvm_optimize(mod);
More information about the mesa-commit
mailing list