1 (* RUN: cp %s %T/analysis.ml
2 * RUN: %ocamlcomp -warn-error A -package llvm.analysis -linkpkg %T/analysis.ml -o %t
10 (* Note that this takes a moment to link, so it's best to keep the number of
11 individual tests low. *)
13 let context = global_context ()
15 let test x = if not x then exit 1 else ()
22 let fty = function_type (void_type context) [| |] in
23 let m = create_module context "valid_m" in
24 let fn = define_function "valid_fn" fty m in
25 let at_entry = builder_at_end context (entry_block fn) in
26 ignore (build_ret_void at_entry);
29 (* Test that valid constructs verify. *)
30 begin match verify_module m with
31 Some msg -> bomb "valid module failed verification!"
35 if not (verify_function fn) then bomb "valid function failed verification!";
38 (* Test that invalid constructs do not verify.
39 A basic block can contain only one terminator instruction. *)
40 ignore (build_ret_void at_entry);
42 begin match verify_module m with
44 | None -> bomb "invalid module passed verification!"
47 if verify_function fn then bomb "invalid function passed verification!";
52 (* Don't bother to test assert_valid_{module,function}. *)