1 (* RUN: cp %s %T/ipo_opts.ml
2 * RUN: %ocamlcomp -g -warn-error A -package llvm.ipo -linkpkg %T/ipo_opts.ml -o %t
7 (* Note: It takes several seconds for ocamlopt to link an executable with
8 libLLVMCore.a, so it's better to write a big test than a bunch of
15 let context = global_context ()
16 let void_type = Llvm.void_type context
17 let i8_type = Llvm.i8_type context
19 (* Tiny unit test framework - really just to help find which line is busted *)
20 let print_checkpoints = false
23 if print_checkpoints then
24 prerr_endline (name ^ ":");
28 (*===-- Fixture -----------------------------------------------------------===*)
30 let filename = Sys.argv.(1)
31 let m = create_module context filename
34 (*===-- Transforms --------------------------------------------------------===*)
36 let test_transforms () =
37 let (++) x f = f x; x in
39 let fty = function_type i8_type [| |] in
40 let fn = define_function "fn" fty m in
41 let fn2 = define_function "fn2" fty m in begin
42 ignore (build_ret (const_int i8_type 4) (builder_at_end context (entry_block fn)));
43 let b = builder_at_end context (entry_block fn2) in
44 ignore (build_ret (build_call fn [| |] "" b) b);
47 ignore (PassManager.create ()
48 ++ add_argument_promotion
50 ++ add_dead_arg_elimination
52 ++ add_function_inlining
55 ++ add_global_optimizer
56 ++ add_ipc_propagation
59 ++ add_internalize ~all_but_main:true
60 ++ add_strip_dead_prototypes
62 ++ PassManager.run_module m
63 ++ PassManager.dispose)
66 (*===-- Driver ------------------------------------------------------------===*)
69 suite "transforms" test_transforms;