[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
Mon Feb 20 12:17:51 PST 2023


alan added a comment.



In D136400#4139053 <https://reviews.llvm.org/D136400#4139053>, @jberdine wrote:

> In D136400#4137328 <https://reviews.llvm.org/D136400#4137328>, @alan wrote:
>
>> Remove added CAML macros as jberdine's request
>
> Thanks! I was thinking that a significantly smaller diff would be possible. Did you see the suggested version of `llvm_param_types` I made in a comment?

I saw that, but I have some mixed feelings about this suggestion. I don't think it would make the diff significantly smaller, and I think it's a little strangely written. The original code allocates from the OCaml-managed heap and casts the pointer because it uses the naked pointer assumption to freely cast between OCaml arrays and C arrays. Now that this patch gets rid of naked pointers, I think that allocating from the OCaml heap to create an array to pass to LLVM is tackier than to just allocate an array with malloc. That being said, I'm going to go and make the change because you want it. If I view the suggested code from the perspective of "mutating each element to make it appropriate for OCaml," instead of from the perspective of "reusing the same allocation for a new array," which is how I first viewed the code, the code becomes less weird in my eyes.


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