Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion goblint.opam
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ dev-repo: "git+https://github.com/goblint/analyzer.git"
# also remember to generate/adjust goblint.opam.locked!
available: os-distribution != "alpine" & arch != "arm64"
pin-depends: [
[ "goblint-cil.2.0.0" "git+https://github.com/goblint/cil.git#bfb977b48d6d92e0ecbdab2e04f2576095506107" ]
[ "goblint-cil.2.0.0" "git+https://github.com/goblint/cil.git#638a407306d3ce1646ef2536af173d9ba38cfd33" ]
# TODO: add back after release, only pinned for optimization (https://github.com/ocaml-ppx/ppx_deriving/pull/252)
[ "ppx_deriving.5.2.1" "git+https://github.com/ocaml-ppx/ppx_deriving.git#0a89b619f94cbbfc3b0fb3255ab4fe5bc77d32d6" ]
# TODO: add back after release, only pinned for CI stability
Expand Down
2 changes: 1 addition & 1 deletion goblint.opam.locked
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ available: os-distribution != "alpine" & arch != "arm64"
pin-depends: [
[
"goblint-cil.2.0.0"
"git+https://github.com/goblint/cil.git#bfb977b48d6d92e0ecbdab2e04f2576095506107"
"git+https://github.com/goblint/cil.git#638a407306d3ce1646ef2536af173d9ba38cfd33"
]
[
"apron.v0.9.13"
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-distribution != "alpine" & arch != "arm64"
pin-depends: [
[ "goblint-cil.2.0.0" "git+https://github.com/goblint/cil.git#bfb977b48d6d92e0ecbdab2e04f2576095506107" ]
[ "goblint-cil.2.0.0" "git+https://github.com/goblint/cil.git#638a407306d3ce1646ef2536af173d9ba38cfd33" ]
# TODO: add back after release, only pinned for optimization (https://github.com/ocaml-ppx/ppx_deriving/pull/252)
[ "ppx_deriving.5.2.1" "git+https://github.com/ocaml-ppx/ppx_deriving.git#0a89b619f94cbbfc3b0fb3255ab4fe5bc77d32d6" ]
# TODO: add back after release, only pinned for CI stability
Expand Down
2 changes: 2 additions & 0 deletions src/util/cilCfg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ let createCFG (fileAST: file) =
computeCFGInfo fd true
| _ -> ()
);
if get_bool "dbg.run_cil_check" then assert (Check.checkFile [] fileAST);

Cilfacade.do_preprocess fileAST
8 changes: 3 additions & 5 deletions src/util/loopUnrolling.ml
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,6 @@ class loopUnrollingVisitor(func) = object
annotateArrays b;
match s.skind with
| Loop (b,loc, loc2, break , continue) ->
(* We copy the statement to later be able to modify it without worrying about invariants *)
let s = { s with sid = s.sid } in

(* top-level breaks should immediately go to the end of the loop, and not just break out of the current iteration *)
let break_target = { (Cil.mkEmptyStmt ()) with labels = [Label (Cil.freshLabel "loop_end",loc, true)]} in
(* continues should go to the next unrolling *)
Expand All @@ -464,10 +461,11 @@ class loopUnrollingVisitor(func) = object
mkStmt (Block (mkBlock (copies@[s]@[break_target])))
| _ -> failwith "invariant broken"
) else s (*no change*)
in ChangeDoChildrenPost({s with sid = s.sid},duplicate_and_rem_labels);
in ChangeDoChildrenPost(s, duplicate_and_rem_labels);
| _ -> DoChildren
end

let unroll_loops fd =
Cil.populateLabelAlphaTable fd;
let thisVisitor = new loopUnrollingVisitor(fd) in
ignore (visitCilFunction thisVisitor fd)
ignore (visitCilFunction thisVisitor fd)
7 changes: 7 additions & 0 deletions src/util/options.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1803,6 +1803,13 @@
"Should the analysis print information on which globals are protected by which mutex?",
"type": "boolean",
"default": false
},
"run_cil_check" : {
"title": "dbg.run_cil_check",
"description":
"Should the analysis call Check.checkFile after creating the CFG (helpful to verify that transformations respect CIL's invariants.",
"type": "boolean",
"default": false
}
},
"additionalProperties": false
Expand Down
4 changes: 2 additions & 2 deletions tests/regression/55-loop-unrolling/01-simple-cases.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// PARAM: --enable ana.int.interval --set exp.unrolling-factor 5
// PARAM: --enable ana.int.interval --set exp.unrolling-factor 5 --enable dbg.run_cil_check
#include <goblint.h>

int global;
Expand Down Expand Up @@ -193,4 +193,4 @@ void example10(void)
++i;
}
return 0;
}
}
2 changes: 1 addition & 1 deletion tests/regression/55-loop-unrolling/02-break.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// PARAM: --set exp.unrolling-factor 5
// PARAM: --set exp.unrolling-factor 5 --enable dbg.run_cil_check
#include <goblint.h>

int main(void) {
Expand Down
2 changes: 1 addition & 1 deletion tests/regression/55-loop-unrolling/03-break-right-place.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// PARAM: --set exp.unrolling-factor 5
// PARAM: --set exp.unrolling-factor 5 --enable dbg.run_cil_check
#include <goblint.h>

int main(void) {
Expand Down
2 changes: 1 addition & 1 deletion tests/regression/55-loop-unrolling/04-simple.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// PARAM: --enable ana.int.interval --set exp.unrolling-factor 5 --set ana.base.arrays.domain unroll --set ana.base.arrays.unrolling-factor 5
// PARAM: --enable ana.int.interval --set exp.unrolling-factor 5 --set ana.base.arrays.domain unroll --set ana.base.arrays.unrolling-factor 5 --enable dbg.run_cil_check
// Simple example
#include <goblint.h>

Expand Down
2 changes: 1 addition & 1 deletion tests/regression/55-loop-unrolling/05-continue.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// PARAM: --enable ana.int.interval --set exp.unrolling-factor 5 --set ana.base.arrays.domain unroll --set ana.base.arrays.unrolling-factor 5
// PARAM: --enable ana.int.interval --set exp.unrolling-factor 5 --set ana.base.arrays.domain unroll --set ana.base.arrays.unrolling-factor 5 --enable dbg.run_cil_check
// Simple example
#include <goblint.h>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// PARAM: --enable ana.int.interval --set exp.unrolling-factor 5 --set ana.base.arrays.domain unroll --set ana.base.arrays.unrolling-factor 5
// PARAM: --enable ana.int.interval --set exp.unrolling-factor 5 --set ana.base.arrays.domain unroll --set ana.base.arrays.unrolling-factor 5 --enable dbg.run_cil_check
#include <goblint.h>

int global;
Expand Down
2 changes: 1 addition & 1 deletion tests/regression/55-loop-unrolling/07-nested-unroll.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// PARAM: --enable ana.int.interval --set exp.unrolling-factor 5 --set ana.base.arrays.domain unroll --set ana.base.arrays.unrolling-factor 5
// PARAM: --enable ana.int.interval --set exp.unrolling-factor 5 --set ana.base.arrays.domain unroll --set ana.base.arrays.unrolling-factor 5 --enable dbg.run_cil_check
#include <goblint.h>
int main(void) {
int arr[10][10];
Expand Down
17 changes: 17 additions & 0 deletions tests/regression/55-loop-unrolling/08-bad.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// PARAM: --set exp.unrolling-factor 1 --enable dbg.run_cil_check
int main() {
int m;

switch (m)
{
default:
do { } while (0);
}


goto lab;

lab: do { } while (0);

return 0;
}
14 changes: 14 additions & 0 deletions tests/regression/55-loop-unrolling/09-weird.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// PARAM: --set exp.unrolling-factor 2 --enable dbg.run_cil_check
#include <goblint.h>

void main(void)
{
int j = 0;

for(int i=0;i < 50;i++) {
goto somelab;
somelab: j = 8;
}

__goblint_check(j==8);
}