Skip to content

Commit 06e6e03

Browse files
Use pretty_wpoint
Co-authored-by: Simmo Saan <[email protected]>
1 parent 8103ced commit 06e6e03

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/solver/td3.ml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,11 @@ module Base =
281281
let destabilize_ref: (S.v -> unit) ref = ref (fun _ -> failwith "no destabilize yet") in
282282
let destabilize x = !destabilize_ref x in (* must be eta-expanded to use changed destabilize_ref *)
283283

284-
let format_wpoint x = Option.map_default (fun x -> Printf.sprintf "true (gas: %d)" x) "false" (HM.find_option wpoint_gas x) in
284+
let pretty_wpoint () x =
285+
match HM.find_option wpoint_gas x with
286+
| None -> Pretty.text "false"
287+
| Some x -> Pretty.dprintf "true (gas: %d)" x
288+
in
285289
let mark_wpoint x default_gas =
286290
if not (HM.mem wpoint_gas x) then (HM.replace wpoint_gas x default_gas) in
287291
let reduce_gas x =
@@ -312,7 +316,7 @@ module Base =
312316
true
313317
) w false (* nosemgrep: fold-exists *) (* does side effects *)
314318
and solve ?reuse_eq x phase =
315-
if tracing then trace "sol2" "solve %a, phase: %s, called: %b, stable: %b, wpoint: %s" S.Var.pretty_trace x (show_phase phase) (HM.mem called x) (HM.mem stable x) (format_wpoint x);
319+
if tracing then trace "sol2" "solve %a, phase: %s, called: %b, stable: %b, wpoint: %a" S.Var.pretty_trace x (show_phase phase) (HM.mem called x) (HM.mem stable x) pretty_wpoint x;
316320
init x;
317321
assert (Hooks.system x <> None);
318322
if not (HM.mem called x || HM.mem stable x) then (
@@ -367,7 +371,7 @@ module Base =
367371
if not (Timing.wrap "S.Dom.equal" (fun () -> S.Dom.equal old wpd) ()) then ( (* value changed *)
368372
if tracing then trace "sol" "Changed";
369373
(* if tracing && not (S.Dom.is_bot old) && wp then trace "solchange" "%a (wpx: %s): %a -> %a" S.Var.pretty_trace x (format_wpoint x) S.Dom.pretty old S.Dom.pretty wpd; *)
370-
if tracing && not (S.Dom.is_bot old) && wp then trace "solchange" "%a (wpx: %s): %a" S.Var.pretty_trace x (format_wpoint x) S.Dom.pretty_diff (wpd, old);
374+
if tracing && not (S.Dom.is_bot old) && wp then trace "solchange" "%a (wpx: %a): %a" S.Var.pretty_trace x pretty_wpoint x S.Dom.pretty_diff (wpd, old);
371375
update_var_event x old wpd;
372376
HM.replace rho x wpd;
373377
destabilize x;
@@ -386,7 +390,7 @@ module Base =
386390
Hooks.stable_remove x;
387391
(solve[@tailcall]) ~reuse_eq:eqd x Narrow
388392
) else if remove_wpoint && not space && (not term || phase = Narrow) then ( (* this makes e.g. nested loops precise, ex. tests/regression/34-localization/01-nested.c - if we do not remove wpoint, the inner loop head will stay a wpoint and widen the outer loop variable. *)
389-
if tracing then trace "sol2" "solve removing wpoint %a (%s)" S.Var.pretty_trace x (format_wpoint x);
393+
if tracing then trace "sol2" "solve removing wpoint %a (%a)" S.Var.pretty_trace x pretty_wpoint x;
390394
HM.remove wpoint_gas x;
391395
)
392396
)
@@ -435,7 +439,7 @@ module Base =
435439
if tracing then trace "sol2" "eval %a ## %a -> %a" S.Var.pretty_trace x S.Var.pretty_trace y S.Dom.pretty tmp;
436440
tmp
437441
and side ?x y d = (* side from x to y; only to variables y w/o rhs; x only used for trace *)
438-
if tracing then trace "sol2" "side to %a (wpx: %s) from %a ## value: %a" S.Var.pretty_trace y (format_wpoint y) (Pretty.docOpt (S.Var.pretty_trace ())) x S.Dom.pretty d;
442+
if tracing then trace "sol2" "side to %a (wpx: %a) from %a ## value: %a" S.Var.pretty_trace y pretty_wpoint y (Pretty.docOpt (S.Var.pretty_trace ())) x S.Dom.pretty d;
439443
if Hooks.system y <> None then (
440444
Logs.warn "side-effect to unknown w/ rhs: %a, contrib: %a" S.Var.pretty_trace y S.Dom.pretty d;
441445
);
@@ -460,8 +464,8 @@ module Base =
460464
if tracing then trace "sol2" "stable add %a" S.Var.pretty_trace y;
461465
HM.replace stable y ();
462466
if not (S.Dom.leq tmp old) then (
463-
if tracing && not (S.Dom.is_bot old) then trace "solside" "side to %a (wpx: %s) from %a: %a -> %a" S.Var.pretty_trace y (format_wpoint y) (Pretty.docOpt (S.Var.pretty_trace ())) x S.Dom.pretty old S.Dom.pretty tmp;
464-
if tracing && not (S.Dom.is_bot old) then trace "solchange" "side to %a (wpx: %s) from %a: %a" S.Var.pretty_trace y (format_wpoint y) (Pretty.docOpt (S.Var.pretty_trace ())) x S.Dom.pretty_diff (tmp, old);
467+
if tracing && not (S.Dom.is_bot old) then trace "solside" "side to %a (wpx: %a) from %a: %a -> %a" S.Var.pretty_trace y pretty_wpoint y (Pretty.docOpt (S.Var.pretty_trace ())) x S.Dom.pretty old S.Dom.pretty tmp;
468+
if tracing && not (S.Dom.is_bot old) then trace "solchange" "side to %a (wpx: %a) from %a: %a" S.Var.pretty_trace y pretty_wpoint y (Pretty.docOpt (S.Var.pretty_trace ())) x S.Dom.pretty_diff (tmp, old);
465469

466470
(match x with
467471
| Some x ->

0 commit comments

Comments
 (0)