[sledge] Strengthen byte-array solver with derived length constraints

Summary: Treat Memory as a length-one Concat.

Reviewed By: ngorogiannis

Differential Revision: D14413027

fbshipit-source-id: 6cd6f287c
master
Josh Berdine 6 years ago committed by Facebook Github Bot
parent 1884994cc0
commit 0a97615da2

@ -1304,6 +1304,13 @@ let solve e f =
let key, data = if ord > 0 then (e, f) else (f, e) in let key, data = if ord > 0 then (e, f) else (f, e) in
Some (Map.add_exn s ~key ~data) Some (Map.add_exn s ~key ~data)
in in
let concat_size args =
Vector.fold_until args ~init:(integer Z.zero Typ.siz)
~f:(fun sum -> function
| Memory {siz} -> Continue (add Typ.siz siz sum) | _ -> Stop None
)
~finish:(fun _ -> None)
in
match (e, f) with match (e, f) with
| (Add {typ} | Mul {typ} | Integer {typ}), _ | (Add {typ} | Mul {typ} | Integer {typ}), _
|_, (Add {typ} | Mul {typ} | Integer {typ}) -> ( |_, (Add {typ} | Mul {typ} | Integer {typ}) -> (
@ -1316,16 +1323,14 @@ let solve e f =
Some (Map.add_exn s ~key:c ~data:r) Some (Map.add_exn s ~key:c ~data:r)
| e_f -> solve_uninterp e_f (integer Z.zero typ) ) | e_f -> solve_uninterp e_f (integer Z.zero typ) )
| Concat {args= ms}, Concat {args= ns} -> ( | Concat {args= ms}, Concat {args= ns} -> (
let siz args = match (concat_size ms, concat_size ns) with
Vector.fold_until args ~init:(integer Z.zero Typ.siz) | Some p, Some q -> solve_uninterp e f >>= solve_ p q
~f:(fun sum -> function | _ -> solve_uninterp e f )
| Memory {siz} -> Continue (add Typ.siz siz sum) | Memory {siz= m}, Concat {args= ns} | Concat {args= ns}, Memory {siz= m}
| _ -> Stop None ) -> (
~finish:(fun _ -> None) match concat_size ns with
in | Some p -> solve_uninterp e f >>= solve_ p m
match (siz ms, siz ns) with | _ -> solve_uninterp e f )
| Some p, Some q -> solve_uninterp e f >>= solve_ p q
| _ -> solve_uninterp e f )
| _ -> solve_uninterp e f | _ -> solve_uninterp e f
in in
solve_ e f empty_map solve_ e f empty_map

Loading…
Cancel
Save