1 (* RUN: cp %s %T/scalar_opts.ml
2 * RUN: %ocamlc -g -warn-error A -package llvm.scalar_opts -linkpkg %T/scalar_opts.ml -o %t
4 * RUN: %ocamlopt -g -warn-error A -package llvm.scalar_opts -linkpkg %T/scalar_opts.ml -o %t
9 (* Note: It takes several seconds for ocamlopt to link an executable with
10 libLLVMCore.a, so it's better to write a big test than a bunch of
17 let context = global_context ()
18 let void_type = Llvm.void_type context
20 (* Tiny unit test framework - really just to help find which line is busted *)
21 let print_checkpoints = false
24 if print_checkpoints then
25 prerr_endline (name ^ ":");
29 (*===-- Fixture -----------------------------------------------------------===*)
31 let filename = Sys.argv.(1)
32 let m = create_module context filename
35 (*===-- Transforms --------------------------------------------------------===*)
37 let test_transforms () =
38 let (++) x f = f x; x in
40 let fty = function_type void_type [| |] in
41 let fn = define_function "fn" fty m in
42 ignore (build_ret_void (builder_at_end context (entry_block fn)));
44 ignore (PassManager.create_function m
46 ++ add_alignment_from_assumptions
47 ++ add_cfg_simplification
48 ++ add_dead_store_elimination
50 ++ add_merged_load_store_motion
52 ++ add_ind_var_simplification
53 ++ add_instruction_combination
63 ++ add_partially_inline_lib_calls
65 ++ add_memory_to_register_promotion
68 ++ add_scalar_repl_aggregation
69 ++ add_scalar_repl_aggregation_ssa
70 ++ add_scalar_repl_aggregation_with_threshold 4
71 ++ add_lib_call_simplification
72 ++ add_tail_call_elimination
73 ++ add_constant_propagation
74 ++ add_memory_to_register_demotion
76 ++ add_correlated_value_propagation
78 ++ add_lower_expect_intrinsic
79 ++ add_type_based_alias_analysis
80 ++ add_scoped_no_alias_alias_analysis
81 ++ add_basic_alias_analysis
82 ++ PassManager.initialize
83 ++ PassManager.run_function fn
84 ++ PassManager.finalize
85 ++ PassManager.dispose)
88 (*===-- Driver ------------------------------------------------------------===*)
91 suite "transforms" test_transforms;