[Beignet] [PATCH] GBE: Fix some bugs under LLVM 3.5
Zhigang Gong
zhigang.gong at linux.intel.com
Thu Jun 19 01:38:49 PDT 2014
LGTM, pushed, thanks.
On Thu, Jun 19, 2014 at 02:01:23PM +0800, Ruiling Song wrote:
> 1. use_iterator point to 'Use' now instead of 'User'.
> 2. all c-string are in constant address space now, which follows OCL Spec.
>
> Signed-off-by: Ruiling Song <ruiling.song at intel.com>
> ---
> backend/src/llvm/llvm_gen_backend.cpp | 10 ++++++++--
> backend/src/ocl_stdlib.tmpl.h | 5 +++++
> 2 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
> index 1bf59a1..a5aa038 100644
> --- a/backend/src/llvm/llvm_gen_backend.cpp
> +++ b/backend/src/llvm/llvm_gen_backend.cpp
> @@ -1524,8 +1524,14 @@ namespace gbe
> // one instruction that use the local variable, simply return.
> const Instruction *insn = NULL;
> for(Value::const_use_iterator iter = v->use_begin(); iter != v->use_end(); ++iter) {
> - if(isa<Instruction>(*iter)) return cast<const Instruction>(*iter);
> - insn = getInstructionUseLocal(*iter);
> + // After LLVM 3.5, use_iterator points to 'Use' instead of 'User', which is more straightforward.
> +#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR < 5)
> + const User *theUser = *iter;
> +#else
> + const User *theUser = iter->getUser();
> +#endif
> + if(isa<Instruction>(theUser)) return cast<const Instruction>(theUser);
> + insn = getInstructionUseLocal(theUser);
> if(insn != NULL) break;
> }
> return insn;
> diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h
> index a4bdfbd..c2eca7c 100755
> --- a/backend/src/ocl_stdlib.tmpl.h
> +++ b/backend/src/ocl_stdlib.tmpl.h
> @@ -5018,7 +5018,12 @@ INLINE_OVERLOADABLE float __gen_ocl_internal_fastpath_tanh (float x)
> #undef INLINE
>
> /* The printf function. */
> +/* From LLVM 3.5, c string are all in constant address space */
> +#if 100*__clang_major__ + __clang_minor__ < 305
> int __gen_ocl_printf_stub(const char * format, ...);
> +#else
> +int __gen_ocl_printf_stub(constant char * format, ...);
> +#endif
> #define printf __gen_ocl_printf_stub
>
> #endif /* __GEN_OCL_STDLIB_H__ */
> --
> 1.7.10.4
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list