From: Luo Xionghu <[email protected]> the printfPaser variables g1Xg2Xg3 and wg_offset should be reinit after the builder is deleted, or else the variables will be freed and caused memory leak; query the Constants related to the globallist by name instead: the GenWriter pass will be called by the number of __kernel functions in the module, since the globallist is always the same, constant index is not simply increased in different kernel function.
this patch could fix fdo bug: https://bugs.freedesktop.org/show_bug.cgi?id=90472. Signed-off-by: Luo Xionghu <[email protected]> --- backend/src/llvm/llvm_gen_backend.cpp | 4 +--- backend/src/llvm/llvm_printf_parser.cpp | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp index 4905415..1a65ee0 100644 --- a/backend/src/llvm/llvm_gen_backend.cpp +++ b/backend/src/llvm/llvm_gen_backend.cpp @@ -2443,7 +2443,6 @@ namespace gbe { // Allocate a address register for each global variable const Module::GlobalListType &globalList = TheModule->getGlobalList(); - size_t j = 0; for(auto i = globalList.begin(); i != globalList.end(); i ++) { const GlobalVariable &v = *i; if(!v.isConstantUsed()) continue; @@ -2475,8 +2474,7 @@ namespace gbe GBE_ASSERT(v.hasInitializer()); this->newRegister(const_cast<GlobalVariable*>(&v)); ir::Register reg = regTranslator.getScalar(const_cast<GlobalVariable*>(&v), 0); - ir::Constant &con = unit.getConstantSet().getConstant(j ++); - GBE_ASSERT(con.getName() == v.getName()); + ir::Constant &con = unit.getConstantSet().getConstant(v.getName()); ctx.LOADI(ir::TYPE_S32, reg, ctx.newIntegerImmediate(con.getOffset(), ir::TYPE_S32)); } else { if(v.getName().equals(StringRef("__gen_ocl_printf_buf"))) { diff --git a/backend/src/llvm/llvm_printf_parser.cpp b/backend/src/llvm/llvm_printf_parser.cpp index 3d84457..7ebda65 100644 --- a/backend/src/llvm/llvm_printf_parser.cpp +++ b/backend/src/llvm/llvm_printf_parser.cpp @@ -755,6 +755,8 @@ error: deadprintfs.clear(); delete builder; + g1Xg2Xg3 = NULL; + wg_offset = NULL; return changed; } -- 1.9.1 _______________________________________________ Beignet mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/beignet
