Skip to content

Commit 273e8b5

Browse files
committed
Use goto-cc to compile once and establish sharing
Writing goto binaries establishes sharing of equal irepts, which is beneficial to all subsequent stages of analysis. For CBMC this furthermore implies that compilation is only done once instead of doing so for every loop unwinding attempt.
1 parent e9545d5 commit 273e8b5

File tree

5 files changed

+30
-18
lines changed

5 files changed

+30
-18
lines changed

2ls.inc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,22 @@ TOOL_NAME=2LS
77

88
run()
99
{
10+
gmon_suffix=$GMON_OUT_PREFIX
11+
export GMON_OUT_PREFIX="goto-cc_$gmon_suffix"
12+
./goto-cc -m$BIT_WIDTH --function $ENTRY $BM -o $LOG.bin
13+
14+
export GMON_OUT_PREFIX="2ls_$gmon_suffix"
1015
# add property-specific options
1116
if [[ "$PROP" == "termination" ]]; then
1217
PROPERTY1="$PROPERTY --termination --competition-mode"
1318
PROPERTY2="$PROPERTY --nontermination --competition-mode"
1419

1520
# run the termination and nontermination analysis in parallel
16-
$TOOL_BINARY --graphml-witness $LOG.witness $BIT_WIDTH --object-bits $OBJ_BITS $PROPERTY1 \
17-
--function $ENTRY $BM >> $LOG.ok1 2>&1 &
21+
$TOOL_BINARY --graphml-witness $LOG.witness --object-bits $OBJ_BITS $PROPERTY1 \
22+
$LOG.bin >> $LOG.ok1 2>&1 &
1823
PID1="$!"
19-
$TOOL_BINARY --graphml-witness $LOG.witness $BIT_WIDTH --object-bits $OBJ_BITS $PROPERTY2 \
20-
--function $ENTRY $BM >> $LOG.ok2 2>&1 &
24+
$TOOL_BINARY --graphml-witness $LOG.witness --object-bits $OBJ_BITS $PROPERTY2 \
25+
$LOG.bin >> $LOG.ok2 2>&1 &
2126
PID2="$!"
2227
# this might not work in all environments
2328
wait -n &> /dev/null
@@ -57,8 +62,8 @@ run()
5762
PROPERTY="$PROPERTY --heap-interval --k-induction --competition-mode"
5863

5964
# run the tool
60-
$TOOL_BINARY --graphml-witness $LOG.witness $BIT_WIDTH --object-bits $OBJ_BITS $PROPERTY \
61-
--function $ENTRY $BM >> $LOG.ok 2>&1
65+
$TOOL_BINARY --graphml-witness $LOG.witness --object-bits $OBJ_BITS $PROPERTY \
66+
$LOG.bin >> $LOG.ok 2>&1
6267

6368
# store the exit code
6469
EC=$?

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,28 @@ jbmc: jbmc.zip
1818
cat $*.inc tool-wrapper.inc >> $@
1919
chmod 755 $@
2020

21-
cbmc.zip: cbmc.inc tool-wrapper.inc $(CBMC)/LICENSE $(CBMC)/src/cbmc/cbmc
21+
cbmc.zip: cbmc.inc tool-wrapper.inc $(CBMC)/LICENSE $(CBMC)/src/cbmc/cbmc $(CBMC)/src/goto-cc/goto-cc
2222
mkdir -p $(basename $@)
2323
$(MAKE) cbmc-wrapper
2424
mv cbmc-wrapper $(basename $@)/cbmc
2525
cp $(CBMC)/LICENSE $(basename $@)/
2626
cp $(CBMC)/src/cbmc/cbmc $(basename $@)/cbmc-binary
27+
cp $(CBMC)/src/goto-cc/goto-cc $(basename $@)/
2728
chmod a+rX $(basename $@)/*
2829
zip -r $@ $(basename $@)
29-
cd $(basename $@) && rm cbmc cbmc-binary LICENSE
30+
cd $(basename $@) && rm cbmc cbmc-binary goto-cc LICENSE
3031
rmdir $(basename $@)
3132

32-
2ls.zip: 2ls.inc tool-wrapper.inc $(2LS)/LICENSE $(2LS)/src/2ls/2ls
33+
2ls.zip: 2ls.inc tool-wrapper.inc $(2LS)/LICENSE $(2LS)/src/2ls/2ls $(2LS)/src/goto-cc/goto-cc
3334
mkdir -p $(basename $@)
3435
$(MAKE) 2ls-wrapper
3536
mv 2ls-wrapper $(basename $@)/2ls
3637
cp $(2LS)/LICENSE $(basename $@)/
3738
cp $(2LS)/src/2ls/2ls $(basename $@)/2ls-binary
39+
cp $(2LS)/src/goto-cc/goto-cc $(basename $@)/
3840
chmod a+rX $(basename $@)/*
3941
zip -r $@ $(basename $@)
40-
cd $(basename $@) && rm 2ls 2ls-binary LICENSE
42+
cd $(basename $@) && rm 2ls 2ls-binary goto-cc LICENSE
4143
rmdir $(basename $@)
4244

4345
jbmc.zip: jbmc.inc tool-wrapper.inc $(JBMC)/LICENSE $(JBMC)/src/jbmc/jbmc

cbmc.inc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,23 @@ run()
1111
PROPERTY="$PROPERTY --no-assertions --no-self-loops-to-assumptions"
1212
fi
1313

14+
gmon_suffix=$GMON_OUT_PREFIX
15+
export GMON_OUT_PREFIX="goto-cc_$gmon_suffix"
16+
./goto-cc -m$BIT_WIDTH --function $ENTRY $BM -o $LOG.bin
17+
18+
export GMON_OUT_PREFIX="cbmc_$gmon_suffix"
1419
timeout 875 bash -c ' \
1520
\
1621
ulimit -v 15000000 ; \
1722
\
1823
EC=42 ; \
1924
for c in 2 6 12 17 21 40 200 400 1025 2049 268435456 ; do \
2025
echo "Unwind: $c" > $LOG.latest ; \
21-
./cbmc-binary --graphml-witness $LOG.witness --unwind $c --stop-on-fail $BIT_WIDTH --object-bits $OBJ_BITS $PROPERTY --function $ENTRY $BM >> $LOG.latest 2>&1 ; \
26+
./cbmc-binary --graphml-witness $LOG.witness --unwind $c --stop-on-fail --object-bits $OBJ_BITS $PROPERTY $LOG.bin >> $LOG.latest 2>&1 ; \
2227
ec=$? ; \
2328
if [ $ec -eq 0 ] ; then \
2429
if ! tail -n 10 $LOG.latest | grep -q "^VERIFICATION SUCCESSFUL$" ; then ec=1 ; else \
25-
./cbmc-binary --unwinding-assertions --unwind $c --stop-on-fail $BIT_WIDTH --object-bits $OBJ_BITS $PROPERTY --function $ENTRY $BM > /dev/null 2>&1 || ec=42 ; \
30+
./cbmc-binary --unwinding-assertions --unwind $c --stop-on-fail --object-bits $OBJ_BITS $PROPERTY $LOG.bin > /dev/null 2>&1 || ec=42 ; \
2631
fi ; \
2732
fi ; \
2833
if [ $ec -eq 10 ] ; then \

jbmc.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ ulimit -v 15000000 ; \
1818
EC=42 ; \
1919
for c in 2 6 12 17 21 40 200 400 1025 2049 268435456 ; do \
2020
echo "Unwind: $c" > $LOG.latest ; \
21-
./jbmc-binary --graphml-witness $LOG.witness --unwind $c --stop-on-fail $BIT_WIDTH --object-bits $OBJ_BITS $PROPERTY --function $ENTRY $BM >> $LOG.latest 2>&1 ; \
21+
./jbmc-binary --graphml-witness $LOG.witness --unwind $c --stop-on-fail --$BIT_WIDTH --object-bits $OBJ_BITS $PROPERTY --function $ENTRY $BM >> $LOG.latest 2>&1 ; \
2222
ec=$? ; \
2323
if [ $ec -eq 0 ] ; then \
2424
if ! tail -n 10 $LOG.latest | grep -q "^VERIFICATION SUCCESSFUL$" ; then ec=1 ; else \
25-
./jbmc-binary --unwinding-assertions --unwind $c --stop-on-fail $BIT_WIDTH --object-bits $OBJ_BITS $PROPERTY --function $ENTRY $BM > /dev/null 2>&1 || ec=42 ; \
25+
./jbmc-binary --unwinding-assertions --unwind $c --stop-on-fail --$BIT_WIDTH --object-bits $OBJ_BITS $PROPERTY --function $ENTRY $BM > /dev/null 2>&1 || ec=42 ; \
2626
fi ; \
2727
fi ; \
2828
if [ $ec -eq 10 ] ; then \

tool-wrapper.inc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,19 @@ process_graphml()
7474
<data key=\"specification\">$(<$PROP_FILE)<\/data>
7575
<data key=\"programfile\">$(echo $BM | sed 's8/8\\/8g')<\/data>
7676
<data key=\"programhash\">$(sha1sum $BM | awk '{print $1}')<\/data>
77-
<data key=\"architecture\">${BIT_WIDTH##--}bit<\/data>\\Q/"
77+
<data key=\"architecture\">${BIT_WIDTH}bit<\/data>\\Q/"
7878
fi
7979
}
8080

8181
OBJ_BITS="11"
82-
BIT_WIDTH="--64"
82+
BIT_WIDTH="64"
8383
BM=""
8484
PROP_FILE=""
8585
WITNESS_FILE=""
8686

8787
while [ -n "$1" ] ; do
8888
case "$1" in
89-
--32|--64) BIT_WIDTH="$1" ; shift 1 ;;
89+
--32|--64) BIT_WIDTH="${1##--}" ; shift 1 ;;
9090
--propertyfile) PROP_FILE="$2" ; shift 2 ;;
9191
--graphml-witness) WITNESS_FILE="$2" ; shift 2 ;;
9292
--version) $TOOL_BINARY --version ; exit 0 ;;
@@ -125,7 +125,7 @@ export OBJ_BITS
125125
export GMON_OUT_PREFIX=`basename $BM`.gmon.out
126126

127127
export LOG=`mktemp -t ${TOOL_NAME}-log.XXXXXX`
128-
trap "rm -f $LOG $LOG.latest $LOG.ok $LOG.witness" EXIT
128+
trap "rm -f $LOG $LOG.latest $LOG.ok $LOG.witness $LOG.bin" EXIT
129129

130130
run
131131

0 commit comments

Comments
 (0)