From 203211090f9e67750a0f953d6dbefe5045271921 Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Sun, 30 Aug 2020 10:31:02 +0200 Subject: Restore discard_dead_code and use it to simplify match-with constructs. Otherwise, these constructs would be followed by a spurious Kreturn opcode, when in tail position. --- kernel/vmbytegen.ml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'kernel') diff --git a/kernel/vmbytegen.ml b/kernel/vmbytegen.ml index 6899ebe1a6..489929d2be 100644 --- a/kernel/vmbytegen.ml +++ b/kernel/vmbytegen.ml @@ -315,12 +315,10 @@ let pos_evar evk r = (* non-terminating instruction (branch, raise, return, appterm) *) (* in front of it. *) -let discard_dead_code cont = cont -(*function - [] -> [] +let rec discard_dead_code = function + | [] -> [] | (Klabel _ | Krestart ) :: _ as cont -> cont | _ :: cont -> discard_dead_code cont -*) (* Return a label to the beginning of the given continuation. *) (* If the sequence starts with a branch, use the target of that branch *) @@ -700,6 +698,7 @@ let rec compile_lam env cenv lam sz cont = | _ -> assert false in + let cont = discard_dead_code cont in let c = ref cont in (* Perform the extra match if needed (too many block constructors) *) if neblock <> 0 then begin -- cgit v1.2.3