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

Pan, Xiuli xiuli.pan at intel.com
Thu Jan 19 09:28:06 UTC 2017


LGTM, thanks.

-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Yang Rong
Sent: Thursday, January 19, 2017 6:15 PM
To: beignet at lists.freedesktop.org
Cc: Yang, Rong R <rong.r.yang at intel.com>
Subject: [Beignet] [PATCH] GBE: fix llvm3.5 version build error.

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

_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list