diff options
Diffstat (limited to 'test/Bindings/Ocaml')
-rw-r--r-- | test/Bindings/Ocaml/bitwriter.ml | 34 | ||||
-rw-r--r-- | test/Bindings/Ocaml/scalar_opts.ml | 23 |
2 files changed, 51 insertions, 6 deletions
diff --git a/test/Bindings/Ocaml/bitwriter.ml b/test/Bindings/Ocaml/bitwriter.ml index 57caac7..ef1c9ab 100644 --- a/test/Bindings/Ocaml/bitwriter.ml +++ b/test/Bindings/Ocaml/bitwriter.ml @@ -1,4 +1,4 @@ -(* RUN: %ocamlopt -warn-error A llvm.cmxa llvm_bitwriter.cmxa %s -o %t +(* RUN: %ocamlopt -warn-error A unix.cmxa llvm.cmxa llvm_bitwriter.cmxa %s -o %t * RUN: ./%t %t.bc * RUN: llvm-dis < %t.bc | grep caml_int_ty *) @@ -10,9 +10,37 @@ let context = Llvm.global_context () let test x = if not x then exit 1 else () +let read_file name = + let ic = open_in_bin name in + let len = in_channel_length ic in + let buf = String.create len in + + test ((input ic buf 0 len) = len); + + close_in ic; + + buf + +let temp_bitcode ?unbuffered m = + let temp_name, temp_oc = Filename.open_temp_file ~mode:[Open_binary] "" "" in + + test (Llvm_bitwriter.output_bitcode ?unbuffered temp_oc m); + flush temp_oc; + + let temp_buf = read_file temp_name in + + close_out temp_oc; + + temp_buf + let _ = let m = Llvm.create_module context "ocaml_test_module" in ignore (Llvm.define_type_name "caml_int_ty" (Llvm.i32_type context) m); - - test (Llvm_bitwriter.write_bitcode_file m Sys.argv.(1)) + + test (Llvm_bitwriter.write_bitcode_file m Sys.argv.(1)); + let file_buf = read_file Sys.argv.(1) in + + test (file_buf = temp_bitcode m); + test (file_buf = temp_bitcode ~unbuffered:false m); + test (file_buf = temp_bitcode ~unbuffered:true m) diff --git a/test/Bindings/Ocaml/scalar_opts.ml b/test/Bindings/Ocaml/scalar_opts.ml index 1b488c5..f28eff2 100644 --- a/test/Bindings/Ocaml/scalar_opts.ml +++ b/test/Bindings/Ocaml/scalar_opts.ml @@ -37,11 +37,28 @@ let test_transforms () = ignore (PassManager.create_function m ++ TargetData.add td - ++ add_instruction_combining + ++ add_constant_propagation + ++ add_sccp + ++ add_dead_store_elimination + ++ add_aggressive_dce + ++ add_scalar_repl_aggregation + ++ add_ind_var_simplification + ++ add_instruction_combination + ++ add_licm + ++ add_loop_unswitch + ++ add_loop_unroll + ++ add_loop_rotation + ++ add_loop_index_split + ++ add_memory_to_register_promotion + ++ add_memory_to_register_demotion ++ add_reassociation - ++ add_gvn + ++ add_jump_threading ++ add_cfg_simplification - ++ add_constant_propagation + ++ add_tail_call_elimination + ++ add_gvn + ++ add_memcpy_opt + ++ add_loop_deletion + ++ add_lib_call_simplification ++ PassManager.initialize ++ PassManager.run_function fn ++ PassManager.finalize |