1(* RUN: cp %s %T/vectorize_opts.ml 2 * RUN: %ocamlc -g -warn-error A -package llvm.vectorize -linkpkg %T/vectorize_opts.ml -o %t 3 * RUN: %t %t.bc 4 * RUN: %ocamlopt -g -warn-error A -package llvm.vectorize -linkpkg %T/vectorize_opts.ml -o %t 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 13open Llvm 14open Llvm_vectorize 15open Llvm_target 16 17let context = global_context () 18let void_type = Llvm.void_type context 19 20(* Tiny unit test framework - really just to help find which line is busted *) 21let print_checkpoints = false 22 23let suite name f = 24 if print_checkpoints then 25 prerr_endline (name ^ ":"); 26 f () 27 28 29(*===-- Fixture -----------------------------------------------------------===*) 30 31let filename = Sys.argv.(1) 32let m = create_module context filename 33 34 35(*===-- Transforms --------------------------------------------------------===*) 36 37let test_transforms () = 38 let (++) x f = f x; x in 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))); 43 44 ignore (PassManager.create () 45 ++ add_bb_vectorize 46 ++ add_loop_vectorize 47 ++ add_slp_vectorize 48 ++ PassManager.run_module m 49 ++ PassManager.dispose) 50 51 52(*===-- Driver ------------------------------------------------------------===*) 53 54let _ = 55 suite "transforms" test_transforms; 56 dispose_module m 57