xref: /aosp_15_r20/external/llvm/test/Bindings/OCaml/scalar_opts.ml (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker(* RUN: cp %s %T/scalar_opts.ml
2*9880d681SAndroid Build Coastguard Worker * RUN: %ocamlc -g -w +A -package llvm.scalar_opts -linkpkg %T/scalar_opts.ml -o %t
3*9880d681SAndroid Build Coastguard Worker * RUN: %t %t.bc
4*9880d681SAndroid Build Coastguard Worker * RUN: %ocamlopt -g -w +A -package llvm.scalar_opts -linkpkg %T/scalar_opts.ml -o %t
5*9880d681SAndroid Build Coastguard Worker * RUN: %t %t.bc
6*9880d681SAndroid Build Coastguard Worker * XFAIL: vg_leak
7*9880d681SAndroid Build Coastguard Worker *)
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker(* Note: It takes several seconds for ocamlopt to link an executable with
10*9880d681SAndroid Build Coastguard Worker         libLLVMCore.a, so it's better to write a big test than a bunch of
11*9880d681SAndroid Build Coastguard Worker         little ones. *)
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Workeropen Llvm
14*9880d681SAndroid Build Coastguard Workeropen Llvm_scalar_opts
15*9880d681SAndroid Build Coastguard Workeropen Llvm_target
16*9880d681SAndroid Build Coastguard Worker
17*9880d681SAndroid Build Coastguard Workerlet context = global_context ()
18*9880d681SAndroid Build Coastguard Workerlet void_type = Llvm.void_type context
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Worker(* Tiny unit test framework - really just to help find which line is busted *)
21*9880d681SAndroid Build Coastguard Workerlet print_checkpoints = false
22*9880d681SAndroid Build Coastguard Worker
23*9880d681SAndroid Build Coastguard Workerlet suite name f =
24*9880d681SAndroid Build Coastguard Worker  if print_checkpoints then
25*9880d681SAndroid Build Coastguard Worker    prerr_endline (name ^ ":");
26*9880d681SAndroid Build Coastguard Worker  f ()
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Worker(*===-- Fixture -----------------------------------------------------------===*)
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard Workerlet filename = Sys.argv.(1)
32*9880d681SAndroid Build Coastguard Workerlet m = create_module context filename
33*9880d681SAndroid Build Coastguard Worker
34*9880d681SAndroid Build Coastguard Worker
35*9880d681SAndroid Build Coastguard Worker(*===-- Transforms --------------------------------------------------------===*)
36*9880d681SAndroid Build Coastguard Worker
37*9880d681SAndroid Build Coastguard Workerlet test_transforms () =
38*9880d681SAndroid Build Coastguard Worker  let (++) x f = f x; x in
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Worker  let fty = function_type void_type [| |] in
41*9880d681SAndroid Build Coastguard Worker  let fn = define_function "fn" fty m in
42*9880d681SAndroid Build Coastguard Worker  ignore (build_ret_void (builder_at_end context (entry_block fn)));
43*9880d681SAndroid Build Coastguard Worker
44*9880d681SAndroid Build Coastguard Worker  ignore (PassManager.create_function m
45*9880d681SAndroid Build Coastguard Worker           ++ add_aggressive_dce
46*9880d681SAndroid Build Coastguard Worker           ++ add_alignment_from_assumptions
47*9880d681SAndroid Build Coastguard Worker           ++ add_cfg_simplification
48*9880d681SAndroid Build Coastguard Worker           ++ add_dead_store_elimination
49*9880d681SAndroid Build Coastguard Worker           ++ add_scalarizer
50*9880d681SAndroid Build Coastguard Worker           ++ add_merged_load_store_motion
51*9880d681SAndroid Build Coastguard Worker           ++ add_gvn
52*9880d681SAndroid Build Coastguard Worker           ++ add_ind_var_simplification
53*9880d681SAndroid Build Coastguard Worker           ++ add_instruction_combination
54*9880d681SAndroid Build Coastguard Worker           ++ add_jump_threading
55*9880d681SAndroid Build Coastguard Worker           ++ add_licm
56*9880d681SAndroid Build Coastguard Worker           ++ add_loop_deletion
57*9880d681SAndroid Build Coastguard Worker           ++ add_loop_idiom
58*9880d681SAndroid Build Coastguard Worker           ++ add_loop_rotation
59*9880d681SAndroid Build Coastguard Worker           ++ add_loop_reroll
60*9880d681SAndroid Build Coastguard Worker           ++ add_loop_unroll
61*9880d681SAndroid Build Coastguard Worker           ++ add_loop_unswitch
62*9880d681SAndroid Build Coastguard Worker           ++ add_memcpy_opt
63*9880d681SAndroid Build Coastguard Worker           ++ add_partially_inline_lib_calls
64*9880d681SAndroid Build Coastguard Worker           ++ add_lower_switch
65*9880d681SAndroid Build Coastguard Worker           ++ add_memory_to_register_promotion
66*9880d681SAndroid Build Coastguard Worker           ++ add_reassociation
67*9880d681SAndroid Build Coastguard Worker           ++ add_sccp
68*9880d681SAndroid Build Coastguard Worker           ++ add_scalar_repl_aggregation
69*9880d681SAndroid Build Coastguard Worker           ++ add_scalar_repl_aggregation_ssa
70*9880d681SAndroid Build Coastguard Worker           ++ add_scalar_repl_aggregation_with_threshold 4
71*9880d681SAndroid Build Coastguard Worker           ++ add_lib_call_simplification
72*9880d681SAndroid Build Coastguard Worker           ++ add_tail_call_elimination
73*9880d681SAndroid Build Coastguard Worker           ++ add_constant_propagation
74*9880d681SAndroid Build Coastguard Worker           ++ add_memory_to_register_demotion
75*9880d681SAndroid Build Coastguard Worker           ++ add_verifier
76*9880d681SAndroid Build Coastguard Worker           ++ add_correlated_value_propagation
77*9880d681SAndroid Build Coastguard Worker           ++ add_early_cse
78*9880d681SAndroid Build Coastguard Worker           ++ add_lower_expect_intrinsic
79*9880d681SAndroid Build Coastguard Worker           ++ add_type_based_alias_analysis
80*9880d681SAndroid Build Coastguard Worker           ++ add_scoped_no_alias_alias_analysis
81*9880d681SAndroid Build Coastguard Worker           ++ add_basic_alias_analysis
82*9880d681SAndroid Build Coastguard Worker           ++ PassManager.initialize
83*9880d681SAndroid Build Coastguard Worker           ++ PassManager.run_function fn
84*9880d681SAndroid Build Coastguard Worker           ++ PassManager.finalize
85*9880d681SAndroid Build Coastguard Worker           ++ PassManager.dispose)
86*9880d681SAndroid Build Coastguard Worker
87*9880d681SAndroid Build Coastguard Worker
88*9880d681SAndroid Build Coastguard Worker(*===-- Driver ------------------------------------------------------------===*)
89*9880d681SAndroid Build Coastguard Worker
90*9880d681SAndroid Build Coastguard Workerlet _ =
91*9880d681SAndroid Build Coastguard Worker  suite "transforms" test_transforms;
92*9880d681SAndroid Build Coastguard Worker  dispose_module m
93