Is it possible to write a llvm pass in OCaml?

Indeed, there's a bit of work to do still to enable this. I don't think there's anything truly 'hard', but it certainly isn't ready to go. I didn't mean to put you off, just wanted to point out the caveats that might not be immediately obvious.

If you're most interested in quick results, probably the path of least resistance is to write a pass in C++ and provide your own ocaml bindings for that; bindings for passes are extremely trivial, since passes are controlled by a single entry point (a createMyPass() function in C++). If it's feasible to execute an external program, you could also run 'opt -load'.

— Gordon