[llvm] [OCaml][NPM] Add OCaml bindings to new pass manager (PR #66421)
Josh Berdine via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 14 13:31:04 PDT 2023
https://github.com/jberdine approved this pull request.
This LGTM. I made a few minor comments, but nothing that needs another round of review.
Regarding the question of how to expose the LLVM error reporting mechanics, there are 3 reasonable options I know of:
1. use `result` just as you have
2. use `option` where `None` means "no error" and `Some msg` means an error described by msg occurred
3. use exceptions
If you want, you could post on the ocaml discuss with the function signature and a brief description of what underlying functionality is being exposed. I would not be surprised to see different people offer support for all of the options. Overall though, there is a move in the ocaml community away from using exceptions toward either `option` or `result`, so I expect choice 3 to be the least supported. Choosing between 1 and 2 is harder. If `LLVMRunPasses` was very light and expected to be fast, using option 2 would avoid an allocation in the common case, which might be worth it. But in this case that won't matter, and it is probably (my opinion) better to have the no-error case be reported as `Ok` and the error case be reported as `Error` rather than `None` and `Some error` which is opposite to usual usage where `None` represents an unspecified error.
https://github.com/llvm/llvm-project/pull/66421
More information about the llvm-commits
mailing list