|
|
@ -21,16 +21,6 @@ let tests =
|
|
|
|
let open AnalyzerTester.StructuredSil in
|
|
|
|
let open AnalyzerTester.StructuredSil in
|
|
|
|
let assert_empty = invariant "{ }" in
|
|
|
|
let assert_empty = invariant "{ }" in
|
|
|
|
let test_list = [
|
|
|
|
let test_list = [
|
|
|
|
"var_tautology",
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
var_assign_var "a" "a";
|
|
|
|
|
|
|
|
assert_empty
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
"id_tautology",
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
id_assign_id "a" "a";
|
|
|
|
|
|
|
|
assert_empty
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
"id_letderef_id_no_gen",
|
|
|
|
"id_letderef_id_no_gen",
|
|
|
|
[
|
|
|
|
[
|
|
|
|
id_assign_id "b" "a"; (* means b = *a *)
|
|
|
|
id_assign_id "b" "a"; (* means b = *a *)
|
|
|
@ -41,7 +31,6 @@ let tests =
|
|
|
|
id_set_id "b" "a"; (* means *b = a *)
|
|
|
|
id_set_id "b" "a"; (* means *b = a *)
|
|
|
|
assert_empty
|
|
|
|
assert_empty
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
"id_set_id_no_kill",
|
|
|
|
"id_set_id_no_kill",
|
|
|
|
[
|
|
|
|
[
|
|
|
|
id_assign_var "b" "a";
|
|
|
|
id_assign_var "b" "a";
|
|
|
@ -54,10 +43,10 @@ let tests =
|
|
|
|
id_assign_var "b" "a";
|
|
|
|
id_assign_var "b" "a";
|
|
|
|
invariant "{ b$0 -> &a }"
|
|
|
|
invariant "{ b$0 -> &a }"
|
|
|
|
];
|
|
|
|
];
|
|
|
|
"var_assign_var_gen",
|
|
|
|
"var_assign_addrof_var_no_gen",
|
|
|
|
[
|
|
|
|
[
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
var_assign_addrof_var "b" "a"; (* means b = &a *)
|
|
|
|
invariant "{ &b -> &a }"
|
|
|
|
assert_empty
|
|
|
|
];
|
|
|
|
];
|
|
|
|
"var_assign_id_gen",
|
|
|
|
"var_assign_id_gen",
|
|
|
|
[
|
|
|
|
[
|
|
|
@ -66,130 +55,112 @@ let tests =
|
|
|
|
];
|
|
|
|
];
|
|
|
|
"multi_command_gen",
|
|
|
|
"multi_command_gen",
|
|
|
|
[
|
|
|
|
[
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
id_assign_var "b" "a";
|
|
|
|
var_assign_var "c" "b";
|
|
|
|
var_assign_id "c" "b";
|
|
|
|
var_assign_var "d" "c";
|
|
|
|
id_assign_var "d" "c";
|
|
|
|
invariant "{ &b -> &a, &c -> &b, &d -> &c }"
|
|
|
|
invariant "{ b$0 -> &a, d$0 -> &c, &c -> b$0 }"
|
|
|
|
];
|
|
|
|
];
|
|
|
|
"simple_kill",
|
|
|
|
"simple_kill",
|
|
|
|
[
|
|
|
|
[
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
id_assign_var "b" "a";
|
|
|
|
invariant "{ &b -> &a }";
|
|
|
|
invariant "{ b$0 -> &a }";
|
|
|
|
var_assign_int "a" 1;
|
|
|
|
var_assign_int "a" 1;
|
|
|
|
assert_empty
|
|
|
|
assert_empty
|
|
|
|
];
|
|
|
|
];
|
|
|
|
"kill_then_gen",
|
|
|
|
"kill_then_gen",
|
|
|
|
[
|
|
|
|
[
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
id_assign_var "b" "a";
|
|
|
|
invariant "{ &b -> &a }";
|
|
|
|
invariant "{ b$0 -> &a }";
|
|
|
|
var_assign_var "a" "b";
|
|
|
|
var_assign_id "a" "c";
|
|
|
|
invariant "{ &a -> &b }"
|
|
|
|
invariant "{ &a -> c$0 }"
|
|
|
|
];
|
|
|
|
|
|
|
|
"harder_kill",
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
|
|
|
|
var_assign_var "c" "b";
|
|
|
|
|
|
|
|
var_assign_var "d" "c";
|
|
|
|
|
|
|
|
invariant "{ &b -> &a, &c -> &b, &d -> &c }";
|
|
|
|
|
|
|
|
var_assign_int "b" 1;
|
|
|
|
|
|
|
|
invariant "{ &c -> &a, &d -> &c }";
|
|
|
|
|
|
|
|
var_assign_int "c" 1;
|
|
|
|
|
|
|
|
invariant "{ &d -> &a }"
|
|
|
|
|
|
|
|
];
|
|
|
|
];
|
|
|
|
"same_copy",
|
|
|
|
"same_copy",
|
|
|
|
[
|
|
|
|
[
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
var_assign_id "b" "a";
|
|
|
|
var_assign_var "c" "b";
|
|
|
|
var_assign_id "c" "d";
|
|
|
|
invariant "{ &b -> &a, &c -> &b }";
|
|
|
|
invariant "{ &b -> a$0, &c -> d$0 }";
|
|
|
|
var_assign_var "c" "b";
|
|
|
|
var_assign_id "c" "d";
|
|
|
|
invariant "{ &b -> &a, &c -> &b }"
|
|
|
|
invariant "{ &b -> a$0, &c -> d$0 }"
|
|
|
|
];
|
|
|
|
|
|
|
|
"no_cycles",
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
var_assign_var "a" "b";
|
|
|
|
|
|
|
|
invariant "{ &a -> &b }";
|
|
|
|
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
|
|
|
|
invariant "{ &b -> &a }";
|
|
|
|
|
|
|
|
var_assign_var "a" "a";
|
|
|
|
|
|
|
|
invariant "{ &b -> &a }"
|
|
|
|
|
|
|
|
];
|
|
|
|
];
|
|
|
|
"conservative_if",
|
|
|
|
"conservative_if",
|
|
|
|
[
|
|
|
|
[
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
var_assign_id "b" "a";
|
|
|
|
If (unknown_exp,
|
|
|
|
If (unknown_exp,
|
|
|
|
[invariant "{ &b -> &a }";
|
|
|
|
[invariant "{ &b -> a$0 }";
|
|
|
|
var_assign_var "a" "b";
|
|
|
|
var_assign_id "b" "c";
|
|
|
|
invariant "{ &a -> &b }"],
|
|
|
|
invariant "{ &b -> c$0 }"],
|
|
|
|
[]
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
);
|
|
|
|
assert_empty
|
|
|
|
assert_empty
|
|
|
|
];
|
|
|
|
];
|
|
|
|
"if1",
|
|
|
|
"if1",
|
|
|
|
[
|
|
|
|
[
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
var_assign_id "b" "a";
|
|
|
|
var_assign_var "c" "b";
|
|
|
|
var_assign_id "c" "d";
|
|
|
|
If (unknown_exp,
|
|
|
|
If (unknown_exp,
|
|
|
|
[invariant "{ &b -> &a, &c -> &b }";
|
|
|
|
[invariant "{ &b -> a$0, &c -> d$0 }";
|
|
|
|
var_assign_var "c" "d"],
|
|
|
|
var_assign_id "c" "e";
|
|
|
|
[invariant "{ &b -> &a, &c -> &b }"]
|
|
|
|
invariant "{ &b -> a$0, &c -> e$0 }";
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
[invariant "{ &b -> a$0, &c -> d$0 }"]
|
|
|
|
);
|
|
|
|
);
|
|
|
|
invariant "{ &b -> &a }"
|
|
|
|
invariant "{ &b -> a$0 }"
|
|
|
|
];
|
|
|
|
];
|
|
|
|
"if2",
|
|
|
|
"if2",
|
|
|
|
[
|
|
|
|
[
|
|
|
|
If (unknown_exp,
|
|
|
|
If (unknown_exp,
|
|
|
|
[var_assign_var "a" "b"],
|
|
|
|
[var_assign_id "a" "b"],
|
|
|
|
[var_assign_var "a" "b"]
|
|
|
|
[var_assign_id "a" "b"]
|
|
|
|
);
|
|
|
|
);
|
|
|
|
invariant "{ &a -> &b }"
|
|
|
|
invariant "{ &a -> b$0 }"
|
|
|
|
];
|
|
|
|
];
|
|
|
|
"if3",
|
|
|
|
"if3",
|
|
|
|
[
|
|
|
|
[
|
|
|
|
If (unknown_exp,
|
|
|
|
If (unknown_exp,
|
|
|
|
[var_assign_var "a" "b"],
|
|
|
|
[var_assign_id "a" "b"],
|
|
|
|
[var_assign_var "a" "c"]
|
|
|
|
[var_assign_id "a" "c"]
|
|
|
|
);
|
|
|
|
);
|
|
|
|
assert_empty
|
|
|
|
assert_empty
|
|
|
|
];
|
|
|
|
];
|
|
|
|
"nested_if",
|
|
|
|
"nested_if",
|
|
|
|
[
|
|
|
|
[
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
var_assign_id "b" "a";
|
|
|
|
var_assign_var "c" "b";
|
|
|
|
var_assign_id "c" "b";
|
|
|
|
If (unknown_exp,
|
|
|
|
If (unknown_exp,
|
|
|
|
[If (var_of_str "unknown2",
|
|
|
|
[If (var_of_str "unknown2",
|
|
|
|
[ invariant "{ &b -> &a, &c -> &b }";
|
|
|
|
[ invariant "{ &b -> a$0, &c -> b$0 }";
|
|
|
|
var_assign_var "a" "b";
|
|
|
|
var_assign_id "b" "d";
|
|
|
|
invariant "{ &a -> &b, &c -> &b }"],
|
|
|
|
invariant "{ &b -> d$0, &c -> b$0 }"],
|
|
|
|
[]
|
|
|
|
[]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
],
|
|
|
|
],
|
|
|
|
[]
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
);
|
|
|
|
invariant "{ &c -> &b }"
|
|
|
|
invariant "{ &c -> b$0 }"
|
|
|
|
];
|
|
|
|
];
|
|
|
|
"loop_as_if",
|
|
|
|
"loop_as_if",
|
|
|
|
[
|
|
|
|
[
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
var_assign_id "b" "a";
|
|
|
|
While (unknown_exp,
|
|
|
|
While (unknown_exp,
|
|
|
|
[var_assign_var "a" "b"]
|
|
|
|
[var_assign_id "b" "c"]
|
|
|
|
);
|
|
|
|
);
|
|
|
|
assert_empty
|
|
|
|
assert_empty
|
|
|
|
];
|
|
|
|
];
|
|
|
|
"easy_loop_invariant",
|
|
|
|
"easy_loop_invariant",
|
|
|
|
[
|
|
|
|
[
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
var_assign_id "b" "a";
|
|
|
|
While (unknown_exp,
|
|
|
|
While (unknown_exp,
|
|
|
|
[var_assign_var "c" "b";
|
|
|
|
[var_assign_id "c" "d";
|
|
|
|
invariant "{ &b -> &a, &c -> &b }"]
|
|
|
|
invariant "{ &b -> a$0, &c -> d$0 }"]
|
|
|
|
);
|
|
|
|
);
|
|
|
|
invariant "{ &b -> &a }"
|
|
|
|
invariant "{ &b -> a$0 }"
|
|
|
|
];
|
|
|
|
];
|
|
|
|
"empty_loop",
|
|
|
|
"empty_loop",
|
|
|
|
[
|
|
|
|
[
|
|
|
|
var_assign_var "b" "a";
|
|
|
|
var_assign_id "b" "a";
|
|
|
|
While (unknown_exp, []);
|
|
|
|
While (unknown_exp, []);
|
|
|
|
var_assign_var "c" "b";
|
|
|
|
var_assign_id "c" "b";
|
|
|
|
invariant "{ &b -> &a, &c -> &b }"
|
|
|
|
invariant "{ &b -> a$0, &c -> b$0 }"
|
|
|
|
];
|
|
|
|
];
|
|
|
|
] |> TestInterpreter.create_tests ProcData.empty_extras in
|
|
|
|
] |> TestInterpreter.create_tests ProcData.empty_extras in
|
|
|
|
"copy_propagation_test_suite">:::test_list
|
|
|
|
"copy_propagation_test_suite">:::test_list
|
|
|
|