1(* RUN: cp %s %T/passmgr_builder.ml 2 * RUN: %ocamlc -g -w +A -package llvm.passmgr_builder -linkpkg %T/passmgr_builder.ml -o %t 3 * RUN: %t %t.bc 4 * RUN: %ocamlopt -g -w +A -package llvm.passmgr_builder -linkpkg %T/passmgr_builder.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_passmgr_builder 15 16let context = global_context () 17let void_type = Llvm.void_type context 18 19(* Tiny unit test framework - really just to help find which line is busted *) 20let print_checkpoints = false 21 22let suite name f = 23 if print_checkpoints then 24 prerr_endline (name ^ ":"); 25 f () 26 27 28(*===-- Fixture -----------------------------------------------------------===*) 29 30let filename = Sys.argv.(1) 31let m = create_module context filename 32 33 34(*===-- Pass Manager Builder ----------------------------------------------===*) 35 36let test_pmbuilder () = 37 let (++) x f = ignore (f x); x in 38 39 let module_passmgr = PassManager.create () in 40 let func_passmgr = PassManager.create_function m in 41 let lto_passmgr = PassManager.create () in 42 43 ignore (Llvm_passmgr_builder.create () 44 ++ set_opt_level 3 45 ++ set_size_level 1 46 ++ set_disable_unit_at_a_time false 47 ++ set_disable_unroll_loops false 48 ++ use_inliner_with_threshold 10 49 ++ populate_function_pass_manager func_passmgr 50 ++ populate_module_pass_manager module_passmgr 51 ++ populate_lto_pass_manager lto_passmgr 52 ~internalize:false ~run_inliner:false); 53 Gc.compact (); 54 55 PassManager.dispose module_passmgr; 56 PassManager.dispose func_passmgr; 57 PassManager.dispose lto_passmgr 58 59 60(*===-- Driver ------------------------------------------------------------===*) 61 62let _ = 63 suite "pass manager builder" test_pmbuilder; 64 dispose_module m 65