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