Skip to content

Commit 2c25848

Browse files
committed
Remove support for old ghost_variable and ghost_update entry types
1 parent 554bd7f commit 2c25848

6 files changed

Lines changed: 4 additions & 157 deletions

File tree

src/analyses/mutexGhosts.ml

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -122,54 +122,6 @@ struct
122122
| YamlEntryGlobal (g, task) ->
123123
let g: V.t = Obj.obj g in
124124
begin match g with
125-
| `Left g' when YamlWitness.entry_type_enabled YamlWitnessType.GhostVariable.entry_type && YamlWitness.entry_type_enabled YamlWitnessType.GhostUpdate.entry_type ->
126-
let (locked, unlocked, multithread) = G.node (ctx.global g) in
127-
let g = g' in
128-
let entries =
129-
(* TODO: do variable_entry-s only once *)
130-
Locked.fold (fun l acc ->
131-
match mustlock_of_addr l with
132-
| Some l when ghost_var_available ctx (Locked l) ->
133-
let entry = WitnessGhost.variable_entry ~task (Locked l) in
134-
Queries.YS.add entry acc
135-
| _ ->
136-
acc
137-
) (Locked.union locked unlocked) (Queries.YS.empty ())
138-
in
139-
let entries =
140-
Locked.fold (fun l acc ->
141-
match mustlock_of_addr l with
142-
| Some l when ghost_var_available ctx (Locked l) ->
143-
let entry = WitnessGhost.update_entry ~task ~node:g (Locked l) GoblintCil.one in
144-
Queries.YS.add entry acc
145-
| _ ->
146-
acc
147-
) locked entries
148-
in
149-
let entries =
150-
Unlocked.fold (fun l acc ->
151-
match mustlock_of_addr l with
152-
| Some l when ghost_var_available ctx (Locked l) ->
153-
let entry = WitnessGhost.update_entry ~task ~node:g (Locked l) GoblintCil.zero in
154-
Queries.YS.add entry acc
155-
| _ ->
156-
acc
157-
) unlocked entries
158-
in
159-
let entries =
160-
if not (GobConfig.get_bool "exp.earlyglobs") && multithread then (
161-
if ghost_var_available ctx Multithreaded then (
162-
let entry = WitnessGhost.variable_entry ~task Multithreaded in
163-
let entry' = WitnessGhost.update_entry ~task ~node:g Multithreaded GoblintCil.one in
164-
Queries.YS.add entry (Queries.YS.add entry' entries)
165-
)
166-
else
167-
entries
168-
)
169-
else
170-
entries
171-
in
172-
entries
173125
| `Right true when YamlWitness.entry_type_enabled YamlWitnessType.GhostInstrumentation.entry_type ->
174126
let nodes = G.update (ctx.global g) in
175127
let (variables, location_updates) = NodeSet.fold (fun node (variables, location_updates) ->

src/config/options.schema.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,8 +2673,6 @@
26732673
"precondition_loop_invariant_certificate",
26742674
"invariant_set",
26752675
"violation_sequence",
2676-
"ghost_variable",
2677-
"ghost_update",
26782676
"ghost_instrumentation"
26792677
]
26802678
},

src/witness/witnessGhost.ml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(** Ghost variables for YAML witnesses. *)
22

33
let enabled () =
4-
(YamlWitness.entry_type_enabled YamlWitnessType.GhostVariable.entry_type && YamlWitness.entry_type_enabled YamlWitnessType.GhostUpdate.entry_type) || YamlWitness.entry_type_enabled YamlWitnessType.GhostInstrumentation.entry_type
4+
YamlWitness.entry_type_enabled YamlWitnessType.GhostInstrumentation.entry_type
55

66
module Var = WitnessGhostVar
77

@@ -11,20 +11,6 @@ module Map = RichVarinfo.BiVarinfoMap.Make (Var)
1111

1212
include Map
1313

14-
let variable_entry ~task x =
15-
let variable = name_varinfo x in
16-
let type_ = String.trim (CilType.Typ.show (typ x)) in (* CIL printer puts space at the end of some types *)
17-
let initial = CilType.Exp.show (initial x) in
18-
YamlWitness.Entry.ghost_variable ~task ~variable ~type_ ~initial
19-
20-
let update_entry ~task ~node x e =
21-
let loc = Node.location node in
22-
let location_function = (Node.find_fundec node).svar.vname in
23-
let location = YamlWitness.Entry.location ~location:loc ~location_function in
24-
let variable = name_varinfo x in
25-
let expression = CilType.Exp.show e in
26-
YamlWitness.Entry.ghost_update ~task ~location ~variable ~expression
27-
2814
let variable' x =
2915
let variable = name_varinfo x in
3016
let type_ = String.trim (CilType.Typ.show (typ x)) in (* CIL printer puts space at the end of some types *)

src/witness/yamlWitness.ml

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -149,25 +149,6 @@ struct
149149
metadata = metadata ();
150150
}
151151

152-
let ghost_variable ~task ~variable ~type_ ~(initial): Entry.t = {
153-
entry_type = GhostVariable {
154-
variable;
155-
scope = "global";
156-
type_;
157-
initial;
158-
};
159-
metadata = metadata ~task ();
160-
}
161-
162-
let ghost_update ~task ~location ~variable ~(expression): Entry.t = {
163-
entry_type = GhostUpdate {
164-
variable;
165-
expression;
166-
location;
167-
};
168-
metadata = metadata ~task ();
169-
}
170-
171152
let ghost_variable' ~variable ~type_ ~(initial): GhostInstrumentation.Variable.t = {
172153
name = variable;
173154
scope = "global";
@@ -410,9 +391,10 @@ struct
410391
entries
411392
in
412393

413-
(* Generate flow-insensitive entries (ghost variables and ghost updates) *)
394+
(* Generate flow-insensitive entries (ghost instrumentation) *)
414395
let entries =
415-
if (entry_type_enabled YamlWitnessType.GhostVariable.entry_type && entry_type_enabled YamlWitnessType.GhostUpdate.entry_type) || entry_type_enabled YamlWitnessType.GhostInstrumentation.entry_type then (
396+
if entry_type_enabled YamlWitnessType.GhostInstrumentation.entry_type then (
397+
(* TODO: only at most one ghost_instrumentation entry can ever be produced, so this fold and deduplication is overkill *)
416398
let module EntrySet = Queries.YS in
417399
fst @@ GHT.fold (fun g v accs ->
418400
match g with

src/witness/yamlWitnessType.ml

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -644,61 +644,6 @@ struct
644644
{content}
645645
end
646646

647-
module GhostVariable =
648-
struct
649-
type t = {
650-
variable: string;
651-
scope: string;
652-
type_: string;
653-
initial: string;
654-
}
655-
[@@deriving eq, ord, hash]
656-
657-
let entry_type = "ghost_variable"
658-
659-
let to_yaml' {variable; scope; type_; initial} =
660-
[
661-
("variable", `String variable);
662-
("scope", `String scope);
663-
("type", `String type_);
664-
("initial", `String initial);
665-
]
666-
667-
let of_yaml y =
668-
let open GobYaml in
669-
let+ variable = y |> find "variable" >>= to_string
670-
and+ scope = y |> find "scope" >>= to_string
671-
and+ type_ = y |> find "type" >>= to_string
672-
and+ initial = y |> find "initial" >>= to_string in
673-
{variable; scope; type_; initial}
674-
end
675-
676-
module GhostUpdate =
677-
struct
678-
type t = {
679-
variable: string;
680-
expression: string;
681-
location: Location.t;
682-
}
683-
[@@deriving eq, ord, hash]
684-
685-
let entry_type = "ghost_update"
686-
687-
let to_yaml' {variable; expression; location} =
688-
[
689-
("variable", `String variable);
690-
("expression", `String expression);
691-
("location", Location.to_yaml location);
692-
]
693-
694-
let of_yaml y =
695-
let open GobYaml in
696-
let+ variable = y |> find "variable" >>= to_string
697-
and+ expression = y |> find "expression" >>= to_string
698-
and+ location = y |> find "location" >>= Location.of_yaml in
699-
{variable; expression; location}
700-
end
701-
702647
module GhostInstrumentation =
703648
struct
704649

@@ -831,8 +776,6 @@ struct
831776
| PreconditionLoopInvariantCertificate of PreconditionLoopInvariantCertificate.t
832777
| InvariantSet of InvariantSet.t
833778
| ViolationSequence of ViolationSequence.t
834-
| GhostVariable of GhostVariable.t
835-
| GhostUpdate of GhostUpdate.t
836779
| GhostInstrumentation of GhostInstrumentation.t
837780
[@@deriving eq, ord, hash]
838781

@@ -845,8 +788,6 @@ struct
845788
| PreconditionLoopInvariantCertificate _ -> PreconditionLoopInvariantCertificate.entry_type
846789
| InvariantSet _ -> InvariantSet.entry_type
847790
| ViolationSequence _ -> ViolationSequence.entry_type
848-
| GhostVariable _ -> GhostVariable.entry_type
849-
| GhostUpdate _ -> GhostUpdate.entry_type
850791
| GhostInstrumentation _ -> GhostInstrumentation.entry_type
851792

852793
let to_yaml' = function
@@ -858,8 +799,6 @@ struct
858799
| PreconditionLoopInvariantCertificate x -> PreconditionLoopInvariantCertificate.to_yaml' x
859800
| InvariantSet x -> InvariantSet.to_yaml' x
860801
| ViolationSequence x -> ViolationSequence.to_yaml' x
861-
| GhostVariable x -> GhostVariable.to_yaml' x
862-
| GhostUpdate x -> GhostUpdate.to_yaml' x
863802
| GhostInstrumentation x -> GhostInstrumentation.to_yaml' x
864803

865804
let of_yaml y =
@@ -889,12 +828,6 @@ struct
889828
else if entry_type = ViolationSequence.entry_type then
890829
let+ x = y |> ViolationSequence.of_yaml in
891830
ViolationSequence x
892-
else if entry_type = GhostVariable.entry_type then
893-
let+ x = y |> GhostVariable.of_yaml in
894-
GhostVariable x
895-
else if entry_type = GhostUpdate.entry_type then
896-
let+ x = y |> GhostUpdate.of_yaml in
897-
GhostUpdate x
898831
else if entry_type = GhostInstrumentation.entry_type then
899832
let+ x = y |> GhostInstrumentation.of_yaml in
900833
GhostInstrumentation x

tests/util/yamlWitnessStripCommon.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ struct
7474
InvariantSet {content = List.sort InvariantSet.Invariant.compare (List.map invariant_strip_file_hash x.content)} (* Sort, so order is deterministic regardless of Goblint. *)
7575
| ViolationSequence x ->
7676
ViolationSequence {content = List.map segment_strip_file_hash x.content}
77-
| GhostVariable x ->
78-
GhostVariable x (* no location to strip *)
79-
| GhostUpdate x ->
80-
GhostUpdate {x with location = location_strip_file_hash x.location}
8177
| GhostInstrumentation x ->
8278
GhostInstrumentation { (* Sort, so order is deterministic regardless of Goblint. *)
8379
ghost_variables = List.sort GhostInstrumentation.Variable.compare x.ghost_variables;

0 commit comments

Comments
 (0)