Skip to content

Commit a65b86e

Browse files
authored
Merge pull request #1574 from goblint/machdep-arch
Change `Machdep` based on SV-COMP architecture
2 parents 060004c + 6d04b1a commit a65b86e

File tree

10 files changed

+54
-7
lines changed

10 files changed

+54
-7
lines changed

goblint.opam

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ dev-repo: "git+https://github.com/goblint/analyzer.git"
9797
# also remember to generate/adjust goblint.opam.locked!
9898
available: os-family != "bsd" & os-distribution != "alpine" & (arch != "arm64" | os = "macos")
9999
pin-depends: [
100-
[ "goblint-cil.2.0.4" "git+https://github.com/goblint/cil.git#04b8a45a7d20425c7b6c8abe1ad094abc063922b" ]
100+
[ "goblint-cil.2.0.4" "git+https://github.com/goblint/cil.git#9f4fac450c02bc61a13717784515056b185794cd" ]
101101
]
102102
depexts: [
103103
["libgraph-easy-perl"] {os-distribution = "ubuntu" & with-test}

goblint.opam.locked

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ post-messages: [
140140
pin-depends: [
141141
[
142142
"goblint-cil.2.0.4"
143-
"git+https://github.com/goblint/cil.git#04b8a45a7d20425c7b6c8abe1ad094abc063922b"
143+
"git+https://github.com/goblint/cil.git#9f4fac450c02bc61a13717784515056b185794cd"
144144
]
145145
]
146146
depexts: ["libgraph-easy-perl"] {os-distribution = "ubuntu" & with-test}

goblint.opam.template

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# also remember to generate/adjust goblint.opam.locked!
33
available: os-family != "bsd" & os-distribution != "alpine" & (arch != "arm64" | os = "macos")
44
pin-depends: [
5-
[ "goblint-cil.2.0.4" "git+https://github.com/goblint/cil.git#04b8a45a7d20425c7b6c8abe1ad094abc063922b" ]
5+
[ "goblint-cil.2.0.4" "git+https://github.com/goblint/cil.git#9f4fac450c02bc61a13717784515056b185794cd" ]
66
]
77
depexts: [
88
["libgraph-easy-perl"] {os-distribution = "ubuntu" & with-test}

src/analyses/base.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ struct
171171
* Abstract evaluation functions
172172
**************************************************************************)
173173

174-
let iDtoIdx = ID.cast_to (Cilfacade.ptrdiff_ikind ())
174+
let iDtoIdx x = ID.cast_to (Cilfacade.ptrdiff_ikind ()) x
175175

176176
let unop_ID = function
177177
| Neg -> ID.neg

src/cdomain/value/cdomains/arrayDomain.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ end
834834
let array_oob_check ( type a ) (module Idx: IntDomain.Z with type t = a) (x, l) (e, v) =
835835
if GobConfig.get_bool "ana.arrayoob" then (* The purpose of the following 2 lines is to give the user extra info about the array oob *)
836836
let idx_before_end = Idx.to_bool (Idx.lt v l) (* check whether index is before the end of the array *)
837-
and idx_after_start = Idx.to_bool (Idx.ge v (Idx.of_int Cil.ILong Z.zero)) in (* check whether the index is non-negative *)
837+
and idx_after_start = Idx.to_bool (Idx.ge v (Idx.of_int (Cilfacade.ptrdiff_ikind ()) Z.zero)) in (* check whether the index is non-negative *)
838838
(* For an explanation of the warning types check the Pull Request #255 *)
839839
match(idx_after_start, idx_before_end) with
840840
| Some true, Some true -> (* Certainly in bounds on both sides.*)

src/common/util/cilfacade.ml

+14-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,20 @@ let init_options () =
4747
Mergecil.merge_inlines := get_bool "cil.merge.inlines";
4848
Cil.cstd := Cil.cstd_of_string (get_string "cil.cstd");
4949
Cil.gnu89inline := get_bool "cil.gnu89inline";
50-
Cabs2cil.addNestedScopeAttr := get_bool "cil.addNestedScopeAttr"
50+
Cabs2cil.addNestedScopeAttr := get_bool "cil.addNestedScopeAttr";
51+
52+
if get_bool "ana.sv-comp.enabled" then (
53+
let machine = match get_string "exp.architecture" with
54+
| "32bit" -> Machdep.gcc32
55+
| "64bit" -> Machdep.gcc64
56+
| _ -> assert false
57+
in
58+
match machine with
59+
| Some _ -> Cil.envMachine := machine
60+
| None ->
61+
GobRef.wrap AnalysisState.should_warn true (fun () -> Messages.msg_final Error ~category:Unsound "Machine definition not available for selected architecture");
62+
Logs.error "Machine definition not available for selected architecture, defaulting to host"
63+
)
5164

5265
let init () =
5366
initCIL ();

src/goblint.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ open Maingoblint
55
(** the main function *)
66
let main () =
77
try
8-
Cilfacade.init ();
98
Maingoblint.parse_arguments ();
9+
Cilfacade.init ();
1010

1111
(* Timing. *)
1212
Maingoblint.reset_stats ();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// CRAM
2+
#include <limits.h>
3+
4+
int main() {
5+
long k = INT_MAX;
6+
long n = k * k;
7+
return 0;
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
There should be overflow on ILP32:
2+
3+
$ goblint --enable ana.sv-comp.enabled --set ana.specification "CHECK( init(main()), LTL(G ! overflow) )" --set exp.architecture 32bit 36-svcomp-arch.c
4+
[Info] Setting "ana.int.interval" to true
5+
[Info] SV-COMP specification: CHECK( init(main()), LTL(G ! overflow) )
6+
[Warning][Integer > Overflow][CWE-190] Signed integer overflow (36-svcomp-arch.c:6:8-6:17)
7+
[Info][Deadcode] Logical lines of code (LLoC) summary:
8+
live: 4
9+
dead: 0
10+
total lines: 4
11+
SV-COMP result: unknown
12+
13+
There shouldn't be an overflow on LP64:
14+
15+
$ goblint --enable ana.sv-comp.enabled --set ana.specification "CHECK( init(main()), LTL(G ! overflow) )" --set exp.architecture 64bit 36-svcomp-arch.c
16+
[Info] Setting "ana.int.interval" to true
17+
[Info] SV-COMP specification: CHECK( init(main()), LTL(G ! overflow) )
18+
[Info][Deadcode] Logical lines of code (LLoC) summary:
19+
live: 4
20+
dead: 0
21+
total lines: 4
22+
SV-COMP result: true

tests/regression/29-svcomp/dune

+4
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@
1414

1515
(cram
1616
(deps (glob_files *.c)))
17+
18+
(cram
19+
(applies_to 36-svcomp-arch)
20+
(enabled_if (<> %{system} macosx))) ; https://dune.readthedocs.io/en/stable/reference/boolean-language.html

0 commit comments

Comments
 (0)