From 7a364fc46f329a51989f5c7380456178f7d992e6 Mon Sep 17 00:00:00 2001 From: Gil Pitney Date: Tue, 27 Jan 2015 01:40:06 +0000 Subject: LLVM 3.6: More updates due to change in MetaData for kernel.cpp Based on patch thanks to Author: Tom Gall Date: Mon Jan 26 12:54:14 2015 -0600 add added updates based on comments in http://llvm.org/docs/doxygen/html/classllvm_1_1ConstantInt.html Signed-off-by: Gil Pitney --- src/core/kernel.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/core/kernel.cpp b/src/core/kernel.cpp index 76c7ab8..47e52db 100644 --- a/src/core/kernel.cpp +++ b/src/core/kernel.cpp @@ -45,7 +45,6 @@ #include #include -#include #include #include #include @@ -55,6 +54,8 @@ using namespace Coal; +using namespace llvm; + Kernel::Kernel(Program *program) : Object(Object::T_Kernel, program), p_has_locals(false), wi_alloca_size(0) { @@ -459,7 +460,9 @@ boost::tuple Kernel::reqdWorkGroupSize(llvm::Module *module) con /*--------------------------------------------------------------------- * Each node has only one operand : a llvm::Function *--------------------------------------------------------------------*/ - llvm::Value *value = node->getOperand(0); + // future DEBUG point, we're not sure this works. + llvm::Value *value = llvm::dyn_cast(node->getOperand(0))->getValue(); + /*--------------------------------------------------------------------- * Bug somewhere, don't crash @@ -472,17 +475,20 @@ boost::tuple Kernel::reqdWorkGroupSize(llvm::Module *module) con if (node->getNumOperands() <= 1) return zeros; llvm::MDNode *meta = llvm::cast(node->getOperand(1)); + llvm::Value *value_tmp = dyn_cast(meta->getOperand(0))->getValue(); if (meta->getNumOperands() == 4 && - meta->getOperand(0)->getName().str() == std::string("reqd_work_group_size")) + value_tmp->getName().str() == std::string("reqd_work_group_size")) { - uint x = llvm::cast (meta->getOperand(1))->getValue().getLimitedValue(); - uint y = llvm::cast (meta->getOperand(2))->getValue().getLimitedValue(); - uint z = llvm::cast (meta->getOperand(3))->getValue().getLimitedValue(); + // See comments in http://llvm.org/docs/doxygen/html/classllvm_1_1ConstantInt.html + auto x = llvm::mdconst::dyn_extract(meta->getOperand(1))->getLimitedValue(); + auto y = llvm::mdconst::dyn_extract(meta->getOperand(2))->getLimitedValue(); + auto z = llvm::mdconst::dyn_extract(meta->getOperand(3))->getLimitedValue(); return boost::tuple (x,y,z); } return zeros; } + return zeros; } -- cgit v1.2.3