| 1 | (*===-- llvm_analysis.mli - LLVM OCaml Interface --------------*- OCaml -*-===* |
| 2 | * |
| 3 | * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | * See https://llvm.org/LICENSE.txt for license information. |
| 5 | * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | * |
| 7 | *===----------------------------------------------------------------------===*) |
| 8 | |
| 9 | (** Intermediate representation analysis. |
| 10 | |
| 11 | This interface provides an OCaml API for LLVM IR analyses, the classes in |
| 12 | the Analysis library. *) |
| 13 | |
| 14 | (** [verify_module m] returns [None] if the module [m] is valid, and |
| 15 | [Some reason] if it is invalid. [reason] is a string containing a |
| 16 | human-readable validation report. See [llvm::verifyModule]. *) |
| 17 | external verify_module : Llvm.llmodule -> string option = "llvm_verify_module" |
| 18 | |
| 19 | (** [verify_function f] returns [true] if the function [f] is valid, and |
| 20 | [false] if it is invalid. See [llvm::verifyFunction]. *) |
| 21 | external verify_function : Llvm.llvalue -> bool = "llvm_verify_function" |
| 22 | |
| 23 | (** [verify_module m] returns if the module [m] is valid, but prints a |
| 24 | validation report to [stderr] and aborts the program if it is invalid. See |
| 25 | [llvm::verifyModule]. *) |
| 26 | external assert_valid_module : Llvm.llmodule -> unit |
| 27 | = "llvm_assert_valid_module" |
| 28 | |
| 29 | (** [verify_function f] returns if the function [f] is valid, but prints a |
| 30 | validation report to [stderr] and aborts the program if it is invalid. See |
| 31 | [llvm::verifyFunction]. *) |
| 32 | external assert_valid_function : Llvm.llvalue -> unit |
| 33 | = "llvm_assert_valid_function" |
| 34 | |
| 35 | (** [view_function_cfg f] opens up a ghostscript window displaying the CFG of |
| 36 | the current function with the code for each basic block inside. |
| 37 | See [llvm::Function::viewCFG]. *) |
| 38 | external view_function_cfg : Llvm.llvalue -> unit = "llvm_view_function_cfg" |
| 39 | |
| 40 | (** [view_function_cfg_only f] works just like [view_function_cfg], but does not |
| 41 | include the contents of basic blocks into the nodes. |
| 42 | See [llvm::Function::viewCFGOnly]. *) |
| 43 | external view_function_cfg_only : Llvm.llvalue -> unit |
| 44 | = "llvm_view_function_cfg_only" |