[OCaml] Fix whitespace.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220829 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Peter Zotov 2014-10-28 22:39:42 +00:00
parent b4d023aafe
commit 4aaed612fe
5 changed files with 100 additions and 100 deletions

View File

@ -26,29 +26,29 @@ let _ =
let fn = define_function "valid_fn" fty m in let fn = define_function "valid_fn" fty m in
let at_entry = builder_at_end context (entry_block fn) in let at_entry = builder_at_end context (entry_block fn) in
ignore (build_ret_void at_entry); ignore (build_ret_void at_entry);
(* Test that valid constructs verify. *) (* Test that valid constructs verify. *)
begin match verify_module m with begin match verify_module m with
Some msg -> bomb "valid module failed verification!" Some msg -> bomb "valid module failed verification!"
| None -> () | None -> ()
end; end;
if not (verify_function fn) then bomb "valid function failed verification!"; if not (verify_function fn) then bomb "valid function failed verification!";
(* Test that invalid constructs do not verify. (* Test that invalid constructs do not verify.
A basic block can contain only one terminator instruction. *) A basic block can contain only one terminator instruction. *)
ignore (build_ret_void at_entry); ignore (build_ret_void at_entry);
begin match verify_module m with begin match verify_module m with
Some msg -> () Some msg -> ()
| None -> bomb "invalid module passed verification!" | None -> bomb "invalid module passed verification!"
end; end;
if verify_function fn then bomb "invalid function passed verification!"; if verify_function fn then bomb "invalid function passed verification!";
dispose_module m dispose_module m
(* Don't bother to test assert_valid_{module,function}. *) (* Don't bother to test assert_valid_{module,function}. *)

View File

@ -17,11 +17,11 @@ let test x = if not x then exit 1 else ()
let _ = let _ =
let fn = Sys.argv.(1) in let fn = Sys.argv.(1) in
let m = Llvm.create_module context "ocaml_test_module" in let m = Llvm.create_module context "ocaml_test_module" in
test (Llvm_bitwriter.write_bitcode_file m fn); test (Llvm_bitwriter.write_bitcode_file m fn);
Llvm.dispose_module m; Llvm.dispose_module m;
(* parse_bitcode *) (* parse_bitcode *)
begin begin
let mb = Llvm.MemoryBuffer.of_file fn in let mb = Llvm.MemoryBuffer.of_file fn in
@ -33,7 +33,7 @@ let _ =
raise x raise x
end end
end; end;
(* MemoryBuffer.of_file *) (* MemoryBuffer.of_file *)
test begin try test begin try
let mb = Llvm.MemoryBuffer.of_file (fn ^ ".bogus") in let mb = Llvm.MemoryBuffer.of_file (fn ^ ".bogus") in
@ -42,7 +42,7 @@ let _ =
with Llvm.IoError _ -> with Llvm.IoError _ ->
true true
end; end;
(* get_module *) (* get_module *)
begin begin
let mb = Llvm.MemoryBuffer.of_file fn in let mb = Llvm.MemoryBuffer.of_file fn in
@ -54,14 +54,14 @@ let _ =
end in end in
Llvm.dispose_module m Llvm.dispose_module m
end; end;
(* corrupt the bitcode *) (* corrupt the bitcode *)
let fn = fn ^ ".txt" in let fn = fn ^ ".txt" in
begin let oc = open_out fn in begin let oc = open_out fn in
output_string oc "not a bitcode file\n"; output_string oc "not a bitcode file\n";
close_out oc close_out oc
end; end;
(* test get_module exceptions *) (* test get_module exceptions *)
test begin test begin
try try

View File

@ -39,7 +39,7 @@ let temp_bitcode ?unbuffered m =
let _ = let _ =
let m = Llvm.create_module context "ocaml_test_module" in let m = Llvm.create_module context "ocaml_test_module" in
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 let file_buf = read_file Sys.argv.(1) in

View File

@ -40,7 +40,7 @@ let test_transforms () =
let fty = function_type void_type [| |] in let fty = function_type void_type [| |] in
let fn = define_function "fn" fty m in let fn = define_function "fn" fty m in
ignore (build_ret_void (builder_at_end context (entry_block fn))); ignore (build_ret_void (builder_at_end context (entry_block fn)));
ignore (PassManager.create_function m ignore (PassManager.create_function m
++ add_verifier ++ add_verifier
++ add_constant_propagation ++ add_constant_propagation

View File

@ -83,7 +83,7 @@ let test_target () =
set_target_triple trip m; set_target_triple trip m;
insist (trip = target_triple m) insist (trip = target_triple m)
end; end;
begin group "layout"; begin group "layout";
let layout = "e" in let layout = "e" in
set_data_layout layout m; set_data_layout layout m;
@ -193,12 +193,12 @@ let test_constants () =
insist (fp128_type = type_of cd); insist (fp128_type = type_of cd);
insist (float_of_const cd = None); insist (float_of_const cd = None);
end; end;
let one = const_int i16_type 1 in let one = const_int i16_type 1 in
let two = const_int i16_type 2 in let two = const_int i16_type 2 in
let three = const_int i32_type 3 in let three = const_int i32_type 3 in
let four = const_int i32_type 4 in let four = const_int i32_type 4 in
(* CHECK: const_array{{.*}}[i32 3, i32 4] (* CHECK: const_array{{.*}}[i32 3, i32 4]
*) *)
group "array"; group "array";
@ -230,7 +230,7 @@ let test_constants () =
let c = const_null (packed_struct_type context [| i1_type; i8_type; i64_type; let c = const_null (packed_struct_type context [| i1_type; i8_type; i64_type;
double_type |]) in double_type |]) in
ignore (define_global "const_null" c m); ignore (define_global "const_null" c m);
(* CHECK: const_all_ones{{.*}}-1 (* CHECK: const_all_ones{{.*}}-1
*) *)
group "all ones"; group "all ones";
@ -243,7 +243,7 @@ let test_constants () =
let c = const_pointer_null (pointer_type i64_type) in let c = const_pointer_null (pointer_type i64_type) in
ignore (define_global "const_pointer_null" c m); ignore (define_global "const_pointer_null" c m);
end; end;
(* CHECK: const_undef{{.*}}undef (* CHECK: const_undef{{.*}}undef
*) *)
group "undef"; group "undef";
@ -251,7 +251,7 @@ let test_constants () =
ignore (define_global "const_undef" c m); ignore (define_global "const_undef" c m);
insist (i1_type = type_of c); insist (i1_type = type_of c);
insist (is_undef c); insist (is_undef c);
group "constant arithmetic"; group "constant arithmetic";
(* CHECK: @const_neg = global i64 sub (* CHECK: @const_neg = global i64 sub
* CHECK: @const_nsw_neg = global i64 sub nsw * CHECK: @const_nsw_neg = global i64 sub nsw
@ -318,7 +318,7 @@ let test_constants () =
ignore (define_global "const_xor" (const_xor foldbomb five) m); ignore (define_global "const_xor" (const_xor foldbomb five) m);
ignore (define_global "const_icmp" (const_icmp Icmp.Sle foldbomb five) m); ignore (define_global "const_icmp" (const_icmp Icmp.Sle foldbomb five) m);
ignore (define_global "const_fcmp" (const_fcmp Fcmp.Ole ffoldbomb ffive) m); ignore (define_global "const_fcmp" (const_fcmp Fcmp.Ole ffoldbomb ffive) m);
group "constant casts"; group "constant casts";
(* CHECK: const_trunc{{.*}}trunc (* CHECK: const_trunc{{.*}}trunc
* CHECK: const_sext{{.*}}sext * CHECK: const_sext{{.*}}sext
@ -345,7 +345,7 @@ let test_constants () =
ignore (define_global "const_sitofp" (const_sitofp foldbomb double_type) m); ignore (define_global "const_sitofp" (const_sitofp foldbomb double_type) m);
ignore (define_global "const_fptoui" (const_fptoui ffoldbomb i32_type) m); ignore (define_global "const_fptoui" (const_fptoui ffoldbomb i32_type) m);
ignore (define_global "const_fptosi" (const_fptosi ffoldbomb i32_type) m); ignore (define_global "const_fptosi" (const_fptosi ffoldbomb i32_type) m);
ignore (define_global "const_ptrtoint" (const_ptrtoint ignore (define_global "const_ptrtoint" (const_ptrtoint
(const_gep (const_null (pointer_type i8_type)) (const_gep (const_null (pointer_type i8_type))
[| const_int i32_type 1 |]) [| const_int i32_type 1 |])
i32_type) m); i32_type) m);
@ -354,7 +354,7 @@ let test_constants () =
ignore (define_global "const_bitcast" (const_bitcast ffoldbomb i64_type) m); ignore (define_global "const_bitcast" (const_bitcast ffoldbomb i64_type) m);
ignore (define_global "const_intcast" ignore (define_global "const_intcast"
(const_intcast foldbomb i128_type ~is_signed:false) m); (const_intcast foldbomb i128_type ~is_signed:false) m);
group "misc constants"; group "misc constants";
(* CHECK: const_size_of{{.*}}getelementptr{{.*}}null (* CHECK: const_size_of{{.*}}getelementptr{{.*}}null
* CHECK: const_gep{{.*}}getelementptr * CHECK: const_gep{{.*}}getelementptr
@ -431,14 +431,14 @@ let test_global_values () =
let g = define_global "GVal03" zero32 m ++ let g = define_global "GVal03" zero32 m ++
set_section "Hanalei" in set_section "Hanalei" in
insist ("Hanalei" = section g); insist ("Hanalei" = section g);
(* CHECK: GVal04{{.*}}hidden (* CHECK: GVal04{{.*}}hidden
*) *)
group "visibility"; group "visibility";
let g = define_global "GVal04" zero32 m ++ let g = define_global "GVal04" zero32 m ++
set_visibility Visibility.Hidden in set_visibility Visibility.Hidden in
insist (Visibility.Hidden = visibility g); insist (Visibility.Hidden = visibility g);
(* CHECK: GVal05{{.*}}align 128 (* CHECK: GVal05{{.*}}align 128
*) *)
group "alignment"; group "alignment";
@ -475,7 +475,7 @@ let test_global_variables () =
insist (match lookup_global "QGVar01" m with Some x -> x = g insist (match lookup_global "QGVar01" m with Some x -> x = g
| None -> false); | None -> false);
end; end;
group "definitions"; begin group "definitions"; begin
(* CHECK: @GVar02 = global i32 42 (* CHECK: @GVar02 = global i32 42
* CHECK: @GVar03 = global i32 42 * CHECK: @GVar03 = global i32 42
@ -531,30 +531,30 @@ let test_global_variables () =
insist (not (is_global_constant g)); insist (not (is_global_constant g));
set_global_constant true g; set_global_constant true g;
insist (is_global_constant g); insist (is_global_constant g);
begin group "iteration"; begin group "iteration";
let m = create_module context "temp" in let m = create_module context "temp" in
insist (At_end m = global_begin m); insist (At_end m = global_begin m);
insist (At_start m = global_end m); insist (At_start m = global_end m);
let g1 = declare_global i32_type "One" m in let g1 = declare_global i32_type "One" m in
let g2 = declare_global i32_type "Two" m in let g2 = declare_global i32_type "Two" m in
insist (Before g1 = global_begin m); insist (Before g1 = global_begin m);
insist (Before g2 = global_succ g1); insist (Before g2 = global_succ g1);
insist (At_end m = global_succ g2); insist (At_end m = global_succ g2);
insist (After g2 = global_end m); insist (After g2 = global_end m);
insist (After g1 = global_pred g2); insist (After g1 = global_pred g2);
insist (At_start m = global_pred g1); insist (At_start m = global_pred g1);
let lf s x = s ^ "->" ^ value_name x in let lf s x = s ^ "->" ^ value_name x in
insist ("->One->Two" = fold_left_globals lf "" m); insist ("->One->Two" = fold_left_globals lf "" m);
let rf x s = value_name x ^ "<-" ^ s in let rf x s = value_name x ^ "<-" ^ s in
insist ("One<-Two<-" = fold_right_globals rf m ""); insist ("One<-Two<-" = fold_right_globals rf m "");
dispose_module m dispose_module m
end end
@ -629,7 +629,7 @@ let test_aliases () =
let test_functions () = let test_functions () =
let ty = function_type i32_type [| i32_type; i64_type |] in let ty = function_type i32_type [| i32_type; i64_type |] in
let ty2 = function_type i8_type [| i8_type; i64_type |] in let ty2 = function_type i8_type [| i8_type; i64_type |] in
(* CHECK: declare i32 @Fn1(i32, i64) (* CHECK: declare i32 @Fn1(i32, i64)
*) *)
begin group "declare"; begin group "declare";
@ -645,13 +645,13 @@ let test_functions () =
| None -> false); | None -> false);
insist (m == global_parent fn) insist (m == global_parent fn)
end; end;
(* CHECK-NOWHERE-NOT: Fn2 (* CHECK-NOWHERE-NOT: Fn2
*) *)
group "delete"; group "delete";
let fn = declare_function "Fn2" ty m in let fn = declare_function "Fn2" ty m in
delete_function fn; delete_function fn;
(* CHECK: define{{.*}}Fn3 (* CHECK: define{{.*}}Fn3
*) *)
group "define"; group "define";
@ -659,7 +659,7 @@ let test_functions () =
insist (not (is_declaration fn)); insist (not (is_declaration fn));
insist (1 = Array.length (basic_blocks fn)); insist (1 = Array.length (basic_blocks fn));
ignore (build_unreachable (builder_at_end context (entry_block fn))); ignore (build_unreachable (builder_at_end context (entry_block fn)));
(* CHECK: define{{.*}}Fn4{{.*}}Param1{{.*}}Param2 (* CHECK: define{{.*}}Fn4{{.*}}Param1{{.*}}Param2
*) *)
group "params"; group "params";
@ -673,7 +673,7 @@ let test_functions () =
set_value_name "Param1" params.(0); set_value_name "Param1" params.(0);
set_value_name "Param2" params.(1); set_value_name "Param2" params.(1);
ignore (build_unreachable (builder_at_end context (entry_block fn))); ignore (build_unreachable (builder_at_end context (entry_block fn)));
(* CHECK: fastcc{{.*}}Fn5 (* CHECK: fastcc{{.*}}Fn5
*) *)
group "callconv"; group "callconv";
@ -682,7 +682,7 @@ let test_functions () =
set_function_call_conv CallConv.fast fn; set_function_call_conv CallConv.fast fn;
insist (CallConv.fast = function_call_conv fn); insist (CallConv.fast = function_call_conv fn);
ignore (build_unreachable (builder_at_end context (entry_block fn))); ignore (build_unreachable (builder_at_end context (entry_block fn)));
begin group "gc"; begin group "gc";
(* CHECK: Fn6{{.*}}gc{{.*}}shadowstack (* CHECK: Fn6{{.*}}gc{{.*}}shadowstack
*) *)
@ -695,30 +695,30 @@ let test_functions () =
set_gc (Some "shadowstack") fn; set_gc (Some "shadowstack") fn;
ignore (build_unreachable (builder_at_end context (entry_block fn))); ignore (build_unreachable (builder_at_end context (entry_block fn)));
end; end;
begin group "iteration"; begin group "iteration";
let m = create_module context "temp" in let m = create_module context "temp" in
insist (At_end m = function_begin m); insist (At_end m = function_begin m);
insist (At_start m = function_end m); insist (At_start m = function_end m);
let f1 = define_function "One" ty m in let f1 = define_function "One" ty m in
let f2 = define_function "Two" ty m in let f2 = define_function "Two" ty m in
insist (Before f1 = function_begin m); insist (Before f1 = function_begin m);
insist (Before f2 = function_succ f1); insist (Before f2 = function_succ f1);
insist (At_end m = function_succ f2); insist (At_end m = function_succ f2);
insist (After f2 = function_end m); insist (After f2 = function_end m);
insist (After f1 = function_pred f2); insist (After f1 = function_pred f2);
insist (At_start m = function_pred f1); insist (At_start m = function_pred f1);
let lf s x = s ^ "->" ^ value_name x in let lf s x = s ^ "->" ^ value_name x in
insist ("->One->Two" = fold_left_functions lf "" m); insist ("->One->Two" = fold_left_functions lf "" m);
let rf x s = value_name x ^ "<-" ^ s in let rf x s = value_name x ^ "<-" ^ s in
insist ("One<-Two<-" = fold_right_functions rf m ""); insist ("One<-Two<-" = fold_right_functions rf m "");
dispose_module m dispose_module m
end end
@ -728,12 +728,12 @@ let test_functions () =
let test_params () = let test_params () =
begin group "iteration"; begin group "iteration";
let m = create_module context "temp" in let m = create_module context "temp" in
let vf = define_function "void" (function_type void_type [| |]) m in let vf = define_function "void" (function_type void_type [| |]) m in
insist (At_end vf = param_begin vf); insist (At_end vf = param_begin vf);
insist (At_start vf = param_end vf); insist (At_start vf = param_end vf);
let ty = function_type void_type [| i32_type; i32_type |] in let ty = function_type void_type [| i32_type; i32_type |] in
let f = define_function "f" ty m in let f = define_function "f" ty m in
let p1 = param f 0 in let p1 = param f 0 in
@ -750,17 +750,17 @@ let test_params () =
insist (Before p1 = param_begin f); insist (Before p1 = param_begin f);
insist (Before p2 = param_succ p1); insist (Before p2 = param_succ p1);
insist (At_end f = param_succ p2); insist (At_end f = param_succ p2);
insist (After p2 = param_end f); insist (After p2 = param_end f);
insist (After p1 = param_pred p2); insist (After p1 = param_pred p2);
insist (At_start f = param_pred p1); insist (At_start f = param_pred p1);
let lf s x = s ^ "->" ^ value_name x in let lf s x = s ^ "->" ^ value_name x in
insist ("->One->Two" = fold_left_params lf "" f); insist ("->One->Two" = fold_left_params lf "" f);
let rf x s = value_name x ^ "<-" ^ s in let rf x s = value_name x ^ "<-" ^ s in
insist ("One<-Two<-" = fold_right_params rf f ""); insist ("One<-Two<-" = fold_right_params rf f "");
dispose_module m dispose_module m
end end
@ -769,7 +769,7 @@ let test_params () =
let test_basic_blocks () = let test_basic_blocks () =
let ty = function_type void_type [| |] in let ty = function_type void_type [| |] in
(* CHECK: Bb1 (* CHECK: Bb1
*) *)
group "entry"; group "entry";
@ -777,14 +777,14 @@ let test_basic_blocks () =
let bb = append_block context "Bb1" fn in let bb = append_block context "Bb1" fn in
insist (bb = entry_block fn); insist (bb = entry_block fn);
ignore (build_unreachable (builder_at_end context bb)); ignore (build_unreachable (builder_at_end context bb));
(* CHECK-NOWHERE-NOT: Bb2 (* CHECK-NOWHERE-NOT: Bb2
*) *)
group "delete"; group "delete";
let fn = declare_function "X2" ty m in let fn = declare_function "X2" ty m in
let bb = append_block context "Bb2" fn in let bb = append_block context "Bb2" fn in
delete_block bb; delete_block bb;
group "insert"; group "insert";
let fn = declare_function "X3" ty m in let fn = declare_function "X3" ty m in
let bbb = append_block context "b" fn in let bbb = append_block context "b" fn in
@ -792,7 +792,7 @@ let test_basic_blocks () =
insist ([| bba; bbb |] = basic_blocks fn); insist ([| bba; bbb |] = basic_blocks fn);
ignore (build_unreachable (builder_at_end context bba)); ignore (build_unreachable (builder_at_end context bba));
ignore (build_unreachable (builder_at_end context bbb)); ignore (build_unreachable (builder_at_end context bbb));
(* CHECK: Bb3 (* CHECK: Bb3
*) *)
group "name/value"; group "name/value";
@ -802,7 +802,7 @@ let test_basic_blocks () =
let bbv = value_of_block bb in let bbv = value_of_block bb in
set_value_name "Bb3" bbv; set_value_name "Bb3" bbv;
insist ("Bb3" = value_name bbv); insist ("Bb3" = value_name bbv);
group "casts"; group "casts";
let fn = define_function "X5" ty m in let fn = define_function "X5" ty m in
let bb = entry_block fn in let bb = entry_block fn in
@ -810,31 +810,31 @@ let test_basic_blocks () =
insist (bb = block_of_value (value_of_block bb)); insist (bb = block_of_value (value_of_block bb));
insist (value_is_block (value_of_block bb)); insist (value_is_block (value_of_block bb));
insist (not (value_is_block (const_null i32_type))); insist (not (value_is_block (const_null i32_type)));
begin group "iteration"; begin group "iteration";
let m = create_module context "temp" in let m = create_module context "temp" in
let f = declare_function "Temp" (function_type i32_type [| |]) m in let f = declare_function "Temp" (function_type i32_type [| |]) m in
insist (At_end f = block_begin f); insist (At_end f = block_begin f);
insist (At_start f = block_end f); insist (At_start f = block_end f);
let b1 = append_block context "One" f in let b1 = append_block context "One" f in
let b2 = append_block context "Two" f in let b2 = append_block context "Two" f in
insist (Before b1 = block_begin f); insist (Before b1 = block_begin f);
insist (Before b2 = block_succ b1); insist (Before b2 = block_succ b1);
insist (At_end f = block_succ b2); insist (At_end f = block_succ b2);
insist (After b2 = block_end f); insist (After b2 = block_end f);
insist (After b1 = block_pred b2); insist (After b1 = block_pred b2);
insist (At_start f = block_pred b1); insist (At_start f = block_pred b1);
let lf s x = s ^ "->" ^ value_name (value_of_block x) in let lf s x = s ^ "->" ^ value_name (value_of_block x) in
insist ("->One->Two" = fold_left_blocks lf "" f); insist ("->One->Two" = fold_left_blocks lf "" f);
let rf x s = value_name (value_of_block x) ^ "<-" ^ s in let rf x s = value_name (value_of_block x) ^ "<-" ^ s in
insist ("One<-Two<-" = fold_right_blocks rf f ""); insist ("One<-Two<-" = fold_right_blocks rf f "");
dispose_module m dispose_module m
end end
@ -848,27 +848,27 @@ let test_instructions () =
let f = define_function "f" fty m in let f = define_function "f" fty m in
let bb = entry_block f in let bb = entry_block f in
let b = builder_at context (At_end bb) in let b = builder_at context (At_end bb) in
insist (At_end bb = instr_begin bb); insist (At_end bb = instr_begin bb);
insist (At_start bb = instr_end bb); insist (At_start bb = instr_end bb);
let i1 = build_add (param f 0) (param f 1) "One" b in let i1 = build_add (param f 0) (param f 1) "One" b in
let i2 = build_sub (param f 0) (param f 1) "Two" b in let i2 = build_sub (param f 0) (param f 1) "Two" b in
insist (Before i1 = instr_begin bb); insist (Before i1 = instr_begin bb);
insist (Before i2 = instr_succ i1); insist (Before i2 = instr_succ i1);
insist (At_end bb = instr_succ i2); insist (At_end bb = instr_succ i2);
insist (After i2 = instr_end bb); insist (After i2 = instr_end bb);
insist (After i1 = instr_pred i2); insist (After i1 = instr_pred i2);
insist (At_start bb = instr_pred i1); insist (At_start bb = instr_pred i1);
let lf s x = s ^ "->" ^ value_name x in let lf s x = s ^ "->" ^ value_name x in
insist ("->One->Two" = fold_left_instrs lf "" bb); insist ("->One->Two" = fold_left_instrs lf "" bb);
let rf x s = value_name x ^ "<-" ^ s in let rf x s = value_name x ^ "<-" ^ s in
insist ("One<-Two<-" = fold_right_instrs rf bb ""); insist ("One<-Two<-" = fold_right_instrs rf bb "");
dispose_module m dispose_module m
end; end;
@ -895,14 +895,14 @@ let test_instructions () =
let test_builder () = let test_builder () =
let (++) x f = f x; x in let (++) x f = f x; x in
begin group "parent"; begin group "parent";
insist (try insist (try
ignore (insertion_block (builder context)); ignore (insertion_block (builder context));
false false
with Not_found -> with Not_found ->
true); true);
let fty = function_type void_type [| i32_type |] in let fty = function_type void_type [| i32_type |] in
let fn = define_function "BuilderParent" fty m in let fn = define_function "BuilderParent" fty m in
let bb = entry_block fn in let bb = entry_block fn in
@ -910,13 +910,13 @@ let test_builder () =
let p = param fn 0 in let p = param fn 0 in
let sum = build_add p p "sum" b in let sum = build_add p p "sum" b in
ignore (build_ret_void b); ignore (build_ret_void b);
insist (fn = block_parent bb); insist (fn = block_parent bb);
insist (fn = param_parent p); insist (fn = param_parent p);
insist (bb = instr_parent sum); insist (bb = instr_parent sum);
insist (bb = insertion_block b) insist (bb = insertion_block b)
end; end;
group "ret void"; group "ret void";
begin begin
(* CHECK: ret void (* CHECK: ret void
@ -938,7 +938,7 @@ let test_builder () =
let agg = [| const_int i8_type 4; const_int i64_type 5 |] in let agg = [| const_int i8_type 4; const_int i64_type 5 |] in
ignore (build_aggregate_ret agg b) ignore (build_aggregate_ret agg b)
end; end;
(* The rest of the tests will use one big function. *) (* The rest of the tests will use one big function. *)
let fty = function_type i32_type [| i32_type; i32_type |] in let fty = function_type i32_type [| i32_type; i32_type |] in
let fn = define_function "X7" fty m in let fn = define_function "X7" fty m in
@ -947,7 +947,7 @@ let test_builder () =
let p2 = param fn 1 ++ set_value_name "P2" in let p2 = param fn 1 ++ set_value_name "P2" in
let f1 = build_uitofp p1 float_type "F1" atentry in let f1 = build_uitofp p1 float_type "F1" atentry in
let f2 = build_uitofp p2 float_type "F2" atentry in let f2 = build_uitofp p2 float_type "F2" atentry in
let bb00 = append_block context "Bb00" fn in let bb00 = append_block context "Bb00" fn in
ignore (build_unreachable (builder_at_end context bb00)); ignore (build_unreachable (builder_at_end context bb00));
@ -1202,7 +1202,7 @@ let test_builder () =
insist (is_conditional br = false) ; insist (is_conditional br = false) ;
insist (get_branch br = Some (`Unconditional bb02)) ; insist (get_branch br = Some (`Unconditional bb02)) ;
end; end;
group "cond_br"; begin group "cond_br"; begin
(* CHECK: br{{.*}}build_br{{.*}}Bb03{{.*}}Bb00 (* CHECK: br{{.*}}build_br{{.*}}Bb03{{.*}}Bb00
*) *)
@ -1216,7 +1216,7 @@ let test_builder () =
insist (is_conditional br = true) ; insist (is_conditional br = true) ;
insist (get_branch br = Some (`Conditional (cond, bb03, bb00))) ; insist (get_branch br = Some (`Conditional (cond, bb03, bb00))) ;
end; end;
group "switch"; begin group "switch"; begin
(* CHECK: switch{{.*}}P1{{.*}}SwiBlock3 (* CHECK: switch{{.*}}P1{{.*}}SwiBlock3
* CHECK: 2,{{.*}}SwiBlock2 * CHECK: 2,{{.*}}SwiBlock2
@ -1263,7 +1263,7 @@ let test_builder () =
ignore (add_destination ibr bb2); ignore (add_destination ibr bb2);
ignore (add_destination ibr bb3) ignore (add_destination ibr bb3)
end; end;
group "invoke"; begin group "invoke"; begin
(* CHECK: build_invoke{{.*}}invoke{{.*}}P1{{.*}}P2 (* CHECK: build_invoke{{.*}}invoke{{.*}}P1{{.*}}P2
* CHECK: to{{.*}}Bb04{{.*}}unwind{{.*}}Bblpad * CHECK: to{{.*}}Bb04{{.*}}unwind{{.*}}Bblpad
@ -1272,7 +1272,7 @@ let test_builder () =
let b = builder_at_end context bb04 in let b = builder_at_end context bb04 in
ignore (build_invoke fn [| p1; p2 |] bb04 bblpad "build_invoke" b) ignore (build_invoke fn [| p1; p2 |] bb04 bblpad "build_invoke" b)
end; end;
group "unreachable"; begin group "unreachable"; begin
(* CHECK: unreachable (* CHECK: unreachable
*) *)
@ -1280,11 +1280,11 @@ let test_builder () =
let b = builder_at_end context bb06 in let b = builder_at_end context bb06 in
ignore (build_unreachable b) ignore (build_unreachable b)
end; end;
group "arithmetic"; begin group "arithmetic"; begin
let bb07 = append_block context "Bb07" fn in let bb07 = append_block context "Bb07" fn in
let b = builder_at_end context bb07 in let b = builder_at_end context bb07 in
(* CHECK: %build_add = add i32 %P1, %P2 (* CHECK: %build_add = add i32 %P1, %P2
* CHECK: %build_nsw_add = add nsw i32 %P1, %P2 * CHECK: %build_nsw_add = add nsw i32 %P1, %P2
* CHECK: %build_nuw_add = add nuw i32 %P1, %P2 * CHECK: %build_nuw_add = add nuw i32 %P1, %P2
@ -1348,7 +1348,7 @@ let test_builder () =
ignore (build_not p1 "build_not" b); ignore (build_not p1 "build_not" b);
ignore (build_unreachable b) ignore (build_unreachable b)
end; end;
group "memory"; begin group "memory"; begin
let bb08 = append_block context "Bb08" fn in let bb08 = append_block context "Bb08" fn in
let b = builder_at_end context bb08 in let b = builder_at_end context bb08 in
@ -1409,18 +1409,18 @@ let test_builder () =
*) *)
let b1 = append_block context "PhiBlock1" fn in let b1 = append_block context "PhiBlock1" fn in
let b2 = append_block context "PhiBlock2" fn in let b2 = append_block context "PhiBlock2" fn in
let jb = append_block context "PhiJoinBlock" fn in let jb = append_block context "PhiJoinBlock" fn in
ignore (build_br jb (builder_at_end context b1)); ignore (build_br jb (builder_at_end context b1));
ignore (build_br jb (builder_at_end context b2)); ignore (build_br jb (builder_at_end context b2));
let at_jb = builder_at_end context jb in let at_jb = builder_at_end context jb in
let phi = build_phi [(p1, b1)] "PhiNode" at_jb in let phi = build_phi [(p1, b1)] "PhiNode" at_jb in
insist ([(p1, b1)] = incoming phi); insist ([(p1, b1)] = incoming phi);
add_incoming (p2, b2) phi; add_incoming (p2, b2) phi;
insist ([(p1, b1); (p2, b2)] = incoming phi); insist ([(p1, b1); (p2, b2)] = incoming phi);
ignore (build_unreachable at_jb); ignore (build_unreachable at_jb);
end end
@ -1442,12 +1442,12 @@ let test_pass_manager () =
++ PassManager.run_module m ++ PassManager.run_module m
++ PassManager.dispose) ++ PassManager.dispose)
end; end;
begin group "function pass manager"; begin group "function pass manager";
let fty = function_type void_type [| |] in let fty = function_type void_type [| |] in
let fn = define_function "FunctionPassManager" fty m in let fn = define_function "FunctionPassManager" fty m in
ignore (build_ret_void (builder_at_end context (entry_block fn))); ignore (build_ret_void (builder_at_end context (entry_block fn)));
ignore (PassManager.create_function m ignore (PassManager.create_function m
++ PassManager.initialize ++ PassManager.initialize
++ PassManager.run_function fn ++ PassManager.run_function fn
@ -1474,7 +1474,7 @@ let test_writer () =
group "writer"; group "writer";
insist (write_bitcode_file m filename); insist (write_bitcode_file m filename);
dispose_module m dispose_module m