[Beignet] [PATCH] fix __kernel function called in __kernel issue.
He Junyan
junyan.he at inbox.com
Mon Oct 12 00:23:58 PDT 2015
LGTM, thanks
On Sat, Oct 10, 2015 at 06:55:45AM -0400, xionghu.luo at intel.com wrote:
> Date: Sat, 10 Oct 2015 06:55:45 -0400
> From: xionghu.luo at intel.com
> To: beignet at lists.freedesktop.org
> Cc: xionghu.luo at intel.com
> Subject: [Beignet] [PATCH] fix __kernel function called in __kernel issue.
> X-Mailer: git-send-email 1.9.1
>
> From: Luo Xionghu <xionghu.luo at intel.com>
>
> 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 <xionghu.luo at intel.com>
> ---
> 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
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list