From 0235033ca158da7797319150681ade4d89349f0b Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Tue, 1 Oct 2019 08:29:07 +0000 Subject: [PATCH] Revert "[OCaml] Handle nullptr in Llvm.global_initializer" This reverts commit r373299. It broke tests: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/18485 llvm-svn: 373311 --- bindings/ocaml/llvm/llvm.ml | 2 +- bindings/ocaml/llvm/llvm.mli | 6 +++--- bindings/ocaml/llvm/llvm_ocaml.c | 12 ------------ 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/bindings/ocaml/llvm/llvm.ml b/bindings/ocaml/llvm/llvm.ml index 587972429f3..f3ff600bde4 100644 --- a/bindings/ocaml/llvm/llvm.ml +++ b/bindings/ocaml/llvm/llvm.ml @@ -710,7 +710,7 @@ external define_qualified_global : string -> llvalue -> int -> llmodule -> external lookup_global : string -> llmodule -> llvalue option = "llvm_lookup_global" external delete_global : llvalue -> unit = "llvm_delete_global" -external global_initializer : llvalue -> llvalue option = "llvm_global_initializer" +external global_initializer : llvalue -> llvalue = "LLVMGetInitializer" external set_initializer : llvalue -> llvalue -> unit = "llvm_set_initializer" external remove_initializer : llvalue -> unit = "llvm_remove_initializer" external is_thread_local : llvalue -> bool = "llvm_is_thread_local" diff --git a/bindings/ocaml/llvm/llvm.mli b/bindings/ocaml/llvm/llvm.mli index 5fedd57971d..6e145fa44f0 100644 --- a/bindings/ocaml/llvm/llvm.mli +++ b/bindings/ocaml/llvm/llvm.mli @@ -1454,9 +1454,9 @@ val is_global_constant : llvalue -> bool See the method [llvm::GlobalVariable::setConstant]. *) val set_global_constant : bool -> llvalue -> unit -(** [global_initializer gv] If global variable [gv] has an initializer it is returned, - otherwise returns [None]. See the method [llvm::GlobalVariable::getInitializer]. *) -val global_initializer : llvalue -> llvalue option +(** [global_initializer gv] returns the initializer for the global variable + [gv]. See the method [llvm::GlobalVariable::getInitializer]. *) +val global_initializer : llvalue -> llvalue (** [set_initializer c gv] sets the initializer for the global variable [gv] to the constant [c]. diff --git a/bindings/ocaml/llvm/llvm_ocaml.c b/bindings/ocaml/llvm/llvm_ocaml.c index abff3ee04a0..6af34bd9c17 100644 --- a/bindings/ocaml/llvm/llvm_ocaml.c +++ b/bindings/ocaml/llvm/llvm_ocaml.c @@ -1261,18 +1261,6 @@ CAMLprim value llvm_delete_global(LLVMValueRef GlobalVar) { return Val_unit; } -/* 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)); -} - /* llvalue -> llvalue -> unit */ CAMLprim value llvm_set_initializer(LLVMValueRef ConstantVal, LLVMValueRef GlobalVar) {