Skip to content

Commit 7437e0b

Browse files
committed
Meet test
1 parent ded368e commit 7437e0b

File tree

1 file changed

+60
-6
lines changed

1 file changed

+60
-6
lines changed

middle_end/flambda/tests/meet_test.ml

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,69 @@ let meet_variants_don't_lose_aliases () =
143143
T.print tag_meet_ty
144144
TEE.print tag_meet_env_extension
145145

146+
let test_meet_two_blocks () =
147+
let define env v =
148+
let v' = Var_in_binding_pos.create v Name_mode.normal in
149+
TE.add_definition env (Name_in_binding_pos.var v') K.value
150+
in
151+
let defines env l = List.fold_left define env l in
152+
let env = TE.create ~resolver ~get_imported_names in
153+
let block1 = Variable.create "block1" in
154+
let field1 = Variable.create "field1" in
155+
let block2 = Variable.create "block2" in
156+
let field2 = Variable.create "field2" in
157+
let env = defines env [block1; block2; field1; field2] in
158+
159+
let env =
160+
TE.add_equation env (Name.var block1)
161+
(T.immutable_block ~is_unique:false Tag.zero ~field_kind:K.value
162+
~fields:[T.alias_type_of K.value (Simple.var field1)])
163+
in
164+
let env =
165+
TE.add_equation env (Name.var block2)
166+
(T.immutable_block ~is_unique:false Tag.zero ~field_kind:K.value
167+
~fields:[T.alias_type_of K.value (Simple.var field2)])
168+
in
169+
(* let test b1 b2 env =
170+
* let eq_block2 = T.alias_type_of K.value (Simple.var b2) in
171+
* let env =
172+
* TE.add_equation env (Name.var b1) eq_block2
173+
* in
174+
* Format.eprintf "Res:@ %a@.@."
175+
* TE.print env
176+
* in
177+
* test block1 block2 env;
178+
* test block2 block1 env; *)
179+
180+
let f b1 b2 =
181+
match
182+
T.meet env
183+
(T.alias_type_of K.value (Simple.var b1))
184+
(T.alias_type_of K.value (Simple.var b2))
185+
with
186+
| Bottom -> assert false
187+
| Ok (t, tee) ->
188+
Format.eprintf "Res:@ %a@.%a@."
189+
T.print t
190+
TEE.print tee;
191+
let env = TE.add_env_extension env tee in
192+
Format.eprintf "Env:@.%a@.@."
193+
TE.print env
194+
in
195+
f block1 block2;
196+
f block2 block1
197+
146198
let () =
147199
let comp_unit =
148200
Compilation_unit.create (Ident.create_persistent "Meet_test")
149201
(Linkage_name.create "meet_test")
150202
in
151203
Compilation_unit.set_current comp_unit;
152-
Format.eprintf "MEET CHAINS WITH TWO VARS\n\n%!";
153-
test_meet_chains_two_vars ();
154-
Format.eprintf "\nMEET CHAINS WITH THREE VARS\n\n%!";
155-
test_meet_chains_three_vars ();
156-
Format.eprintf "@.MEET VARIANT@.@.";
157-
meet_variants_don't_lose_aliases ()
204+
(* Format.eprintf "MEET CHAINS WITH TWO VARS\n\n%!";
205+
* test_meet_chains_two_vars ();
206+
* Format.eprintf "\nMEET CHAINS WITH THREE VARS\n\n%!";
207+
* test_meet_chains_three_vars ();
208+
* Format.eprintf "@.MEET VARIANT@.@.";
209+
* meet_variants_don't_lose_aliases (); *)
210+
Format.eprintf "@.Test bug ?@.";
211+
test_meet_two_blocks ()

0 commit comments

Comments
 (0)