From 30fe23b5415e57e227df511771ffcd7c068722fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Tue, 2 Apr 2019 18:36:34 +0200 Subject: [PATCH] Fix rbp to rsp switch Use rsp+16, because we'll pop the saved rbp from the stack just after --- DwarfSynth/Simplest.ml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/DwarfSynth/Simplest.ml b/DwarfSynth/Simplest.ml index 9ce1573..b723ec8 100644 --- a/DwarfSynth/Simplest.ml +++ b/DwarfSynth/Simplest.ml @@ -255,10 +255,13 @@ let process_def (local_state: block_local_state) def (cur_reg: reg_pos) (* Assume we are overwriting %rbp with something — we must revert to some rsp-based indexing *) (* FIXME don't assume the rsp offset will always be 8, find a smart way - to figure this out *) - Some (RspOffset(Int64.of_int 8)) - | _ -> None) - in + to figure this out. + We actually use offset 16 because the `pop` will occur after the + value is read from the stack. + *) + Some (RspOffset(Int64.of_int 16)) + | _ -> None + ) in let is_rbp_save_expr expr local_state = let free_vars = BStd.Exp.free_vars expr in