aboutsummaryrefslogtreecommitdiff
path: root/test/Bindings
diff options
context:
space:
mode:
authorTorok Edwin <edwintorok@gmail.com>2011-10-14 20:38:33 +0000
committerTorok Edwin <edwintorok@gmail.com>2011-10-14 20:38:33 +0000
commitff616cb440d696b2663d55494e0a5aedfab20726 (patch)
tree0ea5a0b2564ba93558d120cfd276bb535104083c /test/Bindings
parent0be167bab219cb178f7a6e91186c700ad48aa047 (diff)
OCaml bindings: add some missing functions and testcases.
The C bindings exposed some APIs that weren't covered by the OCaml bindings git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141997 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Bindings')
-rw-r--r--test/Bindings/Ocaml/scalar_opts.ml10
-rw-r--r--test/Bindings/Ocaml/vmcore.ml31
2 files changed, 40 insertions, 1 deletions
diff --git a/test/Bindings/Ocaml/scalar_opts.ml b/test/Bindings/Ocaml/scalar_opts.ml
index 1ea97858ed..34a7a6a01b 100644
--- a/test/Bindings/Ocaml/scalar_opts.ml
+++ b/test/Bindings/Ocaml/scalar_opts.ml
@@ -42,11 +42,14 @@ let test_transforms () =
ignore (PassManager.create_function m
++ TargetData.add td
+ ++ add_verifier
++ add_constant_propagation
++ add_sccp
++ add_dead_store_elimination
++ add_aggressive_dce
++ add_scalar_repl_aggregation
+ ++ add_scalar_repl_aggregation_ssa
+ ++ add_scalar_repl_aggregation_with_threshold 4
++ add_ind_var_simplification
++ add_instruction_combination
++ add_licm
@@ -62,7 +65,14 @@ let test_transforms () =
++ add_gvn
++ add_memcpy_opt
++ add_loop_deletion
+ ++ add_loop_idiom
++ add_lib_call_simplification
+ ++ add_correlated_value_propagation
+ ++ add_early_cse
+ ++ add_lower_expect_intrinsic
+ ++ add_type_based_alias_analysis
+ ++ add_basic_alias_analysis
+ ++ add_verifier
++ PassManager.initialize
++ PassManager.run_function fn
++ PassManager.finalize
diff --git a/test/Bindings/Ocaml/vmcore.ml b/test/Bindings/Ocaml/vmcore.ml
index 34a7338682..9329286286 100644
--- a/test/Bindings/Ocaml/vmcore.ml
+++ b/test/Bindings/Ocaml/vmcore.ml
@@ -857,6 +857,14 @@ let test_builder () =
let bb00 = append_block context "Bb00" fn in
ignore (build_unreachable (builder_at_end context bb00));
+ group "function attribute";
+ begin
+ ignore (add_function_attr fn Attribute.UWTable);
+ (* RUN: grep "X7.*uwtable" < %t.ll
+ *)
+ insist ([Attribute.UWTable] = function_attr fn);
+ end;
+
(* see test/Feature/exception.ll *)
let bblpad = append_block context "Bblpad" fn in
let rt = struct_type context [| pointer_type i8_type; i32_type |] in
@@ -872,10 +880,17 @@ let test_builder () =
let lp = build_landingpad rt personality 0 "lpad"
(builder_at_end context bblpad) in begin
set_cleanup lp true;
- ignore (build_unreachable (builder_at_end context bblpad));
+ add_clause lp ztic;
+ insist((pointer_type (pointer_type i8_type)) = type_of ztid);
+ let ety = pointer_type (pointer_type i8_type) in
+ add_clause lp (const_array ety [| ztipkc; ztid |]);
+ ignore (build_resume lp (builder_at_end context bblpad));
end;
(* RUN: grep "landingpad.*personality.*__gxx_personality_v0" < %t.ll
* RUN: grep "cleanup" < %t.ll
+ * RUN: grep "catch.*i8\*\*.*@_ZTIc" < %t.ll
+ * RUN: grep "filter.*@_ZTIPKc.*@_ZTId" < %t.ll
+ * RUN: grep "resume " < %t.ll
* *)
end;
@@ -914,9 +929,23 @@ let test_builder () =
ignore (build_unreachable (builder_at_end context bb3));
let si = build_switch p1 bb3 1 (builder_at_end context bb1) in begin
ignore (add_case si (const_int i32_type 2) bb2);
+ insist (switch_default_dest si = bb3);
end;
end;
+ group "malloc/free"; begin
+ (* RUN: grep {call.*@malloc(i32 ptrtoint} < %t.ll
+ * RUN: grep {call.*@free(i8\*} < %t.ll
+ * RUN: grep {call.*@malloc(i32 %} < %t.ll
+ *)
+ let bb1 = append_block context "MallocBlock1" fn in
+ let m1 = (build_malloc (pointer_type i32_type) "m1"
+ (builder_at_end context bb1)) in
+ ignore (build_free m1 (builder_at_end context bb1));
+ ignore (build_array_malloc i32_type p1 "m2" (builder_at_end context bb1));
+ ignore (build_unreachable (builder_at_end context bb1));
+ end;
+
group "indirectbr"; begin
(* RUN: grep {indirectbr i8\\* blockaddress(@X7, %IBRBlock2), \\\[label %IBRBlock2, label %IBRBlock3\\\]} < %t.ll
*)