From b7a5caf87fc35a09d5e8cbab41d4ee57c9f52d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Thu, 15 Nov 2018 17:23:20 +0100 Subject: [PATCH] Simplify evaluation of affine rsp setting expr --- DwarfSynth/Simplest.ml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/DwarfSynth/Simplest.ml b/DwarfSynth/Simplest.ml index 0eb651b..34882f6 100644 --- a/DwarfSynth/Simplest.ml +++ b/DwarfSynth/Simplest.ml @@ -163,13 +163,13 @@ let build_next_instr graph = let interpret_var_expr c_var offset expr = BStd.Bil.( let closed_form = BStd.Exp.substitute (var c_var) - (int (BStd.Word.of_int64 offset)) + (int (BStd.Word.of_int64 (Int64.neg offset))) expr in let res = BStd.Exp.eval closed_form in match res with | Imm value -> - Some (BStd.Word.to_int64_exn @@ BStd.Word.signed value) + Some (Int64.neg @@ BStd.Word.to_int64_exn @@ BStd.Word.signed value) | _ -> None ) @@ -192,9 +192,7 @@ let process_def def (cur_offset: memory_offset) let interpreted = interpret_var_expr bil_var cur_offset exp in (match interpreted with | None -> lose_track - | Some interp_val -> - let gap = Int64.sub interp_val cur_offset in - let new_offset = Int64.sub cur_offset gap in + | Some new_offset -> Some (RspOffset(new_offset), new_offset) ) | _ -> lose_track