From 4811d682131d018ba5e682a604f80d454c0625c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Fri, 5 Jul 2019 17:17:43 +0200 Subject: [PATCH] synth: tolerate rbp def/undef merges (one way only) The easy way of RBP defined vs. undefined merge is implemented (if a block is defined with RBP undef, we tolerate merging upon it with a defined RBP by losing this information). --- DwarfSynth/Simplest.ml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/DwarfSynth/Simplest.ml b/DwarfSynth/Simplest.ml index b88635e..d7309f6 100644 --- a/DwarfSynth/Simplest.ml +++ b/DwarfSynth/Simplest.ml @@ -746,6 +746,18 @@ let process_sub sub next_instr_graph : subroutine_cfa_data = let entry_blk = get_entry_blk cfg (first_bap_addr) in let rbp_pop_set = find_rbp_pop_set cfg entry_blk in + let valid_merge previous_regs cur_regs = + let valid_rbp_merge old cur = + (old = cur) || (match old, cur with + | RbpUndef, RbpCfaOffset _ -> true + | _ -> false) + in + + let prev_cfa, prev_rbp = previous_regs in + let cur_cfa, cur_rbp = cur_regs in + (prev_cfa = cur_cfa) && valid_rbp_merge prev_rbp cur_rbp + in + let rec dfs_process allow_rbp (sub_changes: (reg_changes_fde * reg_pos) TIdMap.t) @@ -775,7 +787,7 @@ let process_sub sub next_instr_graph : subroutine_cfa_data = ~init:n_sub_changes | Some (_, former_entry_offset) -> (* Already visited: check that entry values are matching *) - if entry_offset <> former_entry_offset then ( + if not @@ valid_merge former_entry_offset entry_offset then ( if allow_rbp then Format.eprintf "Found inconsistency (0x%Lx <%a>): %a -- %a@." (int64_addr_of cur_blk)