1 (* RUN: %ocamlc -warn-error A llvm.cma llvm_scalar_opts.cma llvm_target.cma %s -o %t 2> /dev/null
4 (* Note: It takes several seconds for ocamlc to link an executable with
5 libLLVMCore.a, so it's better to write a big test than a bunch of
13 (* Tiny unit test framework - really just to help find which line is busted *)
15 prerr_endline
(name ^
":");
19 (*===-- Fixture -----------------------------------------------------------===*)
21 let filename = Sys.argv
.(1)
22 let m = create_module
filename
23 let mp = ModuleProvider.create
m
26 (*===-- Transforms --------------------------------------------------------===*)
28 let test_transforms () =
29 let (++) x f
= ignore
(f x
); x
in
31 let fty = function_type void_type
[| |] in
32 let fn = define_function
"fn" fty m in
33 ignore
(build_ret_void
(builder_at_end
(entry_block
fn)));
35 let td = TargetData.create
(target_triple
m) in
37 ignore
(PassManager.create_function
mp
39 ++ add_instruction_combining
42 ++ add_cfg_simplification
43 ++ add_constant_propagation
44 ++ PassManager.initialize
45 ++ PassManager.run_function
fn
46 ++ PassManager.finalize
47 ++ PassManager.dispose
);
52 (*===-- Driver ------------------------------------------------------------===*)
55 suite "transforms" test_transforms;
56 ModuleProvider.dispose
mp