[LLVMdev] LLVM-OCaml Bindings Tutorial (2.6-2.7)

Erick Tryzelaar idadesub at users.sourceforge.net
Tue Feb 16 00:41:45 PST 2010

On Mon, Feb 15, 2010 at 11:47 PM, Jon Harrop <jon at ffconsultancy.com> wrote:
> There are at least two other significant users of LLVM's OCaml bindings,

I'm writing an llvm backend/repl for felix, but it's pretty early.

> My only gripe with LLVM's OCaml bindings is the way an error caught on the
> LLVM side causes my program to die in a way that the stack trace is
> unobtainable. So I resort to massively verbose debug logs. I'd much rather
> the bindings reraised errors as exceptions on the OCaml side.

Unfortunately most errors are assertions, which we can't hook into.
Perhaps though we can recover some type safety. Hypothetically, I can
imagine using polymorphic variants just like lablgtk, and

type llvalue = [`Value]
type lluser = [value | `User]
type llconstant = [user | `Constant]
type llfunction = [llconstant | `Function]

val value_name : [> llvalue] -> string
val is_tail_call : [>llfunction] -> bool

Would something like this be worthwhile? If we do it right, I think we
could be mostly source compatible.

More information about the llvm-dev mailing list