[llvm-dev] ORC C Interface & JITEventListeners

Andres Freund via llvm-dev
Wed, 08 Mar 2017 19:47:19 -0000

Hi,

I am working on using LLVM to compile parts of longrunning PostgreSQL
queries into native code for faster code execution.  As postgres is,
nearly, entirely written in C and has long-lived (5 years) supported
branches (making the higher API stability important), I'm currently
using the C API.

I started out using MCJIT but it looks like that's slowly on the way
out.  My current concern is that neither the ORC MCJIT replacement, nor
the ORC C bindings appear to provide integration into JIT event
listeners.  Which I find a bit surprising - without gdb and/or profiler
integration, how is one supposed to actually use a JIT successfully?

It'd not be too bad if I had to use a small bit of, optional, code to
register a JIT event listener, but otherwise use the C API (that's what
I currently do for perf support in MCJIT), but it doesn't look like
that's an option with the ORC C bindings (RTDyldObjectLinkingLayer's
integration is a class template parameter defaulting to
DoNothingOnNotifyLoaded), and it's not used by OrcCBindingsStack.

In addition, it doesn't currently look there's C API to force the mcjit
replacement being used?

Is there interest in addressing these issues, or is the position more
generally that the C bindings aren't going to be useful enough?  I'm
willing to work on that, but only if there's actual interest in
integrating things...


I'm also a bit confused about RTDyldObjectLinkingLayer's notify
integration.  NotifyLoadedFtor is a class template parameter, but
NotifyFinalizedFtor is just a std::function defaulting to empty?  Is
that just for historical raisins, or is there a deeper reason?


To be able to use existing JITEventListeners - it'd surely be a shame to
have to rewrite them anew - in custom stacks it also appears that
there's no easy way to call JITEventListener->NotifyFreeingObject() -
the to-be-freed objects aren't readily available in
RTDyldObjectLinkingLayer.

Greetings,

Andres Freund