[Beignet] [PATCH] fix __kernel function called in __kernel issue.

Song, Ruiling ruiling.song at intel.com
Mon Oct 12 19:34:23 PDT 2015


I agree we should change to query constant through name instead of index.
But we still need to make things clear why this could happen?
And the patch name is not quite proper.
You can divide it into two patches, one is for "using name instead of index to query from ConstantSet"
Another is "reset the variables in printf_paser to NULL". That would be quite clear.

Thanks!
Ruiling

> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> xionghu.luo at intel.com
> Sent: Saturday, October 10, 2015 6:56 PM
> To: beignet at lists.freedesktop.org
> Cc: Luo, Xionghu
> Subject: [Beignet] [PATCH] fix __kernel function called in __kernel issue.
> 
> 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