From ec75b2fc929fecaa2371e7aee51e6a6d5ec25b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Tue, 11 Jun 2019 03:22:22 +0200 Subject: [PATCH] Fix tail call synthesis --- DwarfSynth/Simplest.ml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/DwarfSynth/Simplest.ml b/DwarfSynth/Simplest.ml index 138f8d4..82c63e8 100644 --- a/DwarfSynth/Simplest.ml +++ b/DwarfSynth/Simplest.ml @@ -524,7 +524,13 @@ let process_jmp jmp (cur_reg: reg_pos) in match (BStd.Jmp.kind jmp) with - | BStd.Call call -> gen_change (-8) + | BStd.Call call -> ( + (* If this call never returns (tail call), do not generate an offset of + -8. *) + match BStd.Call.return call with + | Some _ -> gen_change (-8) + | None -> None + ) | BStd.Ret ret -> gen_change (8) | _ -> None