1 (* RUN: %ocamlopt -warn-error A llvm.cmxa llvm_scalar_opts.cmxa llvm_target.cmxa %s -o %t
4 (* Note: It takes several seconds for ocamlopt to link an executable with
5 libLLVMCore.a, so it's better to write a big test than a bunch of
12 let context = global_context ()
13 let void_type = Llvm.void_type context
15 (* Tiny unit test framework - really just to help find which line is busted *)
17 prerr_endline (name ^ ":");
21 (*===-- Fixture -----------------------------------------------------------===*)
23 let filename = Sys.argv.(1)
24 let m = create_module context filename
27 (*===-- Transforms --------------------------------------------------------===*)
29 let test_transforms () =
30 let (++) x f = ignore (f x); x in
32 let fty = function_type void_type [| |] in
33 let fn = define_function "fn" fty m in
34 ignore (build_ret_void (builder_at_end context (entry_block fn)));
36 let td = TargetData.create (target_triple m) in
38 ignore (PassManager.create_function m
40 ++ add_constant_propagation
42 ++ add_dead_store_elimination
44 ++ add_scalar_repl_aggregation
45 ++ add_ind_var_simplification
46 ++ add_instruction_combination
51 ++ add_loop_index_split
52 ++ add_memory_to_register_promotion
53 ++ add_memory_to_register_demotion
56 ++ add_cfg_simplification
57 ++ add_tail_call_elimination
61 ++ add_lib_call_simplification
62 ++ PassManager.initialize
63 ++ PassManager.run_function fn
64 ++ PassManager.finalize
65 ++ PassManager.dispose);
70 (*===-- Driver ------------------------------------------------------------===*)
73 suite "transforms" test_transforms;