Skip to content

Commit bcf8b72

Browse files
authored
Merge pull request #1667 from goblint/auto-disable-race-analyses
Disable race analyses for other ConcurrencySafety properties
2 parents 7356e84 + 9f6bf24 commit bcf8b72

File tree

12 files changed

+44
-48
lines changed

12 files changed

+44
-48
lines changed

conf/svcomp-ghost.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"autotune": {
8282
"enabled": true,
8383
"activated": [
84-
"singleThreaded",
84+
"reduceAnalyses",
8585
"mallocWrappers",
8686
"noRecursiveIntervals",
8787
"enums",

conf/svcomp-validate.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"autotune": {
6060
"enabled": true,
6161
"activated": [
62-
"singleThreaded",
62+
"reduceAnalyses",
6363
"mallocWrappers",
6464
"noRecursiveIntervals",
6565
"enums",

conf/svcomp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"autotune": {
5959
"enabled": true,
6060
"activated": [
61-
"singleThreaded",
61+
"reduceAnalyses",
6262
"mallocWrappers",
6363
"noRecursiveIntervals",
6464
"enums",

conf/svcomp23.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"autotune": {
6464
"enabled": true,
6565
"activated": [
66-
"singleThreaded",
66+
"reduceAnalyses",
6767
"mallocWrappers",
6868
"noRecursiveIntervals",
6969
"enums",

conf/svcomp24-validate.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"autotune": {
8080
"enabled": true,
8181
"activated": [
82-
"singleThreaded",
82+
"reduceAnalyses",
8383
"mallocWrappers",
8484
"noRecursiveIntervals",
8585
"enums",

conf/svcomp24.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"autotune": {
7979
"enabled": true,
8080
"activated": [
81-
"singleThreaded",
81+
"reduceAnalyses",
8282
"mallocWrappers",
8383
"noRecursiveIntervals",
8484
"enums",

conf/svcomp25-validate.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"autotune": {
6060
"enabled": true,
6161
"activated": [
62-
"singleThreaded",
62+
"reduceAnalyses",
6363
"mallocWrappers",
6464
"noRecursiveIntervals",
6565
"enums",

conf/svcomp25.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"autotune": {
5959
"enabled": true,
6060
"activated": [
61-
"singleThreaded",
61+
"reduceAnalyses",
6262
"mallocWrappers",
6363
"noRecursiveIntervals",
6464
"enums",

conf/svcomp2var.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"autotune": {
7979
"enabled": true,
8080
"activated": [
81-
"singleThreaded",
81+
"reduceAnalyses",
8282
"mallocWrappers",
8383
"noRecursiveIntervals",
8484
"enums",

src/autoTune.ml

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -206,29 +206,31 @@ let hasFunction pred =
206206
calls.calledBy |> FunctionCallMap.exists (fun var _ -> relevant_static var) ||
207207
calls.dynamicallyCalled |> FunctionSet.exists relevant_dynamic
208208

209-
let disableAnalyses anas =
210-
List.iter (GobConfig.set_auto "ana.activated[-]") anas
209+
let disableAnalyses reason analyses =
210+
Logs.info "%s -> disabling analyses: \"%s\"" reason (String.concat ", " analyses);
211+
List.iter (GobConfig.set_auto "ana.activated[-]") analyses
211212

212-
let enableAnalyses anas =
213-
List.iter (GobConfig.set_auto "ana.activated[+]") anas
213+
let enableAnalyses reason description analyses =
214+
Logs.info "%s -> enabling %s: \"%s\"" reason description (String.concat ", " analyses);
215+
List.iter (GobConfig.set_auto "ana.activated[+]") analyses
214216

215217
(*If only one thread is used in the program, we can disable most thread analyses*)
216218
(*The exceptions are analyses that are depended on by others: base -> mutex -> mutexEvents, access; termination -> threadflag *)
217219
(*escape is also still enabled, because otherwise we get a warning*)
218220
(*does not consider dynamic calls!*)
221+
let notNeccessaryRaceAnalyses = ["race"; "symb_locks"; "region"]
222+
let notNeccessaryThreadAnalyses = notNeccessaryRaceAnalyses @ ["deadlock"; "maylocks"; "thread"; "threadid"; "threadJoins"; "threadreturn"; "mhp"; "pthreadMutexType"]
219223

220-
let notNeccessaryThreadAnalyses = ["race"; "deadlock"; "maylocks"; "symb_locks"; "thread"; "threadid"; "threadJoins"; "threadreturn"; "mhp"; "region"; "pthreadMutexType"]
221-
let reduceThreadAnalyses () =
224+
let hasSpec spec = List.mem spec (Svcomp.Specification.of_option ())
225+
226+
let reduceAnalyses () =
222227
let isThreadCreate (desc: LibraryDesc.t) args =
223228
match desc.special args with
224229
| LibraryDesc.ThreadCreate _ -> true
225230
| _ -> LibraryDesc.Accesses.find_kind desc.accs Spawn args <> []
226231
in
227232
let hasThreadCreate = hasFunction isThreadCreate in
228-
if not @@ hasThreadCreate then (
229-
Logs.info "no thread creation -> disabling thread analyses \"%s\"" (String.concat ", " notNeccessaryThreadAnalyses);
230-
disableAnalyses notNeccessaryThreadAnalyses;
231-
)
233+
if not hasThreadCreate then disableAnalyses "no thread creation" notNeccessaryThreadAnalyses
232234

233235
let focusOnMemSafetySpecification (spec: Svcomp.Specification.t) =
234236
match spec with
@@ -247,8 +249,7 @@ let focusOnTermination (spec: Svcomp.Specification.t) =
247249
match spec with
248250
| Termination ->
249251
let terminationAnas = ["threadflag"; "apron"] in
250-
Logs.info "Specification: Termination -> enabling termination analyses \"%s\"" (String.concat ", " terminationAnas);
251-
enableAnalyses terminationAnas;
252+
enableAnalyses "Specification: Termination" "termination analyses" terminationAnas;
252253
set_string "sem.int.signed_overflow" "assume_none";
253254
set_bool "ana.int.interval" true;
254255
set_string "ana.apron.domain" "polyhedra"; (* TODO: Needed? *)
@@ -258,16 +259,16 @@ let focusOnTermination (spec: Svcomp.Specification.t) =
258259
let focusOnTermination () =
259260
List.iter focusOnTermination (Svcomp.Specification.of_option ())
260261

261-
let concurrencySafety (spec: Svcomp.Specification.t) =
262-
match spec with
263-
| NoDataRace -> (*enable all thread analyses*)
264-
Logs.info "Specification: NoDataRace -> enabling thread analyses \"%s\"" (String.concat ", " notNeccessaryThreadAnalyses);
265-
enableAnalyses notNeccessaryThreadAnalyses;
266-
| _ -> ()
262+
let focusOnConcurrencySafety () =
263+
if hasSpec SvcompSpec.NoDataRace then
264+
(*enable all thread analyses*)
265+
(* TODO: what's the exact relation between thread analyses enabled in conf, the ones we disable in reduceAnalyses and the ones we enable here? *)
266+
enableAnalyses "Specification: NoDataRace" "thread analyses" notNeccessaryThreadAnalyses
267+
else
268+
disableAnalyses "NoDataRace property is not in spec" notNeccessaryRaceAnalyses
267269

268-
let noOverflows (spec: Svcomp.Specification.t) =
269-
match spec with
270-
| NoOverflow ->
270+
let focusOnNoOverflows () =
271+
if hasSpec SvcompSpec.NoOverflow then (
271272
(*We focus on integer analysis*)
272273
set_bool "ana.int.def_exc" true;
273274
begin
@@ -276,10 +277,7 @@ let noOverflows (spec: Svcomp.Specification.t) =
276277
set_int "ana.malloc.unique_address_count" 1
277278
with Found -> set_int "ana.malloc.unique_address_count" 0;
278279
end
279-
| _ -> ()
280-
281-
let focusOn (f : SvcompSpec.t -> unit) =
282-
List.iter f (Svcomp.Specification.of_option ())
280+
)
283281

284282
(*Detect enumerations and enable the "ana.int.enums" option*)
285283
exception EnumFound
@@ -492,8 +490,7 @@ let activateTmpSpecialAnalysis () =
492490
in
493491
let hasMathFunctions = hasFunction isMathFun in
494492
if hasMathFunctions then (
495-
Logs.info "math function -> enabling tmpSpecial analysis and floating-point domain";
496-
enableAnalyses ["tmpSpecial"];
493+
enableAnalyses "Math function" "tmpSpecial analysis and floating-point domain" ["tmpSpecial"];
497494
set_bool "ana.float.interval" true;
498495
)
499496

@@ -546,15 +543,17 @@ let chooseConfig file =
546543
if isActivated "mallocWrappers" then
547544
findMallocWrappers ();
548545

549-
if isActivated "concurrencySafetySpecification" then focusOn concurrencySafety;
546+
if isActivated "concurrencySafetySpecification" then
547+
focusOnConcurrencySafety ();
550548

551-
if isActivated "noOverflows" then focusOn noOverflows;
549+
if isActivated "noOverflows" then
550+
focusOnNoOverflows ();
552551

553552
if isActivated "enums" && hasEnums file then
554553
set_bool "ana.int.enums" true;
555554

556-
if isActivated "singleThreaded" then
557-
reduceThreadAnalyses ();
555+
if isActivated "reduceAnalyses" then
556+
reduceAnalyses ();
558557

559558
if isActivated "arrayDomain" then
560559
selectArrayDomains file;

0 commit comments

Comments
 (0)