1 (* RUN: %ocamlopt -warn-error A llvm.cmxa llvm_scalar_opts.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
17 (* Tiny unit test framework - really just to help find which line is busted *)
18 let print_checkpoints = false
21 if print_checkpoints then
22 prerr_endline
(name ^
":");
26 (*===-- Fixture -----------------------------------------------------------===*)
28 let filename = Sys.argv
.(1)
29 let m = create_module
context filename
32 (*===-- Transforms --------------------------------------------------------===*)
34 let test_transforms () =
35 let (++) x f
= ignore
(f x
); x
in
37 let fty = function_type
void_type [| |] in
38 let fn = define_function
"fn" fty m in
39 ignore
(build_ret_void
(builder_at_end
context (entry_block
fn)));
41 let td = TargetData.create
(target_triple
m) in
43 ignore
(PassManager.create_function
m
45 ++ add_constant_propagation
47 ++ add_dead_store_elimination
49 ++ add_scalar_repl_aggregation
50 ++ add_ind_var_simplification
51 ++ add_instruction_combination
56 ++ add_memory_to_register_promotion
57 ++ add_memory_to_register_demotion
60 ++ add_cfg_simplification
61 ++ add_tail_call_elimination
65 ++ add_lib_call_simplification
66 ++ PassManager.initialize
67 ++ PassManager.run_function
fn
68 ++ PassManager.finalize
69 ++ PassManager.dispose
);
74 (*===-- Driver ------------------------------------------------------------===*)
77 suite "transforms" test_transforms;