aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/clover
diff options
context:
space:
mode:
authorZoltan Gilian <[email protected]>2015-08-19 11:56:08 +0200
committerFrancisco Jerez <[email protected]>2015-08-21 14:18:10 +0300
commitdf5cdec1329507d5ac52a6d3db49c2608b9226bc (patch)
treea6ac6246eeb33c94f7352b75d3808651bf812e1e /src/gallium/state_trackers/clover
parent7eda897bf05dc572dbe83f3a1075b773b0c65708 (diff)
clover: fix llvm 3.5 build error
There is no MDOperand in llvm 3.5. v2: Check if kernel metadata is present to avoid crash (EdB). v3: Second attempt to avoid crash: switch off metadata query for llvm < 3.6. Reviewed-by: Serge Martin (EdB) <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/clover')
-rw-r--r--src/gallium/state_trackers/clover/llvm/invocation.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 63c3f8ee49b..7c23a27150b 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -346,6 +346,15 @@ namespace {
// Kernel metadata
+ struct kernel_arg_md {
+ llvm::StringRef type_name;
+ llvm::StringRef access_qual;
+ kernel_arg_md(llvm::StringRef type_name_, llvm::StringRef access_qual_):
+ type_name(type_name_), access_qual(access_qual_) {}
+ };
+
+#if HAVE_LLVM >= 0x0306
+
const llvm::MDNode *
get_kernel_metadata(const llvm::Function *kernel_func) {
auto mod = kernel_func->getParent();
@@ -356,12 +365,8 @@ namespace {
const llvm::MDNode *kernel_node = nullptr;
for (unsigned i = 0; i < kernels_node->getNumOperands(); ++i) {
-#if HAVE_LLVM >= 0x0306
auto func = llvm::mdconst::dyn_extract<llvm::Function>(
-#else
- auto func = llvm::dyn_cast<llvm::Function>(
-#endif
- kernels_node->getOperand(i)->getOperand(0));
+ kernels_node->getOperand(i)->getOperand(0));
if (func == kernel_func) {
kernel_node = kernels_node->getOperand(i);
break;
@@ -387,13 +392,6 @@ namespace {
return node;
}
- struct kernel_arg_md {
- llvm::StringRef type_name;
- llvm::StringRef access_qual;
- kernel_arg_md(llvm::StringRef type_name_, llvm::StringRef access_qual_):
- type_name(type_name_), access_qual(access_qual_) {}
- };
-
std::vector<kernel_arg_md>
get_kernel_arg_md(const llvm::Function *kernel_func) {
auto num_args = kernel_func->getArgumentList().size();
@@ -415,6 +413,17 @@ namespace {
return res;
}
+#else
+
+ std::vector<kernel_arg_md>
+ get_kernel_arg_md(const llvm::Function *kernel_func) {
+ return std::vector<kernel_arg_md>(
+ kernel_func->getArgumentList().size(),
+ kernel_arg_md("", ""));
+ }
+
+#endif // HAVE_LLVM >= 0x0306
+
std::vector<module::argument>
get_kernel_args(const llvm::Module *mod, const std::string &kernel_name,
const clang::LangAS::Map &address_spaces) {