aboutsummaryrefslogtreecommitdiffstats
path: root/test/Bindings
diff options
context:
space:
mode:
Diffstat (limited to 'test/Bindings')
-rw-r--r--test/Bindings/Go/go.test2
-rw-r--r--test/Bindings/OCaml/core.ml17
-rw-r--r--test/Bindings/OCaml/executionengine.ml11
-rw-r--r--test/Bindings/OCaml/linker.ml6
-rw-r--r--test/Bindings/OCaml/lit.local.cfg2
-rw-r--r--test/Bindings/OCaml/transform_utils.ml21
-rw-r--r--test/Bindings/llvm-c/Inputs/invalid.ll.bcbin0 -> 332 bytes
-rw-r--r--test/Bindings/llvm-c/add_named_metadata_operand.ll2
-rw-r--r--test/Bindings/llvm-c/invalid-bitcode.test3
-rw-r--r--test/Bindings/llvm-c/set_metadata.ll2
10 files changed, 55 insertions, 11 deletions
diff --git a/test/Bindings/Go/go.test b/test/Bindings/Go/go.test
index 3951483..14eb328 100644
--- a/test/Bindings/Go/go.test
+++ b/test/Bindings/Go/go.test
@@ -1,3 +1,3 @@
; RUN: llvm-go test llvm.org/llvm/bindings/go/llvm
-; REQUIRES: shell
+; REQUIRES: shell, not_ubsan
diff --git a/test/Bindings/OCaml/core.ml b/test/Bindings/OCaml/core.ml
index c08351e..c5e47e7 100644
--- a/test/Bindings/OCaml/core.ml
+++ b/test/Bindings/OCaml/core.ml
@@ -1146,7 +1146,7 @@ let test_builder () =
(* CHECK: %dbg = add i32 %P1, %P2, !dbg !2
* !2 is metadata emitted at EOF.
*)
- insist ((current_debug_location atentry) = None);
+ insist ((current_debug_location atentry) = Some (mdnode context [||]));
let m_line = const_int i32_type 2 in
let m_col = const_int i32_type 3 in
@@ -1428,15 +1428,24 @@ let test_builder () =
add_incoming (p2, b2) phi;
insist ([(p1, b1); (p2, b2)] = incoming phi);
+ (* CHECK: %PhiEmptyNode = phi i8
+ *)
+ let phi_empty = build_empty_phi i8_type "PhiEmptyNode" at_jb in
+ insist ([] = incoming phi_empty);
+
+ (* can't emit an empty phi to bitcode *)
+ add_incoming (const_int i8_type 1, b1) phi_empty;
+ add_incoming (const_int i8_type 2, b2) phi_empty;
+
ignore (build_unreachable at_jb);
end
(* End-of-file checks for things like metdata and attributes.
* CHECK: attributes #0 = {{.*}}uwtable{{.*}}
* CHECK: !llvm.module.flags = !{!0}
- * CHECK: !0 = metadata !{i32 1, metadata !"Debug Info Version", i32 2}
- * CHECK: !1 = metadata !{i32 1, metadata !"metadata test"}
- * CHECK: !2 = metadata !{i32 2, i32 3, metadata !3, metadata !3}
+ * CHECK: !0 = !{i32 1, !"Debug Info Version", i32 2}
+ * CHECK: !1 = !{i32 1, !"metadata test"}
+ * CHECK: !2 = !MDLocation(line: 2, column: 3, scope: !3, inlinedAt: !3)
*)
(*===-- Pass Managers -----------------------------------------------------===*)
diff --git a/test/Bindings/OCaml/executionengine.ml b/test/Bindings/OCaml/executionengine.ml
index 893f988..1de2cfb 100644
--- a/test/Bindings/OCaml/executionengine.ml
+++ b/test/Bindings/OCaml/executionengine.ml
@@ -50,7 +50,10 @@ let test_executionengine () =
let ee = create m in
(* add plus *)
- let plus = define_plus m in
+ ignore (define_plus m);
+
+ (* declare global variable *)
+ ignore (define_global "globvar" (const_int i32_type 23) m);
(* add module *)
let m2 = create_module (global_context ()) "test_module2" in
@@ -73,9 +76,13 @@ let test_executionengine () =
(* run_static_ctors *)
run_static_ctors ee;
+ (* get a handle on globvar *)
+ let varh = get_global_value_address "globvar" int32_t ee in
+ if 23l <> varh then bomb "get_global_value_address didn't work";
+
(* call plus *)
let cplusty = Foreign.funptr (int32_t @-> int32_t @-> returning int32_t) in
- let cplus = get_pointer_to_global plus cplusty ee in
+ let cplus = get_function_address "plus" cplusty ee in
if 4l <> cplus 2l 2l then bomb "plus didn't work";
(* call getglobal *)
diff --git a/test/Bindings/OCaml/linker.ml b/test/Bindings/OCaml/linker.ml
index 00064b0..1ea0be9 100644
--- a/test/Bindings/OCaml/linker.ml
+++ b/test/Bindings/OCaml/linker.ml
@@ -39,19 +39,19 @@ let test_linker () =
let m1 = make_module "one"
and m2 = make_module "two" in
- link_modules m1 m2 Mode.PreserveSource;
+ link_modules m1 m2;
dispose_module m1;
dispose_module m2;
let m1 = make_module "one"
and m2 = make_module "two" in
- link_modules m1 m2 Mode.DestroySource;
+ link_modules m1 m2;
dispose_module m1;
let m1 = make_module "one"
and m2 = make_module "one" in
try
- link_modules m1 m2 Mode.PreserveSource;
+ link_modules m1 m2;
failwith "must raise"
with Error _ ->
dispose_module m1;
diff --git a/test/Bindings/OCaml/lit.local.cfg b/test/Bindings/OCaml/lit.local.cfg
index bca5d39..7a83ca1 100644
--- a/test/Bindings/OCaml/lit.local.cfg
+++ b/test/Bindings/OCaml/lit.local.cfg
@@ -3,5 +3,5 @@ config.suffixes = ['.ml']
if not 'ocaml' in config.root.llvm_bindings:
config.unsupported = True
-if config.root.have_ocaml_ounit != '1':
+if config.root.have_ocaml_ounit not in ('1', 'TRUE'):
config.unsupported = True
diff --git a/test/Bindings/OCaml/transform_utils.ml b/test/Bindings/OCaml/transform_utils.ml
new file mode 100644
index 0000000..6b46df1
--- /dev/null
+++ b/test/Bindings/OCaml/transform_utils.ml
@@ -0,0 +1,21 @@
+(* RUN: cp %s %T/transform_utils.ml
+ * RUN: %ocamlc -g -warn-error A -package llvm.transform_utils -linkpkg %T/transform_utils.ml -o %t
+ * RUN: %t
+ * RUN: %ocamlopt -g -warn-error A -package llvm.transform_utils -linkpkg %T/transform_utils.ml -o %t
+ * RUN: %t
+ * XFAIL: vg_leak
+ *)
+
+open Llvm
+open Llvm_transform_utils
+
+let context = global_context ()
+
+let test_clone_module () =
+ let m = create_module context "mod" in
+ let m' = clone_module m in
+ if m == m' then failwith "m == m'";
+ if string_of_llmodule m <> string_of_llmodule m' then failwith "string_of m <> m'"
+
+let () =
+ test_clone_module ()
diff --git a/test/Bindings/llvm-c/Inputs/invalid.ll.bc b/test/Bindings/llvm-c/Inputs/invalid.ll.bc
new file mode 100644
index 0000000..a85c364
--- /dev/null
+++ b/test/Bindings/llvm-c/Inputs/invalid.ll.bc
Binary files differ
diff --git a/test/Bindings/llvm-c/add_named_metadata_operand.ll b/test/Bindings/llvm-c/add_named_metadata_operand.ll
new file mode 100644
index 0000000..fcc833d
--- /dev/null
+++ b/test/Bindings/llvm-c/add_named_metadata_operand.ll
@@ -0,0 +1,2 @@
+; RUN: llvm-c-test --add-named-metadata-operand < /dev/null
+; This used to trigger an assertion
diff --git a/test/Bindings/llvm-c/invalid-bitcode.test b/test/Bindings/llvm-c/invalid-bitcode.test
new file mode 100644
index 0000000..6318a9b
--- /dev/null
+++ b/test/Bindings/llvm-c/invalid-bitcode.test
@@ -0,0 +1,3 @@
+; RUN: not llvm-c-test --module-dump < %S/Inputs/invalid.ll.bc 2>&1 | FileCheck %s
+
+CHECK: Error parsing bitcode: Unknown attribute kind (48)
diff --git a/test/Bindings/llvm-c/set_metadata.ll b/test/Bindings/llvm-c/set_metadata.ll
new file mode 100644
index 0000000..0a65b8c
--- /dev/null
+++ b/test/Bindings/llvm-c/set_metadata.ll
@@ -0,0 +1,2 @@
+; RUN: llvm-c-test --set-metadata < /dev/null
+; This used to trigger an assertion