[4/6] FIx get kernel arg info crash bug.

Submitted by junyan.he@inbox.com on June 23, 2017, 10:18 a.m.

Details

Message ID 1498213109-10042-4-git-send-email-junyan.he@inbox.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Beignet

Not browsing as part of any series.

Commit Message

junyan.he@inbox.com June 23, 2017, 10:18 a.m.
From: Junyan He <junyan.he@intel.com>

Signed-off-by: Junyan He <junyan.he@intel.com>
---
 backend/src/llvm/llvm_gen_backend.cpp | 5 +++--
 backend/src/llvm/llvm_passes.cpp      | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
index 6f78180..817c590 100644
--- a/backend/src/llvm/llvm_gen_backend.cpp
+++ b/backend/src/llvm/llvm_gen_backend.cpp
@@ -1322,8 +1322,9 @@  namespace gbe
       if(typeBaseNameNode) {
         llvmInfo.typeBaseName= (cast<MDString>(typeBaseNameNode->getOperand(opID)))->getString();
       }
-      llvmInfo.typeName= (cast<MDString>(typeNameNode->getOperand(opID)))->getString();
-      llvmInfo.typeQual = (cast<MDString>(typeQualNode->getOperand(opID)))->getString();
+      if (typeQualNode) {
+        llvmInfo.typeQual = (cast<MDString>(typeQualNode->getOperand(opID)))->getString();
+      }
       bool isImage = llvmInfo.isImageType();
       bool isPipe = llvmInfo.isPipeType();
       if (I->getType()->isPointerTy() || isImage || isPipe) {
diff --git a/backend/src/llvm/llvm_passes.cpp b/backend/src/llvm/llvm_passes.cpp
index 10752a3..fbdb02c 100644
--- a/backend/src/llvm/llvm_passes.cpp
+++ b/backend/src/llvm/llvm_passes.cpp
@@ -43,8 +43,9 @@  namespace gbe
   bool isKernelFunction(const llvm::Function &F) {
     bool bKernel = false;
 #if LLVM_VERSION_MAJOR * 10 + LLVM_VERSION_MINOR >= 39
-    bKernel = F.getMetadata("kernel_arg_name") != NULL;
-#else
+    if (F.getMetadata("kernel_arg_name") != NULL)
+      return true;
+#endif
     const Module *module = F.getParent();
     const Module::NamedMDListType& globalMD = module->getNamedMDList();
     for(auto i = globalMD.begin(); i != globalMD.end(); i++) {
@@ -61,7 +62,6 @@  namespace gbe
         if(op == &F) bKernel = true;
       }
     }
-#endif
     return bKernel;
   }