Skip to content

Commit

Permalink
improves reification of calls in the IR theory (BinaryAnalysisPlatfor…
Browse files Browse the repository at this point in the history
…m#1378)

* fixes the IR theory implementation

The seq function was incorrectly dropping blocks because the is_empty
predicate was not updated in BinaryAnalysisPlatform#1326 when subinstructions were
introduced and the null label started to be used everywhere.

* improves reification of calls in the IR theory

It looks like that the IR theory could be more clever and reify
`seq (call <fun>) <rest>` into
```
call <fun> return @next
...
next:
<rest>
```
  • Loading branch information
ivg authored Dec 2, 2021
1 parent 3b08a65 commit 71076d4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion plugins/bil/bil_ir.ml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,15 @@ module IR = struct
blks = [blk ~keep:false entry ++ Jmp.reify ~tid ~dst:(Jmp.indirect dst) ()]
}

let is_call jmp = Option.is_some (Jmp.alt jmp)

let fall ~tid x dst = match x.jmps with
| [jmp] when is_call jmp -> {
x with jmps = [
Jmp.with_dst jmp (Some (Jmp.resolved dst))
]}
| jmps -> {x with jmps = goto ~tid dst :: jmps}

let appgraphs fst snd =
if is_empty fst then ret snd else
if is_empty snd then ret fst
Expand All @@ -318,7 +327,7 @@ module IR = struct
entry;
blks =
y ::
x ++ goto ~tid esnd ::
fall ~tid x esnd ::
List.rev_append xs ys
}

Expand Down

0 comments on commit 71076d4

Please sign in to comment.