1 (* RUN: cp %s %T/scalar_opts.ml
2 * RUN: %ocamlcomp -g -warn-error A -package llvm.scalar_opts -linkpkg %T/scalar_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
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 = f x; x in
38 let fty = function_type void_type [| |] in
39 let fn = define_function "fn" fty m in
40 ignore (build_ret_void (builder_at_end context (entry_block fn)));
42 ignore (PassManager.create_function m
44 ++ add_alignment_from_assumptions
45 ++ add_cfg_simplification
46 ++ add_dead_store_elimination
48 ++ add_merged_load_store_motion
50 ++ add_ind_var_simplification
51 ++ add_instruction_combination
61 ++ add_partially_inline_lib_calls
63 ++ add_memory_to_register_promotion
66 ++ add_scalar_repl_aggregation
67 ++ add_scalar_repl_aggregation_ssa
68 ++ add_scalar_repl_aggregation_with_threshold 4
69 ++ add_lib_call_simplification
70 ++ add_tail_call_elimination
71 ++ add_constant_propagation
72 ++ add_memory_to_register_demotion
74 ++ add_correlated_value_propagation
76 ++ add_lower_expect_intrinsic
77 ++ add_type_based_alias_analysis
78 ++ add_scoped_no_alias_alias_analysis
79 ++ add_basic_alias_analysis
80 ++ PassManager.initialize
81 ++ PassManager.run_function fn
82 ++ PassManager.finalize
83 ++ PassManager.dispose)
86 (*===-- Driver ------------------------------------------------------------===*)
89 suite "transforms" test_transforms;