1 /*===-- analysis_ocaml.c - LLVM OCaml Glue ----------------------*- C++ -*-===*\
3 |* The LLVM Compiler Infrastructure *|
5 |* This file is distributed under the University of Illinois Open Source *|
6 |* License. See LICENSE.TXT for details. *|
8 |*===----------------------------------------------------------------------===*|
10 |* This file glues LLVM's OCaml interface to its C interface. These functions *|
11 |* are by and large transparent wrappers to the corresponding C functions. *|
13 |* Note that these functions intentionally take liberties with the CAMLparamX *|
14 |* macros, since most of the parameters are not GC heap objects. *|
16 \*===----------------------------------------------------------------------===*/
18 #include "llvm-c/Analysis.h"
19 #include "caml/alloc.h"
20 #include "caml/mlvalues.h"
21 #include "caml/memory.h"
23 /* Llvm.llmodule -> string option */
24 CAMLprim value llvm_verify_module(LLVMModuleRef M) {
26 CAMLlocal2(String, Option);
29 int Result = LLVMVerifyModule(M, LLVMReturnStatusAction, &Message);
35 String = copy_string(Message);
36 Store_field(Option, 0, String);
39 LLVMDisposeMessage(Message);
44 /* Llvm.llvalue -> bool */
45 CAMLprim value llvm_verify_function(LLVMValueRef Fn) {
46 return Val_bool(LLVMVerifyFunction(Fn, LLVMReturnStatusAction) == 0);
49 /* Llvm.llmodule -> unit */
50 CAMLprim value llvm_assert_valid_module(LLVMModuleRef M) {
51 LLVMVerifyModule(M, LLVMAbortProcessAction, 0);
55 /* Llvm.llvalue -> unit */
56 CAMLprim value llvm_assert_valid_function(LLVMValueRef Fn) {
57 LLVMVerifyFunction(Fn, LLVMAbortProcessAction);
61 /* Llvm.llvalue -> unit */
62 CAMLprim value llvm_view_function_cfg(LLVMValueRef Fn) {
63 LLVMViewFunctionCFG(Fn);
67 /* Llvm.llvalue -> unit */
68 CAMLprim value llvm_view_function_cfg_only(LLVMValueRef Fn) {
69 LLVMViewFunctionCFGOnly(Fn);