]>
Commit | Line | Data |
---|---|---|
85aaf69f SL |
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 | |
3 | * RUN: %t %t.bc | |
4 | * RUN: %ocamlopt -g -warn-error A -package llvm.scalar_opts -linkpkg %T/scalar_opts.ml -o %t | |
223e47cc LB |
5 | * RUN: %t %t.bc |
6 | * XFAIL: vg_leak | |
7 | *) | |
8 | ||
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 | |
11 | little ones. *) | |
12 | ||
13 | open Llvm | |
14 | open Llvm_scalar_opts | |
15 | open Llvm_target | |
16 | ||
17 | let context = global_context () | |
18 | let void_type = Llvm.void_type context | |
19 | ||
20 | (* Tiny unit test framework - really just to help find which line is busted *) | |
21 | let print_checkpoints = false | |
22 | ||
23 | let suite name f = | |
24 | if print_checkpoints then | |
25 | prerr_endline (name ^ ":"); | |
26 | f () | |
27 | ||
28 | ||
29 | (*===-- Fixture -----------------------------------------------------------===*) | |
30 | ||
31 | let filename = Sys.argv.(1) | |
32 | let m = create_module context filename | |
33 | ||
34 | ||
35 | (*===-- Transforms --------------------------------------------------------===*) | |
36 | ||
37 | let test_transforms () = | |
85aaf69f | 38 | let (++) x f = f x; x in |
223e47cc LB |
39 | |
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))); | |
85aaf69f | 43 | |
223e47cc | 44 | ignore (PassManager.create_function m |
223e47cc | 45 | ++ add_aggressive_dce |
85aaf69f SL |
46 | ++ add_alignment_from_assumptions |
47 | ++ add_cfg_simplification | |
48 | ++ add_dead_store_elimination | |
49 | ++ add_scalarizer | |
50 | ++ add_merged_load_store_motion | |
51 | ++ add_gvn | |
223e47cc LB |
52 | ++ add_ind_var_simplification |
53 | ++ add_instruction_combination | |
85aaf69f | 54 | ++ add_jump_threading |
223e47cc | 55 | ++ add_licm |
85aaf69f SL |
56 | ++ add_loop_deletion |
57 | ++ add_loop_idiom | |
223e47cc | 58 | ++ add_loop_rotation |
85aaf69f SL |
59 | ++ add_loop_reroll |
60 | ++ add_loop_unroll | |
61 | ++ add_loop_unswitch | |
62 | ++ add_memcpy_opt | |
63 | ++ add_partially_inline_lib_calls | |
64 | ++ add_lower_switch | |
223e47cc | 65 | ++ add_memory_to_register_promotion |
223e47cc | 66 | ++ add_reassociation |
85aaf69f SL |
67 | ++ add_sccp |
68 | ++ add_scalar_repl_aggregation | |
69 | ++ add_scalar_repl_aggregation_ssa | |
70 | ++ add_scalar_repl_aggregation_with_threshold 4 | |
223e47cc | 71 | ++ add_lib_call_simplification |
85aaf69f SL |
72 | ++ add_tail_call_elimination |
73 | ++ add_constant_propagation | |
74 | ++ add_memory_to_register_demotion | |
75 | ++ add_verifier | |
223e47cc LB |
76 | ++ add_correlated_value_propagation |
77 | ++ add_early_cse | |
78 | ++ add_lower_expect_intrinsic | |
79 | ++ add_type_based_alias_analysis | |
85aaf69f | 80 | ++ add_scoped_no_alias_alias_analysis |
223e47cc | 81 | ++ add_basic_alias_analysis |
223e47cc LB |
82 | ++ PassManager.initialize |
83 | ++ PassManager.run_function fn | |
84 | ++ PassManager.finalize | |
1a4d82fc | 85 | ++ PassManager.dispose) |
223e47cc LB |
86 | |
87 | ||
88 | (*===-- Driver ------------------------------------------------------------===*) | |
89 | ||
90 | let _ = | |
91 | suite "transforms" test_transforms; | |
92 | dispose_module m |