Skip to content

Commit f4486e6

Browse files
committed
Fix octagon autotuner choosing non-integer variables
1 parent 4aebf07 commit f4486e6

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

src/autoTune.ml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,17 +334,16 @@ type option = {
334334
(*Option for activating the octagon apron domain on selected vars*)
335335
module VariableMap = Map.Make(CilType.Varinfo)
336336
module VariableSet = Set.Make(CilType.Varinfo)
337+
module OctagonTracked = RelationCil.AutotuneTracked
337338

338339
let isComparison = function
339340
| Lt | Gt | Le | Ge | Ne | Eq -> true
340341
| _ -> false
341342

342-
let isGoblintStub v = List.exists (fun (Attr(s,_)) -> s = "goblint_stub") v.vattr
343-
344343
let rec extractVar = function
345344
| UnOp (Neg, e, _)
346345
| CastE (_, e) -> extractVar e
347-
| Lval ((Var info),_) when not (isGoblintStub info) -> Some info
346+
| Lval ((Var info),_) when OctagonTracked.varinfo_tracked info -> Some info
348347
| _ -> None
349348

350349
let extractBinOpVars e1 e2 =
@@ -376,7 +375,7 @@ class octagonVariableVisitor(varMap, globals) = object
376375
List.iter (fun var -> addOrCreateVarMapping varMap var 5 globals) (extractOctagonVars e2);
377376
DoChildren
378377
)
379-
| Lval ((Var info),_) when not (isGoblintStub info) -> addOrCreateVarMapping varMap info 1 globals; SkipChildren
378+
| Lval ((Var info),_) when OctagonTracked.varinfo_tracked info -> addOrCreateVarMapping varMap info 1 globals; SkipChildren
380379
(*Traverse down only operations fitting for linear equations*)
381380
| UnOp (LNot, _,_)
382381
| UnOp (Neg, _,_)

src/util/relationCil.ml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,33 @@ sig
88
val varinfo_tracked: varinfo -> bool
99
end
1010

11-
module Tracked: Tracked =
11+
module TypeTracked =
1212
struct
1313
let is_pthread_int_type = function
1414
| TNamed ({tname = ("pthread_t" | "pthread_key_t" | "pthread_once_t" | "pthread_spinlock_t"); _}, _) -> true (* on Linux these pthread types are integral *)
1515
| _ -> false
1616

1717
let type_tracked typ =
1818
isIntegralType typ && not (is_pthread_int_type typ)
19+
end
20+
21+
(** To be used in relational analyses. *)
22+
module Tracked: Tracked =
23+
struct
24+
include TypeTracked
1925

2026
let varinfo_tracked vi =
2127
(* no vglob check here, because globals are allowed in relation, but just have to be handled separately *)
2228
let hasTrackAttribute = List.exists (fun (Attr(s,_)) -> s = "goblint_relation_track") in
2329
type_tracked vi.vtype && (not @@ GobConfig.get_bool "annotation.goblint_relation_track" || hasTrackAttribute vi.vattr)
2430
end
31+
32+
(** To be used in autotuner. *)
33+
module AutotuneTracked: Tracked =
34+
struct
35+
include TypeTracked
36+
37+
let isGoblintStub v = List.exists (fun (Attr(s,_)) -> s = "goblint_stub") v.vattr
38+
39+
let varinfo_tracked vi = type_tracked vi.vtype && not (isGoblintStub vi) (* must not check for goblint_relation_track because the autotuner wants to add them based on this *)
40+
end

tests/regression/29-svcomp/38-autotune-octagon-fun.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
TODO: Should not annotate functions for octagon.
1+
Should not annotate functions for octagon.
22

33
$ goblint --enable ana.autotune.enabled --set ana.autotune.activated[*] octagon 38-autotune-octagon-fun.c
44
[Info] Enabled octagon domain ONLY for:
5-
[Info] pthread_create, i, count, tmp, key, a, count, i, j, i___0, j___0, k, size, r
5+
[Info] i, count, tmp, count, i, j, i___0, j___0, k, size, r
66
[Info][Deadcode] Logical lines of code (LLoC) summary:
77
live: 5
88
dead: 0

0 commit comments

Comments
 (0)