[Beignet] [PATCH 4/6] FIx get kernel arg info crash bug.
junyan.he at inbox.com
junyan.he at inbox.com
Fri Jun 23 10:18:27 UTC 2017
From: Junyan He <junyan.he at intel.com>
Signed-off-by: Junyan He <junyan.he at intel.com>
---
backend/src/llvm/llvm_gen_backend.cpp | 5 +++--
backend/src/llvm/llvm_passes.cpp | 6 +++---
2 files changed, 6 insertions(+), 5 deletions(-)
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;
}
--
2.7.4
More information about the Beignet
mailing list