As non-kernel functions hit many assert in the backend, simply skip them as we already inline all function calls.
Signed-off-by: Ruiling Song <[email protected]> --- backend/src/llvm/llvm_gen_backend.cpp | 4 ++++ backend/src/llvm/llvm_gen_backend.hpp | 3 +++ backend/src/llvm/llvm_passes.cpp | 17 +++++++++++++++++ backend/src/llvm/llvm_scalarize.cpp | 4 ++++ 4 files changed, 28 insertions(+) diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp index 5fb4f49..7519ff1 100644 --- a/backend/src/llvm/llvm_gen_backend.cpp +++ b/backend/src/llvm/llvm_gen_backend.cpp @@ -472,6 +472,10 @@ namespace gbe if (F.hasAvailableExternallyLinkage()) return false; + // As we inline all function calls, so skip non-kernel functions + bool bKernel = isKernelFunction(F); + if(!bKernel) return false; + LI = &getAnalysis<LoopInfo>(); emitFunction(F); diff --git a/backend/src/llvm/llvm_gen_backend.hpp b/backend/src/llvm/llvm_gen_backend.hpp index 2ad879e..d6c98dd 100644 --- a/backend/src/llvm/llvm_gen_backend.hpp +++ b/backend/src/llvm/llvm_gen_backend.hpp @@ -75,6 +75,9 @@ namespace gbe /*! Get the type size in bytes */ uint32_t getTypeByteSize(const ir::Unit &unit, llvm::Type* Ty); + /*! whether this is a kernel function */ + bool isKernelFunction(const llvm::Function &f); + /*! Create a Gen-IR unit */ llvm::FunctionPass *createGenPass(ir::Unit &unit); diff --git a/backend/src/llvm/llvm_passes.cpp b/backend/src/llvm/llvm_passes.cpp index 4bafc0d..60c9df1 100644 --- a/backend/src/llvm/llvm_passes.cpp +++ b/backend/src/llvm/llvm_passes.cpp @@ -105,6 +105,23 @@ using namespace llvm; namespace gbe { + bool isKernelFunction(const llvm::Function &F) { + const Module *module = F.getParent(); + const Module::NamedMDListType& globalMD = module->getNamedMDList(); + bool bKernel = false; + for(auto i = globalMD.begin(); i != globalMD.end(); i++) { + const NamedMDNode &md = *i; + if(strcmp(md.getName().data(), "opencl.kernels") != 0) continue; + uint32_t ops = md.getNumOperands(); + for(uint32_t x = 0; x < ops; x++) { + MDNode* node = md.getOperand(x); + Value * op = node->getOperand(0); + if(op == &F) bKernel = true; + } + } + return bKernel; + } + uint32_t getPadding(uint32_t offset, uint32_t align) { return (align - (offset % align)) % align; } diff --git a/backend/src/llvm/llvm_scalarize.cpp b/backend/src/llvm/llvm_scalarize.cpp index 7a40616..edfc369 100644 --- a/backend/src/llvm/llvm_scalarize.cpp +++ b/backend/src/llvm/llvm_scalarize.cpp @@ -767,6 +767,10 @@ namespace gbe { default: GBE_ASSERTM(false, "Unsupported calling convention"); } + // As we inline all function calls, so skip non-kernel functions + bool bKernel = isKernelFunction(F); + if(!bKernel) return false; + bool changed = false; module = F.getParent(); intTy = IntegerType::get(module->getContext(), 32); -- 1.7.9.5 _______________________________________________ Beignet mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/beignet
