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>
{
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
+}
extern void
lp_free_memory_manager(LLVMMCJITMemoryManagerRef memorymgr);
+extern void
+lp_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes);
+
#ifdef __cplusplus
}
#endif