1 (* RUN: %ocamlopt -warn-error A llvm.cmxa llvm_ipo.cmxa llvm_target.cmxa %s -o %t
6 (* Note: It takes several seconds for ocamlopt to link an executable with
7 libLLVMCore.a, so it's better to write a big test than a bunch of
14 let context = global_context ()
15 let void_type = Llvm.void_type context
16 let i8_type = Llvm.i8_type context
18 (* Tiny unit test framework - really just to help find which line is busted *)
19 let print_checkpoints = false
22 if print_checkpoints then
23 prerr_endline (name ^ ":");
27 (*===-- Fixture -----------------------------------------------------------===*)
29 let filename = Sys.argv.(1)
30 let m = create_module context filename
33 (*===-- Transforms --------------------------------------------------------===*)
35 let test_transforms () =
36 let (++) x f = ignore (f x); x in
38 let fty = function_type i8_type [| |] in
39 let fn = define_function "fn" fty m in
40 let fn2 = define_function "fn2" fty m in begin
41 ignore (build_ret (const_int i8_type 4) (builder_at_end context (entry_block fn)));
42 let b = builder_at_end context (entry_block fn2) in
43 ignore (build_ret (build_call fn [| |] "" b) b);
46 let td = TargetData.create (target_triple m) in
48 ignore (PassManager.create ()
50 ++ add_argument_promotion
52 ++ add_dead_arg_elimination
54 ++ add_function_inlining
56 ++ add_global_optimizer
57 ++ add_ipc_propagation
61 ++ add_strip_dead_prototypes
63 ++ PassManager.run_module m
64 ++ PassManager.dispose);
69 (*===-- Driver ------------------------------------------------------------===*)
72 suite "transforms" test_transforms;