Skip to content

Commit 4b1c337

Browse files
committed
[bindings][test] Add test for global_set_metadata
1 parent 2d4484f commit 4b1c337

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

llvm/test/Bindings/OCaml/core.ml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,19 @@ let test_global_values () =
434434
group "dll_storage_class";
435435
let g = define_global "GVal06" zero32 m ++
436436
set_dll_storage_class DLLStorageClass.DLLExport in
437-
insist (DLLStorageClass.DLLExport = dll_storage_class g)
437+
insist (DLLStorageClass.DLLExport = dll_storage_class g);
438438

439+
(* CHECK: GVal07{{.*}}!test !{{.*}}
440+
* See metadata check at the end of the file.
441+
*)
442+
group "metdata";
443+
let g = define_global "GVal07" zero32 m in
444+
let md_string = mdstring context "global test metadata" in
445+
let md_node = mdnode context [| zero32; md_string |] |> value_as_metadata in
446+
let mdkind_test = mdkind_id context "test" in
447+
global_set_metadata g mdkind_test md_node;
448+
let md' = global_copy_all_metadata g in
449+
insist (md' = [| mdkind_test, md_node |])
439450

440451
(*===-- Global Variables --------------------------------------------------===*)
441452

@@ -1115,8 +1126,9 @@ let test_builder () =
11151126
end;
11161127

11171128
group "metadata"; begin
1118-
(* CHECK: %metadata = add i32 %P1, %P2, !test !1
1119-
* !1 is metadata emitted at EOF.
1129+
(* CHECK: %metadata = add i32 %P1, %P2, !test !{{[0-9]+}}
1130+
* Number of metadata nodes is not predictable, so we just check for
1131+
* the presence of metadata here
11201132
*)
11211133
let i = build_add p1 p2 "metadata" atentry in
11221134
insist ((has_metadata i) = false);
@@ -1432,9 +1444,10 @@ let test_builder () =
14321444
end
14331445

14341446
(* End-of-file checks for things like metdata and attributes.
1435-
* CHECK: !llvm.module.flags = !{!0}
1436-
* CHECK: !0 = !{i32 1, !"Debug Info Version", i32 3}
1437-
* CHECK: !1 = !{i32 1, !"metadata test"}
1447+
* CHECK: !llvm.module.flags = !{!{{[0-9]+}}}
1448+
* CHECK: !{{[0-9]+}} = !{i32 0, !"global test metadata"}
1449+
* CHECK: !{{[0-9]+}} = !{i32 1, !"Debug Info Version", i32 3}
1450+
* CHECK: !{{[0-9]+}} = !{i32 1, !"metadata test"}
14381451
*)
14391452

14401453

0 commit comments

Comments
 (0)