Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Machdep based on SV-COMP architecture #1574

Merged
merged 9 commits into from
Oct 2, 2024
2 changes: 1 addition & 1 deletion goblint.opam
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ dev-repo: "git+https://github.com/goblint/analyzer.git"
# also remember to generate/adjust goblint.opam.locked!
available: os-family != "bsd" & os-distribution != "alpine" & (arch != "arm64" | os = "macos")
pin-depends: [
[ "goblint-cil.2.0.4" "git+https://github.com/goblint/cil.git#04b8a45a7d20425c7b6c8abe1ad094abc063922b" ]
[ "goblint-cil.2.0.4" "git+https://github.com/goblint/cil.git#9f4fac450c02bc61a13717784515056b185794cd" ]
]
depexts: [
["libgraph-easy-perl"] {os-distribution = "ubuntu" & with-test}
Expand Down
2 changes: 1 addition & 1 deletion goblint.opam.locked
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ post-messages: [
pin-depends: [
[
"goblint-cil.2.0.4"
"git+https://github.com/goblint/cil.git#04b8a45a7d20425c7b6c8abe1ad094abc063922b"
"git+https://github.com/goblint/cil.git#9f4fac450c02bc61a13717784515056b185794cd"
]
]
depexts: ["libgraph-easy-perl"] {os-distribution = "ubuntu" & with-test}
Expand Down
2 changes: 1 addition & 1 deletion goblint.opam.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# also remember to generate/adjust goblint.opam.locked!
available: os-family != "bsd" & os-distribution != "alpine" & (arch != "arm64" | os = "macos")
pin-depends: [
[ "goblint-cil.2.0.4" "git+https://github.com/goblint/cil.git#04b8a45a7d20425c7b6c8abe1ad094abc063922b" ]
[ "goblint-cil.2.0.4" "git+https://github.com/goblint/cil.git#9f4fac450c02bc61a13717784515056b185794cd" ]
]
depexts: [
["libgraph-easy-perl"] {os-distribution = "ubuntu" & with-test}
Expand Down
2 changes: 1 addition & 1 deletion src/analyses/base.ml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ struct
* Abstract evaluation functions
**************************************************************************)

let iDtoIdx = ID.cast_to (Cilfacade.ptrdiff_ikind ())
let iDtoIdx x = ID.cast_to (Cilfacade.ptrdiff_ikind ()) x

let unop_ID = function
| Neg -> ID.neg
Expand Down
2 changes: 1 addition & 1 deletion src/cdomain/value/cdomains/arrayDomain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ end
let array_oob_check ( type a ) (module Idx: IntDomain.Z with type t = a) (x, l) (e, v) =
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 *)
let idx_before_end = Idx.to_bool (Idx.lt v l) (* check whether index is before the end of the array *)
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 *)
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 *)
(* For an explanation of the warning types check the Pull Request #255 *)
match(idx_after_start, idx_before_end) with
| Some true, Some true -> (* Certainly in bounds on both sides.*)
Expand Down
9 changes: 8 additions & 1 deletion src/common/util/cilfacade.ml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ let init_options () =
Mergecil.merge_inlines := get_bool "cil.merge.inlines";
Cil.cstd := Cil.cstd_of_string (get_string "cil.cstd");
Cil.gnu89inline := get_bool "cil.gnu89inline";
Cabs2cil.addNestedScopeAttr := get_bool "cil.addNestedScopeAttr"
Cabs2cil.addNestedScopeAttr := get_bool "cil.addNestedScopeAttr";

if get_bool "ana.sv-comp.enabled" then (
Cil.envMachine := match get_string "exp.architecture" with
| "32bit" -> Machdep.gcc32
| "64bit" -> Machdep.gcc64
| _ -> assert false
)

let init () =
initCIL ();
Expand Down
2 changes: 1 addition & 1 deletion src/goblint.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ open Maingoblint
(** the main function *)
let main () =
try
Cilfacade.init ();
Maingoblint.parse_arguments ();
Cilfacade.init ();

(* Timing. *)
Maingoblint.reset_stats ();
Expand Down
8 changes: 8 additions & 0 deletions tests/regression/29-svcomp/36-svcomp-arch.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// CRAM
#include <limits.h>

int main() {
long k = INT_MAX;
long n = k * k;
return 0;
}
22 changes: 22 additions & 0 deletions tests/regression/29-svcomp/36-svcomp-arch.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
There should be overflow on ILP32:

$ goblint --enable ana.sv-comp.enabled --set ana.specification "CHECK( init(main()), LTL(G ! overflow) )" --set exp.architecture 32bit 36-svcomp-arch.c
[Info] Setting "ana.int.interval" to true
[Info] SV-COMP specification: CHECK( init(main()), LTL(G ! overflow) )
[Warning][Integer > Overflow][CWE-190] Signed integer overflow (36-svcomp-arch.c:6:8-6:17)
[Info][Deadcode] Logical lines of code (LLoC) summary:
live: 4
dead: 0
total lines: 4
SV-COMP result: unknown

There shouldn't be an overflow on LP64:

$ goblint --enable ana.sv-comp.enabled --set ana.specification "CHECK( init(main()), LTL(G ! overflow) )" --set exp.architecture 64bit 36-svcomp-arch.c
[Info] Setting "ana.int.interval" to true
[Info] SV-COMP specification: CHECK( init(main()), LTL(G ! overflow) )
[Info][Deadcode] Logical lines of code (LLoC) summary:
live: 4
dead: 0
total lines: 4
SV-COMP result: true
Loading