Skip to content

Commit 6f40463

Browse files
authored
Merge pull request #7429 from qinheping/goto-synthesizer-migration
SYNTHESIZER: Migrate loop-contracts synthesizer from goto-instrument to goto-synthesizer
2 parents 5d603e4 + 2a745f8 commit 6f40463

28 files changed

+240
-71
lines changed

CODEOWNERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
/src/goto-harness/ @martin-cs @chris-ryder @peterschrammel
5353
/src/goto-instrument/ @martin-cs @chris-ryder @peterschrammel @tautschnig @kroening
5454
/src/goto-instrument/contracts/ @tautschnig @feliperodri @remi-delmas-3000
55-
/src/goto-instrument/synthesizer/ @qinheping @tautschnig @feliperodri @remi-delmas-3000
5655
/src/goto-synthesizer/ @qinheping @tautschnig @feliperodri @remi-delmas-3000
5756
/src/goto-diff/ @tautschnig @peterschrammel
5857
/src/jsil/ @kroening @tautschnig

doc/man/goto-instrument.1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -999,9 +999,6 @@ force aggressive slicer to preserve all direct paths
999999
\fB\-\-apply\-loop\-contracts\fR
10001000
check and use loop contracts when provided
10011001
.TP
1002-
\fB\-\-synthesize\-loop\-invariants\fR
1003-
synthesize and apply loop invariants
1004-
.TP
10051002
\fB\-\-replace\-call\-with\-contract\fR \fIfun\fR
10061003
replace calls to \fIfun\fR with \fIfun\fR's contract
10071004
.TP

regression/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ add_subdirectory(statement-list)
6666
add_subdirectory(systemc)
6767
add_subdirectory(contracts)
6868
add_subdirectory(contracts-dfcc)
69+
add_subdirectory(goto-synthesizer)
6970
add_subdirectory(acceleration)
7071
add_subdirectory(k-induction)
7172
add_subdirectory(goto-harness)

regression/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ DIRS = cbmc \
3939
systemc \
4040
contracts \
4141
contracts-dfcc \
42+
goto-synthesizer \
4243
acceleration \
4344
k-induction \
4445
goto-harness \
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
if(WIN32)
2+
set(is_windows true)
3+
else()
4+
set(is_windows false)
5+
endif()
6+
7+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
8+
set(gcc_only -X gcc-only)
9+
set(gcc_only_string "-X;gcc-only;")
10+
else()
11+
set(gcc_only "")
12+
set(gcc_only_string "")
13+
endif()
14+
15+
16+
add_test_pl_tests(
17+
"${CMAKE_CURRENT_SOURCE_DIR}/chain.sh $<TARGET_FILE:goto-cc> $<TARGET_FILE:goto-synthesizer> $<TARGET_FILE:cbmc> ${is_windows}"
18+
)
19+
20+
## Enabling these causes a very significant increase in the time taken to run the regressions
21+
22+
#add_test_pl_profile(
23+
# "cbmc-z3"
24+
# "${CMAKE_CURRENT_SOURCE_DIR}/chain.sh $<TARGET_FILE:goto-cc> $<TARGET_FILE:goto-synthesizer> '$<TARGET_FILE:cbmc> --z3' ${is_windows}"
25+
# "-C;-X;broken-smt-backend;-X;thorough-smt-backend;-X;broken-z3-backend;-X;thorough-z3-backend;${gcc_only_string}-s;z3"
26+
# "CORE"
27+
#)
28+
29+
#add_test_pl_profile(
30+
# "cbmc-cprover-smt2"
31+
# "${CMAKE_CURRENT_SOURCE_DIR}/chain.sh $<TARGET_FILE:goto-cc> $<TARGET_FILE:goto-synthesizer> '$<TARGET_FILE:cbmc> --cprover-smt2' ${is_windows}"
32+
# "-C;-X;broken-smt-backend;-X;thorough-smt-backend;-X;broken-cprover-smt2-backend;-X;thorough-cprover-smt2-backend;${gcc_only_string}-s;cprover-smt2"
33+
# "CORE"
34+
#)
35+
36+
# solver appears on the PATH in Windows already
37+
#if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
38+
# set_property(
39+
# TEST "cbmc-cprover-smt2-CORE"
40+
# PROPERTY ENVIRONMENT
41+
# "PATH=$ENV{PATH}:$<TARGET_FILE_DIR:smt2_solver>"
42+
# )
43+
#endif()

regression/goto-synthesizer/Makefile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
default: test
2+
3+
include ../../src/config.inc
4+
include ../../src/common
5+
6+
ifeq ($(BUILD_ENV_),MSVC)
7+
exe=../../../src/goto-cc/goto-cl
8+
is_windows=true
9+
GCC_ONLY = -X gcc-only
10+
else
11+
exe=../../../src/goto-cc/goto-cc
12+
is_windows=false
13+
GCC_ONLY =
14+
endif
15+
16+
test:
17+
@../test.pl -e -p -c '../chain.sh $(exe) ../../../src/goto-synthesizer/goto-synthesizer ../../../src/cbmc/cbmc $(is_windows)' -X smt-backend $(GCC_ONLY)
18+
19+
test-cprover-smt2:
20+
@../test.pl -e -p -c '../chain.sh $(exe) ../../../src/goto-synthesizer/goto-synthesizer "../../../src/cbmc/cbmc --cprover-smt2" $(is_windows)' \
21+
-X broken-smt-backend -X thorough-smt-backend \
22+
-X broken-cprover-smt-backend -X thorough-cprover-smt-backend \
23+
-s cprover-smt2 $(GCC_ONLY)
24+
25+
test-z3:
26+
@../test.pl -e -p -c '../chain.sh $(exe) ../../../src/goto-synthesizer/goto-synthesizer "../../../src/cbmc/cbmc --z3" $(is_windows)' \
27+
-X broken-smt-backend -X thorough-smt-backend \
28+
-X broken-z3-smt-backend -X thorough-z3-smt-backend \
29+
-s z3 $(GCC_ONLY)
30+
31+
tests.log: ../test.pl test
32+
33+
34+
clean:
35+
@for dir in *; do \
36+
$(RM) tests.log; \
37+
if [ -d "$$dir" ]; then \
38+
cd "$$dir"; \
39+
$(RM) *.out *.gb *.smt2; \
40+
cd ..; \
41+
fi \
42+
done

regression/goto-synthesizer/chain.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
goto_cc=$1
6+
goto_synthesizer=$2
7+
cbmc=$3
8+
is_windows=$4
9+
10+
name=${*:$#}
11+
name=${name%.c}
12+
13+
args=${*:5:$#-5}
14+
if [[ "$args" != *" _ "* ]]
15+
then
16+
args_inst=$args
17+
args_cbmc=""
18+
else
19+
args_inst="${args%%" _ "*}"
20+
args_cbmc="${args#*" _ "}"
21+
fi
22+
23+
if [[ "${is_windows}" == "true" ]]; then
24+
$goto_cc "${name}.c" "/Fe${name}.gb"
25+
else
26+
$goto_cc -o "${name}.gb" "${name}.c"
27+
fi
28+
29+
rm -f "${name}-mod.gb"
30+
$goto_synthesizer ${args_inst} "${name}.gb" "${name}-mod.gb"
31+
if [ ! -e "${name}-mod.gb" ] ; then
32+
cp "$name.gb" "${name}-mod.gb"
33+
elif echo $args_inst | grep -q -- "--dump-c" ; then
34+
mv "${name}-mod.gb" "${name}-mod.c"
35+
36+
if [[ "${is_windows}" == "true" ]]; then
37+
$goto_cc "${name}-mod.c" "/Fe${name}-mod.gb"
38+
else
39+
$goto_cc -o "${name}-mod.gb" "${name}-mod.c"
40+
fi
41+
42+
rm "${name}-mod.c"
43+
fi
44+
$cbmc "${name}-mod.gb" ${args_cbmc}

regression/contracts/loop_invariant_synthesis_01/test.desc renamed to regression/goto-synthesizer/loop_contracts_synthesis_01/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.c
3-
--synthesize-loop-invariants --apply-loop-contracts
3+
44
^EXIT=0$
55
^SIGNAL=0$
66
^\[main\.\d+\] line 10 Check loop invariant before entry: SUCCESS$

src/goto-instrument/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,6 @@ SRC = accelerate/accelerate.cpp \
8383
source_lines.cpp \
8484
splice_call.cpp \
8585
stack_depth.cpp \
86-
synthesizer/enumerative_loop_invariant_synthesizer.cpp \
87-
synthesizer/expr_enumerator.cpp \
88-
synthesizer/synthesizer_utils.cpp \
8986
thread_instrumentation.cpp \
9087
undefined_functions.cpp \
9188
uninitialized.cpp \

0 commit comments

Comments
 (0)