[InstCombine] Signed saturation patterns
[llvm-core.git] / test / Bindings / OCaml / ipo.ml
blob6a67f37570edbc46c8e9bccf9b01b13d15935fda
1 (* RUN: rm -rf %t && mkdir -p %t && cp %s %t/ipo_opts.ml
2 * RUN: %ocamlc -g -w +A -package llvm.ipo -linkpkg %t/ipo_opts.ml -o %t/executable
3 * RUN: %t/executable %t/bitcode.bc
4 * RUN: %ocamlopt -g -w +A -package llvm.ipo -linkpkg %t/ipo_opts.ml -o %t/executable
5 * RUN: %t/executable %t/bitcode.bc
6 * XFAIL: vg_leak
7 *)
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. *)
13 open Llvm
14 open Llvm_ipo
15 open Llvm_target
17 let context = global_context ()
18 let void_type = Llvm.void_type context
19 let i8_type = Llvm.i8_type context
21 (* Tiny unit test framework - really just to help find which line is busted *)
22 let print_checkpoints = false
24 let suite name f =
25 if print_checkpoints then
26 prerr_endline (name ^ ":");
27 f ()
30 (*===-- Fixture -----------------------------------------------------------===*)
32 let filename = Sys.argv.(1)
33 let m = create_module context filename
36 (*===-- Transforms --------------------------------------------------------===*)
38 let test_transforms () =
39 let (++) x f = f x; x in
41 let fty = function_type i8_type [| |] in
42 let fn = define_function "fn" fty m in
43 let fn2 = define_function "fn2" fty m in begin
44 ignore (build_ret (const_int i8_type 4) (builder_at_end context (entry_block fn)));
45 let b = builder_at_end context (entry_block fn2) in
46 ignore (build_ret (build_call fn [| |] "" b) b);
47 end;
49 ignore (PassManager.create ()
50 ++ add_argument_promotion
51 ++ add_constant_merge
52 ++ add_dead_arg_elimination
53 ++ add_function_attrs
54 ++ add_function_inlining
55 ++ add_always_inliner
56 ++ add_global_dce
57 ++ add_global_optimizer
58 ++ add_ipc_propagation
59 ++ add_prune_eh
60 ++ add_ipsccp
61 ++ add_internalize ~all_but_main:true
62 ++ add_strip_dead_prototypes
63 ++ add_strip_symbols
64 ++ PassManager.run_module m
65 ++ PassManager.dispose)
68 (*===-- Driver ------------------------------------------------------------===*)
70 let _ =
71 suite "transforms" test_transforms;
72 dispose_module m