[Beignet] [PATCH] GBE: fix llvm3.5 version build error.

Yang Rong rong.r.yang at intel.com
Thu Jan 19 10:14:34 UTC 2017


Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
 backend/src/llvm/llvm_device_enqueue.cpp | 9 ++++++---
 backend/src/llvm/llvm_passes.cpp         | 4 ++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/backend/src/llvm/llvm_device_enqueue.cpp b/backend/src/llvm/llvm_device_enqueue.cpp
index ff6fbbb..ee236de 100644
--- a/backend/src/llvm/llvm_device_enqueue.cpp
+++ b/backend/src/llvm/llvm_device_enqueue.cpp
@@ -15,7 +15,7 @@
  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  *
  */
-
+#include <list>
 #include "llvm_includes.hpp"
 
 #include "ir/unit.hpp"
@@ -84,6 +84,7 @@ namespace gbe {
 
   Function* setFunctionAsKernel(Module *mod, Function *Fn)
   {
+#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR >= 9)
     LLVMContext &Context = mod->getContext();
     Type *intTy = IntegerType::get(mod->getContext(), 32);
     SmallVector<llvm::Metadata *, 5> kernelMDArgs;
@@ -148,7 +149,6 @@ namespace gbe {
     }
 
     //If run to here, llvm version always > 3.9, add the version check just for build.
-#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR >= 9)
     NewFn->setMetadata("kernel_arg_addr_space",
                     llvm::MDNode::get(Context, addressQuals));
     NewFn->setMetadata("kernel_arg_access_qual",
@@ -161,8 +161,11 @@ namespace gbe {
                     llvm::MDNode::get(Context, argTypeQuals));
     NewFn->setMetadata("kernel_arg_name",
                     llvm::MDNode::get(Context, argNames));
-#endif
     return NewFn;
+#else
+    assert(0);  //only opencl 2.0 could reach hear.
+    return Fn;
+#endif
   }
 
   Instruction* replaceInst(Instruction *I, Value *v)
diff --git a/backend/src/llvm/llvm_passes.cpp b/backend/src/llvm/llvm_passes.cpp
index f5d9052..367a2c3 100644
--- a/backend/src/llvm/llvm_passes.cpp
+++ b/backend/src/llvm/llvm_passes.cpp
@@ -78,8 +78,8 @@ namespace gbe
       major = mdconst::extract<ConstantInt>(node->getOperand(0))->getZExtValue();
       minor = mdconst::extract<ConstantInt>(node->getOperand(1))->getZExtValue();
 #else
-      major = cast<ConstantInt>(MD->getOperand(0))->getZExtValue();
-      minor = cast<ConstantInt>(MD->getOperand(1))->getZExtValue();
+      major = cast<ConstantInt>(node->getOperand(0))->getZExtValue();
+      minor = cast<ConstantInt>(node->getOperand(1))->getZExtValue();
 #endif
       oclVersion = major * 100 + minor * 10;
     }
-- 
2.1.4



More information about the Beignet mailing list