[PATCH] D99391: [NFC][OCaml] Simplify llvm_global_initializer using ptr_to_option

Josh Berdine via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 26 05:01:56 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb06c669114e2: [NFC][OCaml] Simplify llvm_global_initializer using ptr_to_option (authored by jberdine).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99391

Files:
  llvm/bindings/ocaml/llvm/llvm_ocaml.c


Index: llvm/bindings/ocaml/llvm/llvm_ocaml.c
===================================================================
--- llvm/bindings/ocaml/llvm/llvm_ocaml.c
+++ llvm/bindings/ocaml/llvm/llvm_ocaml.c
@@ -1349,14 +1349,7 @@
 
 /* llvalue -> llvalue option */
 CAMLprim value llvm_global_initializer(LLVMValueRef GlobalVar) {
-  CAMLparam0();
-  LLVMValueRef Init;
-  if ((Init = LLVMGetInitializer(GlobalVar))) {
-    value Option = alloc(1, 0);
-    Field(Option, 0) = (value) Init;
-    CAMLreturn(Option);
-  }
-  CAMLreturn(Val_int(0));
+  return ptr_to_option(LLVMGetInitializer(GlobalVar));
 }
 
 /* llvalue -> llvalue -> unit */


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99391.333536.patch
Type: text/x-patch
Size: 632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210326/9af864e7/attachment.bin>


More information about the llvm-commits mailing list