Dounia Khaldi via llvm-dev
2016-Aug-22 23:50 UTC
[llvm-dev] Where to define a new library routine in LLVM framework?
Hello, I am working on a transformation pass that converts malloc operations into HBM specific allocations. Specifically, I generate a call to a new function that I called memkind_alloc (please don't confuse it with memkind_malloc that is Intel specific library routine). The transformation has been successfully added to the compiler. However, I was not sure where to add the definition of this function. The two options I can think of are: (1) I create a new library for this and link it with LLVM. (2) extending an existing LLVM runtime library such as compiler-rt. If this is the right/best option, Is compiler-rt the right place to add a new file that will contain my new function? Please let me know your thoughts on this. Thanks, -- Dounia KHALDI Research Assistant Professor Institute for Advanced Computational Science Stony Brook University Stony Brook, NY 11794-5250 www.iacs.stonybrook.edu -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160822/566e958e/attachment.html>
Mehdi Amini via llvm-dev
2016-Aug-24 00:59 UTC
[llvm-dev] Where to define a new library routine in LLVM framework?
> On Aug 22, 2016, at 4:50 PM, Dounia Khaldi via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hello, > > I am working on a transformation pass that converts malloc operations into HBM specific allocations. Specifically, I generate a call to a new function that I called memkind_alloc (please don't confuse it with memkind_malloc that is Intel specific library routine). The transformation has been successfully added to the compiler. However, I was not sure where to add the definition of this function. > > The two options I can think of are: > (1) I create a new library for this and link it with LLVM.If you do that, the function will be present in the LLVM binary, but not in the binary *generated by LLVM*, which seems to be what you’re after. It is possible to generate the function implementation in every Module where you need it in the transformation itself, but it needs to be done programmatically, which may not be ideal for your `memkind_alloc` (I don’t know what it does).> (2) extending an existing LLVM runtime library such as compiler-rt. If this is the right/best option, Is compiler-rt the right place to add a new file that will contain my new function?Compiler-rt is usually the appropriate place for this kind of need: it is where where we put runtimes that need to be linked-in to the final binary for code generated by the compiler itself (Sanitizer, OpenMP, and other helpers…). — Mehdi