Add support for relaese 3.8 Signed-off-by: Pan Xiuli <xiuli....@intel.com> --- backend/src/backend/gen_program.cpp | 4 ++++ backend/src/backend/program.cpp | 4 ++++ backend/src/llvm/ExpandConstantExpr.cpp | 2 +- backend/src/llvm/llvm_bitcode_link.cpp | 27 +++++++++++++++++++++++---- backend/src/llvm/llvm_to_gen.cpp | 4 ++++ backend/src/llvm/llvm_unroll.cpp | 5 +++++ 6 files changed, 41 insertions(+), 5 deletions(-)
diff --git a/backend/src/backend/gen_program.cpp b/backend/src/backend/gen_program.cpp index 9f82702..15ac763 100644 --- a/backend/src/backend/gen_program.cpp +++ b/backend/src/backend/gen_program.cpp @@ -426,7 +426,11 @@ namespace gbe { using namespace gbe; char* errMsg; if(((GenProgram*)dst_program)->module == NULL){ +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8 + ((GenProgram*)dst_program)->module = llvm::CloneModule((llvm::Module*)((GenProgram*)src_program)->module).release(); +#else ((GenProgram*)dst_program)->module = llvm::CloneModule((llvm::Module*)((GenProgram*)src_program)->module); +#endif errSize = 0; }else{ llvm::Module* src = (llvm::Module*)((GenProgram*)src_program)->module; diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp index 36af95f..2440edb 100644 --- a/backend/src/backend/program.cpp +++ b/backend/src/backend/program.cpp @@ -119,7 +119,11 @@ namespace gbe { ir::Unit *unit = new ir::Unit(ir::POINTER_64_BITS); llvm::Module * cloned_module = NULL; if(module){ +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8 + cloned_module = llvm::CloneModule((llvm::Module*)module).release(); +#else cloned_module = llvm::CloneModule((llvm::Module*)module); +#endif } if (llvmToGen(*unit, fileName, module, optLevel, OCL_STRICT_CONFORMANCE) == false) { if (fileName) diff --git a/backend/src/llvm/ExpandConstantExpr.cpp b/backend/src/llvm/ExpandConstantExpr.cpp index e9ec3ab..b6b8667 100644 --- a/backend/src/llvm/ExpandConstantExpr.cpp +++ b/backend/src/llvm/ExpandConstantExpr.cpp @@ -114,7 +114,7 @@ static Value *expandConstantVector(Instruction *InsertPt, ConstantVector *CV) { int elemNum = CV->getType()->getNumElements(); Type *IntTy = IntegerType::get(CV->getContext(), 32); - BasicBlock::iterator InsertPos(InsertPt); + BasicBlock::iterator InsertPos(&*InsertPt); IRBuilder<> IRB(&*InsertPos); Value *vec = UndefValue::get(CV->getType()); for (int i = 0; i < elemNum; i++) { diff --git a/backend/src/llvm/llvm_bitcode_link.cpp b/backend/src/llvm/llvm_bitcode_link.cpp index 56205bb..79250ab 100644 --- a/backend/src/llvm/llvm_bitcode_link.cpp +++ b/backend/src/llvm/llvm_bitcode_link.cpp @@ -68,7 +68,7 @@ namespace gbe return oclLib; } - static bool materializedFuncCall(Module& src, Module& lib, llvm::Function &KF, std::set<std::string>& MFS) + static bool materializedFuncCall(Module& src, Module& lib, llvm::Function &KF, std::set<std::string>& MFS, std::vector<GlobalValue *>& Gvs) { bool fromSrc = false; for (llvm::Function::iterator B = KF.begin(), BE = KF.end(); B != BE; B++) { @@ -112,9 +112,10 @@ namespace gbe printf("Can not materialize the function: %s, because %s\n", fnName.c_str(), EC.message().c_str()); return false; } + Gvs.push_back((GlobalValue *)newMF); #endif } - if (!materializedFuncCall(src, lib, *newMF, MFS)) + if (!materializedFuncCall(src, lib, *newMF, MFS, Gvs)) return false; } @@ -128,6 +129,7 @@ namespace gbe { LLVMContext& ctx = mod->getContext(); std::set<std::string> materializedFuncs; + std::vector<GlobalValue *> Gvs; Module* clonedLib = createOclBitCodeModule(ctx, strictMath); assert(clonedLib && "Can not create the beignet bitcode\n"); @@ -173,10 +175,11 @@ namespace gbe if (!isKernelFunction(*SF)) continue; kernels.push_back(SF->getName().data()); - if (!materializedFuncCall(*mod, *clonedLib, *SF, materializedFuncs)) { + if (!materializedFuncCall(*mod, *clonedLib, *SF, materializedFuncs, Gvs)) { delete clonedLib; return NULL; } + Gvs.push_back((GlobalValue *)&*SF); } if (kernels.empty()) { @@ -215,14 +218,30 @@ namespace gbe } #endif - if (!materializedFuncCall(*mod, *clonedLib, *newMF, materializedFuncs)) { + if (!materializedFuncCall(*mod, *clonedLib, *newMF, materializedFuncs, Gvs)) { delete clonedLib; return NULL; } + Gvs.push_back((GlobalValue *)newMF); kernels.push_back(f); } + /* The llvm check materialized for all value, get all the functions and + * global values we neeed */ +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >=8 + Module::GlobalListType &GVlist = clonedLib->getGlobalList(); + for(Module::global_iterator GVitr = GVlist.begin();GVitr != GVlist.end();++GVitr) { + GlobalValue * GV = &*GVitr; + clonedLib->materialize(GV); + Gvs.push_back(GV); + } + llvm::legacy::PassManager Extract; + Extract.add(createGVExtractionPass(Gvs, false)); + Extract.run(*clonedLib); + clonedLib->materializeAll(); +#endif + /* the SPIR binary datalayout maybe different with beignet's bitcode */ if(clonedLib->getDataLayout() != mod->getDataLayout()) mod->setDataLayout(clonedLib->getDataLayout()); diff --git a/backend/src/llvm/llvm_to_gen.cpp b/backend/src/llvm/llvm_to_gen.cpp index ceaee9b..0b3f0d2 100644 --- a/backend/src/llvm/llvm_to_gen.cpp +++ b/backend/src/llvm/llvm_to_gen.cpp @@ -140,7 +140,11 @@ namespace gbe MPM.add(createBarrierNodupPass(false)); // remove noduplicate fnAttr before inlining. MPM.add(createFunctionInliningPass(20000)); MPM.add(createBarrierNodupPass(true)); // restore noduplicate fnAttr after inlining. +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8 + MPM.add(createPostOrderFunctionAttrsPass()); +#else MPM.add(createFunctionAttrsPass()); // Set readonly/readnone attrs +#endif //MPM.add(createScalarReplAggregatesPass(64, true, -1, -1, 64)) if(optLevel > 0) diff --git a/backend/src/llvm/llvm_unroll.cpp b/backend/src/llvm/llvm_unroll.cpp index 4cc3481..0f62bdc 100644 --- a/backend/src/llvm/llvm_unroll.cpp +++ b/backend/src/llvm/llvm_unroll.cpp @@ -163,6 +163,7 @@ namespace gbe { Loop *currL = L; #if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8 ScalarEvolution *SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE(); + LoopInfo &loopInfo = getAnalysis<LoopInfoWrapperPass>().getLoopInfo(); #else ScalarEvolution *SE = &getAnalysis<ScalarEvolution>(); #endif @@ -192,7 +193,11 @@ namespace gbe { shouldUnroll = false; setUnrollID(currL, false); if (currL != L) +#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 8 + loopInfo.markAsRemoved(currL); +#else LPM.deleteLoopFromQueue(currL); +#endif } currL = parentL; currTripCount = parentTripCount; -- 2.5.0 _______________________________________________ Beignet mailing list Beignet@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/beignet