Skip to content

Commit 4ec572b

Browse files
committed
Add option incremental.restart.sided.vars
This simplifies the should_restart logic and makes the combination of both "only" options unrepresentable.
1 parent 7aa89e9 commit 4ec572b

File tree

4 files changed

+22
-21
lines changed

4 files changed

+22
-21
lines changed

src/solvers/td3.ml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ module WP =
103103
let side_dep = data.side_dep in
104104
let side_infl = data.side_infl in
105105
let restart_sided = GobConfig.get_bool "incremental.restart.sided.enabled" in
106-
let restart_only_globals = GobConfig.get_bool "incremental.restart.sided.only-global" in
107-
let restart_only_access = GobConfig.get_bool "incremental.restart.sided.only-access" in
106+
let restart_vars = GobConfig.get_string "incremental.restart.sided.vars" in
108107

109108
let restart_wpoint = GobConfig.get_bool "solvers.td3.restart.wpoint.enabled" in
110109
let restart_once = GobConfig.get_bool "solvers.td3.restart.wpoint.once" in
@@ -391,10 +390,14 @@ module WP =
391390
HM.remove side_dep x;
392391

393392
let should_restart =
394-
if restart_only_access then
395-
S.Var.is_write_only x
396-
else
397-
(not restart_only_globals || Node.equal (S.Var.node x) (Function Cil.dummyFunDec)) && (not (S.Var.is_write_only x) || not restart_write_only)
393+
match restart_write_only, S.Var.is_write_only x with
394+
| true, true -> false (* prefer efficient write-only restarting during postsolving *)
395+
| _, is_write_only ->
396+
match restart_vars with
397+
| "all" -> true
398+
| "global" -> Node.equal (S.Var.node x) (Function Cil.dummyFunDec) (* non-function entry node *)
399+
| "write-only" -> is_write_only
400+
| _ -> assert false
398401
in
399402

400403
if not (VS.is_empty w) && should_restart then (
@@ -634,10 +637,13 @@ module WP =
634637
destabilize x
635638
in
636639

640+
let should_restart_start = restart_sided && restart_vars <> "write-only" in (* assuming start vars are not write-only *)
641+
(* TODO: should this distinguish non-global (function entry) and global (earlyglobs) start vars? *)
642+
637643
(* Call side on all globals and functions in the start variables to make sure that changes in the initializers are propagated.
638644
* This also destabilizes start functions if their start state changes because of globals that are neither in the start variables nor in the contexts *)
639645
List.iter (fun (v,d) ->
640-
if restart_sided && not restart_only_access then (
646+
if should_restart_start then (
641647
match GobList.assoc_eq_opt S.Var.equal v data.st with
642648
| Some old_d when not (S.Dom.equal old_d d) ->
643649
ignore (Pretty.printf "Destabilizing and restarting changed start var %a\n" S.Var.pretty_trace v);
@@ -651,7 +657,7 @@ module WP =
651657
side v d
652658
) st;
653659

654-
if restart_sided && not restart_only_access then (
660+
if should_restart_start then (
655661
List.iter (fun (v, _) ->
656662
match GobList.assoc_eq_opt S.Var.equal v st with
657663
| None ->

src/util/options.schema.json

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,17 +1007,12 @@
10071007
"type": "boolean",
10081008
"default": false
10091009
},
1010-
"only-global": {
1011-
"title": "incremental.restart.sided.only-global",
1012-
"description": "Restart only constraint system globals (not function entry nodes).",
1013-
"type": "boolean",
1014-
"default": false
1015-
},
1016-
"only-access" : {
1017-
"title" : "incremental.restart.sided.only-access",
1018-
"description" : "Restart only write-only variables.",
1019-
"type" : "boolean",
1020-
"default" : false
1010+
"vars": {
1011+
"title": "incremental.restart.sided.vars",
1012+
"description": "Side-effected variables to restart. Globals are non-function entry nodes. Write-only is a subset of globals.",
1013+
"type": "string",
1014+
"enum": ["all", "global", "write-only"],
1015+
"default": "all"
10211016
},
10221017
"fuel": {
10231018
"title": "incremental.restart.sided.fuel",

tests/incremental/11-restart/12-mutex-simple-access.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"restart": {
44
"sided": {
55
"enabled": true,
6-
"only-access": true,
6+
"vars": "write-only",
77
"fuel": 1
88
},
99
"write-only": false

tests/incremental/11-restart/13-changed_start_state2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"restart": {
1111
"sided": {
1212
"enabled": true,
13-
"only-access": true
13+
"vars": "write-only"
1414
}
1515
}
1616
}

0 commit comments

Comments
 (0)