From 705443ffd3f67018c1ec387014262566502a9ee3 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Tue, 2 Mar 2010 20:32:32 +0000 Subject: Add support for use to ocaml. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97586 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Bindings/Ocaml/vmcore.ml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/Bindings') diff --git a/test/Bindings/Ocaml/vmcore.ml b/test/Bindings/Ocaml/vmcore.ml index cbd52e46bb..d87e162b9c 100644 --- a/test/Bindings/Ocaml/vmcore.ml +++ b/test/Bindings/Ocaml/vmcore.ml @@ -607,6 +607,33 @@ let test_global_variables () = end +(*===-- Uses --------------------------------------------------------------===*) + +let test_uses () = + let ty = function_type i32_type [| i32_type; i32_type |] in + let fn = define_function "use_function" ty m in + let b = builder_at_end context (entry_block fn) in + + let p1 = param fn 0 in + let p2 = param fn 1 in + let v1 = build_add p1 p2 "v1" b in + let v2 = build_add p1 v1 "v2" b in + let _ = build_add v1 v2 "v3" b in + + let lf s u = value_name (user u) ^ "->" ^ s in + insist ("v2->v3->" = fold_left_uses lf "" v1); + let rf u s = value_name (user u) ^ "<-" ^ s in + insist ("v3<-v2<-" = fold_right_uses rf v1 ""); + + let lf s u = value_name (used_value u) ^ "->" ^ s in + insist ("v1->v1->" = fold_left_uses lf "" v1); + + let rf u s = value_name (used_value u) ^ "<-" ^ s in + insist ("v1<-v1<-" = fold_right_uses rf v1 ""); + + ignore (build_unreachable b) + + (*===-- Users -------------------------------------------------------------===*) let test_users () = @@ -1291,6 +1318,7 @@ let _ = suite "constants" test_constants; suite "global values" test_global_values; suite "global variables" test_global_variables; + suite "uses" test_uses; suite "users" test_users; suite "aliases" test_aliases; suite "functions" test_functions; -- cgit v1.2.3-18-g5258