[Mesa-dev] [PATCH 1/5] gallivm: add helper lp_add_attr_dereferenceable

Roland Scheidegger sroland at vmware.com
Tue Jul 12 21:38:32 UTC 2016


Am 12.07.2016 um 22:52 schrieb Marek Olšák:
> From: Marek Olšák <marek.olsak at amd.com>
> 
> Not sure if this is the right way to do it, but it seems to work.
> ---
>  src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 9 +++++++++
>  src/gallium/auxiliary/gallivm/lp_bld_misc.h   | 3 +++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
> index 23ef3ed..d9b62b8 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
> @@ -697,3 +697,12 @@ lp_free_memory_manager(LLVMMCJITMemoryManagerRef memorymgr)
>  {
>     delete reinterpret_cast<BaseMemoryManager*>(memorymgr);
>  }
> +
> +extern "C" void
> +lp_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes)
> +{
> +   llvm::Argument *A = llvm::unwrap<llvm::Argument>(val);
> +   llvm::AttrBuilder B;
> +   B.addDereferenceableAttr(bytes);
> +   A->addAttr(llvm::AttributeSet::get(A->getContext(), A->getArgNo() + 1,  B));
> +}
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.h b/src/gallium/auxiliary/gallivm/lp_bld_misc.h
> index d038e3b..c127c48 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.h
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.h
> @@ -73,6 +73,9 @@ lp_get_default_memory_manager();
>  extern void
>  lp_free_memory_manager(LLVMMCJITMemoryManagerRef memorymgr);
>  
> +extern void
> +lp_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes);
> +
>  #ifdef __cplusplus
>  }
>  #endif
> 

Based on some quick grepping, I've got some suspicion this won't compile
with llvm versions earlier than 3.5.
If so, could you add some ifdef?
Otherwise looks reasonable enough (of course, this being settable with
the c api would be nicer...).

Roland



More information about the mesa-dev mailing list