[Mesa-dev] [PATCH] clover: Don't segfault when compiling a program with no kernel

Aaron Watry awatry at gmail.com
Thu Jun 6 08:29:21 PDT 2013


Looks good to me.  Is there a piglit test for this?

--Aaron

On Wed, Jun 5, 2013 at 7:12 PM, Tom Stellard <tom at stellard.net> wrote:
> From: Tom Stellard <thomas.stellard at amd.com>
>
> ---
>  src/gallium/state_trackers/clover/llvm/invocation.cpp | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp
> index 2d115ed..8ec089d 100644
> --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
> +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
> @@ -209,6 +209,13 @@ namespace {
>     find_kernels(llvm::Module *mod, std::vector<llvm::Function *> &kernels) {
>        const llvm::NamedMDNode *kernel_node =
>                                   mod->getNamedMetadata("opencl.kernels");
> +      // This means there are no kernels in the program.  The spec does not
> +      // require that we return an error here, but there will be an error if
> +      // the user tries to pass this program to a clCreateKernel() call.
> +      if (!kernel_node) {
> +         return;
> +      }
> +
>        for (unsigned i = 0; i < kernel_node->getNumOperands(); ++i) {
>           kernels.push_back(llvm::dyn_cast<llvm::Function>(
>                                      kernel_node->getOperand(i)->getOperand(0)));
> --
> 1.7.11.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list