Skip to content

Commit 00c16c2

Browse files
committed
Merge branch 'master' into generic-spec-lifters
2 parents 9eeff41 + 85aaec9 commit 00c16c2

File tree

5 files changed

+38
-29
lines changed

5 files changed

+38
-29
lines changed

src/cdomain/value/cdomains/int/defExcDomain.ml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,15 @@ struct
299299
let ex = if Z.gt x Z.zero || Z.lt y Z.zero then S.singleton Z.zero else S.empty () in
300300
norm ik @@ (`Excluded (ex, r))
301301

302-
let to_bitfield ik x =
303-
match x with
304-
| `Definite c -> (Z.lognot c, c)
305-
| _ when Cil.isSigned ik ->
306-
let one_mask = Z.lognot Z.zero in
302+
let to_bitfield ik x =
303+
match x with
304+
| `Definite c -> (Z.lognot c, c)
305+
| _ when Cil.isSigned ik ->
306+
let one_mask = Z.lognot Z.zero in
307307
(one_mask, one_mask)
308-
| _ ->
309-
let one_mask = Z.lognot Z.zero in
310-
let ik_mask = snd (Size.range ik) in
308+
| _ ->
309+
let one_mask = Z.lognot Z.zero in
310+
let ik_mask = snd (Size.range ik) in
311311
(one_mask, ik_mask)
312312

313313
let starting ?(suppress_ovwarn=false) ikind x =
@@ -333,12 +333,9 @@ struct
333333
| `Bot -> None
334334

335335
let apply_range f r = (* apply f to the min/max of the old range r to get a new range *)
336-
(* If the Int64 might overflow on us during computation, we instead go to top_range *)
337-
match R.minimal r, R.maximal r with
338-
| _ ->
339-
let rf m = (size % Size.min_for % f) (m r) in
340-
let r1, r2 = rf Exclusion.min_of_range, rf Exclusion.max_of_range in
341-
R.join r1 r2
336+
let rf m = (size % Size.min_for % f) (m r) in
337+
let r1, r2 = rf Exclusion.min_of_range, rf Exclusion.max_of_range in
338+
R.join r1 r2
342339

343340
(* Default behaviour for unary operators, simply maps the function to the
344341
* DefExc data structure. *)
@@ -542,8 +539,8 @@ struct
542539

543540
let refine_with_congruence ik a b = a
544541

545-
let refine_with_bitfield ik x (z,o) =
546-
match BitfieldDomain.Bitfield.to_int (z,o) with
542+
let refine_with_bitfield ik x (z,o) =
543+
match BitfieldDomain.Bitfield.to_int (z,o) with
547544
| Some y ->
548545
meet ik x (`Definite y)
549546
| _ ->

src/common/domains/printable.ml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ sig
2626
(* For hashconsing together with incremental we need to re-hashcons old values.
2727
* For HashconsLifter.D this is done on any lattice operation, so we can replace x with `join bot x` to hashcons it again and get a new tag for it.
2828
* For HashconsLifter.C we call hashcons only in `context` which is in Analyses.Spec but not in Analyses.GlobConstrSys, i.e. not visible to the solver. *)
29-
(* The default for this should be identity, except for HConsed below where we want to have the side-effect and return a value with the updated tag. *)
29+
(* The default for functors should pass the call to their argument modules, except for HConsed below where we want to have the side-effect and return a value with the updated tag. *)
3030
val relift: t -> t
3131
end
3232

@@ -162,39 +162,40 @@ struct
162162
let arbitrary () = QCheck.map ~rev:unlift lift (Base.arbitrary ())
163163
end
164164

165-
module HashCached (M: S) =
165+
module HashCached (Base: S) =
166166
struct
167-
module LazyHash = LazyEval.Make (struct type t = M.t type result = int let eval = M.hash end)
167+
module LazyHash = LazyEval.Make (struct type t = Base.t type result = int let eval = Base.hash end)
168168

169-
let name () = "HashCached " ^ M.name ()
169+
let name () = "HashCached " ^ Base.name ()
170170

171171
type t =
172172
{
173-
m: M.t;
173+
m: Base.t;
174174
lazy_hash: LazyHash.t;
175175
}
176176

177177
let lift m = {m; lazy_hash = LazyHash.make m}
178178
let unlift {m; _} = m
179+
let relift x = lift @@ Base.relift x.m
179180

180181
let lift_f f x = f (unlift x)
181182
let lift_f' f x = lift @@ lift_f f x
182183
let lift_f2 f x y = f (unlift x) (unlift y)
183184
let lift_f2' f x y = lift @@ lift_f2 f x y
184185

185-
let equal = lift_f2 M.equal
186-
let compare = lift_f2 M.compare
186+
let equal = lift_f2 Base.equal
187+
let compare = lift_f2 Base.compare
187188
let hash x = LazyHash.force x.lazy_hash
188-
let show = lift_f M.show
189+
let show = lift_f Base.show
189190

190-
let pretty () = lift_f (M.pretty ())
191+
let pretty () = lift_f (Base.pretty ())
191192

192-
let printXml f = lift_f (M.printXml f)
193-
let to_yojson = lift_f (M.to_yojson)
193+
let printXml f = lift_f (Base.printXml f)
194+
let to_yojson = lift_f (Base.to_yojson)
194195

195-
let arbitrary () = QCheck.map ~rev:unlift lift (M.arbitrary ())
196+
let arbitrary () = QCheck.map ~rev:unlift lift (Base.arbitrary ())
196197

197-
let tag = lift_f M.tag
198+
let tag = lift_f Base.tag
198199
end
199200

200201

src/config/options.schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,13 @@
513513
"type": "boolean",
514514
"default": true
515515
},
516+
"hashcached": {
517+
"title": "ana.opt.hashcached",
518+
"description":
519+
"Should we try to save memory and speed up equality by caching hashes of contexts? This is useful when hashconsing is off",
520+
"type": "boolean",
521+
"default": false
522+
},
516523
"equal": {
517524
"title": "ana.opt.equal",
518525
"description":

src/framework/control.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ let spec_module: (module Spec) Lazy.t = lazy (
2828
|> lift true (module WidenContextLifterSide) (* option checked in functor *)
2929
(* hashcons before witness to reduce duplicates, because witness re-uses contexts in domain and requires tag for PathSensitive3 *)
3030
|> lift (get_bool "ana.opt.hashcons" || arg_enabled) (module HashconsContextLifter)
31+
|> lift (get_bool "ana.opt.hashcached") (module HashCachedContextLifter)
3132
|> lift arg_enabled (module HashconsLifter)
3233
|> lift arg_enabled (module WitnessConstraints.PathSensitive3)
3334
|> lift (not arg_enabled) (module PathSensitive2)

src/lifters/specLifters.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ end
206206
(** Lifts a [Spec] so that the context is [Hashcons]d. *)
207207
module HashconsContextLifter = ContextLifter (Printable.HConsed)
208208

209+
(** Lifts a [Spec] so that the context is [HashCached]. *)
210+
module HashCachedContextLifter = ContextLifter (Printable.HashCached)
211+
209212
(* see option ana.opt.equal *)
210213
module OptEqual (S: Spec) = struct
211214
module D = struct include S.D let equal x y = x == y || equal x y end

0 commit comments

Comments
 (0)