diff --git a/llvm/bindings/ocaml/llvm/llvm_ocaml.h b/llvm/bindings/ocaml/llvm/llvm_ocaml.h --- a/llvm/bindings/ocaml/llvm/llvm_ocaml.h +++ b/llvm/bindings/ocaml/llvm/llvm_ocaml.h @@ -33,6 +33,8 @@ value caml_alloc_some(value); #endif +/* ASSUME: Pointer is at least 2-bit aligned! Does not allocate on the OCaml + heap. */ value to_val(void *ptr); void *from_val(value v); diff --git a/llvm/bindings/ocaml/llvm/llvm_ocaml.c b/llvm/bindings/ocaml/llvm/llvm_ocaml.c --- a/llvm/bindings/ocaml/llvm/llvm_ocaml.c +++ b/llvm/bindings/ocaml/llvm/llvm_ocaml.c @@ -32,23 +32,9 @@ } #endif -value to_val(void *ptr) { - if ((((value)ptr) & 1) == 0) { - return ((value)ptr) + 1; - } else { - value v = caml_alloc(1, Abstract_tag); - *((void **)Data_abstract_val(v)) = ptr; - return v; - } -} +value to_val(void *ptr) { return ((value)ptr) + 1; } -void *from_val(value v) { - if (Is_long(v)) { - return (void *)(v - 1); - } else { - return *((void **)Data_abstract_val(v)); - } -} +void *from_val(value v) { return (void *)(v - 1); } value llvm_string_of_message(char *Message) { value String = caml_copy_string(Message);