From 02b6630303396fb7d9e61688a1480c64271f065e Mon Sep 17 00:00:00 2001 From: Chris Casinghino Date: Mon, 27 May 2024 13:49:41 +0800 Subject: [PATCH] Add test case for the begin_region / end_region stuff --- .../validate/test-validate/test-mls/generated-rules.inc | 8 ++++++++ .../validate/test-validate/test-mls/region_elim.ml | 9 +++++++++ .../validate/test-validate/test-mls/region_elim.mli | 1 + 3 files changed, 18 insertions(+) create mode 100644 middle_end/flambda2/validate/test-validate/test-mls/region_elim.ml create mode 100644 middle_end/flambda2/validate/test-validate/test-mls/region_elim.mli diff --git a/middle_end/flambda2/validate/test-validate/test-mls/generated-rules.inc b/middle_end/flambda2/validate/test-validate/test-mls/generated-rules.inc index 7392ec76a1b..86f4583baa6 100644 --- a/middle_end/flambda2/validate/test-validate/test-mls/generated-rules.inc +++ b/middle_end/flambda2/validate/test-validate/test-mls/generated-rules.inc @@ -42,3 +42,11 @@ (action (progn (run %{bin:ocamlopt.opt} -c -validate cse.mli cse.ml)))) + +(rule + (alias runtest) + (enabled_if (= %{context_name} "main")) + (deps region_elim.ml region_elim.mli) + (action + (progn + (run %{bin:ocamlopt.opt} -c -validate region_elim.mli region_elim.ml)))) diff --git a/middle_end/flambda2/validate/test-validate/test-mls/region_elim.ml b/middle_end/flambda2/validate/test-validate/test-mls/region_elim.ml new file mode 100644 index 00000000000..2ac8ecad537 --- /dev/null +++ b/middle_end/flambda2/validate/test-validate/test-mls/region_elim.ml @@ -0,0 +1,9 @@ +(* This gets compiled to a program with a begin_region / end_region pair creating a region + that is never allocated in. We had to add a special case for this, as does flambda2. + See [Normalize.remove_corresponding_end_region] and its interactions with the + [Can_delete_if_unused] case of [step_let] (which fires for [Begin_region] *) + +let trim () = + let _ = ref 0 in + () + diff --git a/middle_end/flambda2/validate/test-validate/test-mls/region_elim.mli b/middle_end/flambda2/validate/test-validate/test-mls/region_elim.mli new file mode 100644 index 00000000000..0a1c6682419 --- /dev/null +++ b/middle_end/flambda2/validate/test-validate/test-mls/region_elim.mli @@ -0,0 +1 @@ +val trim : unit -> unit