gallivm: add helper lp_add_attr_dereferenceable

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 <sroland@vmware.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
Marek Olšák 2016-07-12 18:49:57 +02:00
parent bccf9de4df
commit 6596ecf8c5
2 changed files with 14 additions and 0 deletions

View File

@ -697,3 +697,14 @@ lp_free_memory_manager(LLVMMCJITMemoryManagerRef memorymgr)
{
delete reinterpret_cast<BaseMemoryManager*>(memorymgr);
}
extern "C" void
lp_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes)
{
#if HAVE_LLVM >= 0x0306
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));
#endif
}

View File

@ -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