summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/clover/llvm
diff options
context:
space:
mode:
authorTom Stellard <[email protected]>2013-06-05 17:05:43 -0700
committerTom Stellard <[email protected]>2013-06-28 15:19:06 -0700
commit5a925cc5504575c22dbb7d29842d7fc5babcb5c7 (patch)
treee01b3567d84fbdf704d4df66694ff6ce75fd62d8 /src/gallium/state_trackers/clover/llvm
parentd7361f294379c3b6d7f17c06fd520a6fd3ee7cb9 (diff)
clover: Don't segfault when compiling a program with no kernel
Diffstat (limited to 'src/gallium/state_trackers/clover/llvm')
-rw-r--r--src/gallium/state_trackers/clover/llvm/invocation.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 90bc53b238c..dae61f7fa7d 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -211,6 +211,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)));