[PATCH] D136400: [llvm-ocaml] Migrate from naked pointers to prepare for OCaml 5

Alan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 25 12:31:44 PST 2023


alan added inline comments.


================
Comment at: llvm/bindings/ocaml/target/target_ocaml.c:148
+value llvm_datalayout_offset_of_element(value Ty, value Index, value DL) {
+  CAMLparam1(DL);
+  CAMLreturn(caml_copy_int64(
----------------
jberdine wrote:
> alan wrote:
> > jberdine wrote:
> > > left over
> > This root is necessary. `DataLayout.t` is an OCaml custom block, not a pointer with the low bit set. `Int64.t` is also boxed. So, this function allocates on the OCaml heap and the GC needs to know that `DL` is live.
> I understand that `DL` is a custom block, but its value is only used before the allocation in `caml_copy_int64`. This is the same before and after this diff, or am I overlooking something?
`DL` is a parameter, so it needs to be live when the function ends. Otherwise, a caller could pass a `DataLayout.t` value, and that value could be invalidated by the GC during the function call.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136400/new/

https://reviews.llvm.org/D136400



More information about the llvm-commits mailing list