From 6596ecf8c50b6400b02a018a438a8de98de48761 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 12 Jul 2016 18:49:57 +0200 Subject: [PATCH] gallivm: add helper lp_add_attr_dereferenceable MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Not sure if this is the right way to do it, but it seems to work. v2: make it a no-op on LLVM <= 3.5 Reviewed-by: Roland Scheidegger Reviewed-by: Nicolai Hähnle --- src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 11 +++++++++++ src/gallium/auxiliary/gallivm/lp_bld_misc.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index 23ef3edeae7..791a4702556 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp @@ -697,3 +697,14 @@ lp_free_memory_manager(LLVMMCJITMemoryManagerRef memorymgr) { delete reinterpret_cast(memorymgr); } + +extern "C" void +lp_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes) +{ +#if HAVE_LLVM >= 0x0306 + llvm::Argument *A = llvm::unwrap(val); + llvm::AttrBuilder B; + B.addDereferenceableAttr(bytes); + A->addAttr(llvm::AttributeSet::get(A->getContext(), A->getArgNo() + 1, B)); +#endif +} diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.h b/src/gallium/auxiliary/gallivm/lp_bld_misc.h index d038e3bee00..c127c480d52 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 -- 2.30.2