[OCaml] Code simplification using option allocation functions
authorJosh Berdine <josh@berdine.net>
Sat, 27 Mar 2021 22:53:35 +0000 (22:53 +0000)
committerJosh Berdine <josh@berdine.net>
Mon, 5 Apr 2021 09:55:07 +0000 (10:55 +0100)
commite5b7fedc573c8f7977c8a4800144df6d341d8887
treed13f941949a5be881233ce6965dd9fb193b9ca1a
parent58bb9222dd298a2a38b76817df18323167f095f7
[OCaml] Code simplification using option allocation functions

Using the `caml_alloc_some` and `ptr_to_option` functions that
allocate OCaml `option` values enables simplifications in many
cases. These simplifications also result in avoiding unnecessary
double initialization in many cases, so yield a minor optimization as
well.

Also, change to avoid using the old unprefixed functions such as
`alloc_small` and instead use the current `caml_alloc_small`.

A few of the changed functions were slightly rewritten in the
early-return style.

Differential Revision: https://reviews.llvm.org/D99473
llvm/bindings/ocaml/llvm/llvm_ocaml.c