Skip to content

Commit 4c4ce48

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 4c4ce48

File tree

5 files changed

+24
-18
lines changed

5 files changed

+24
-18
lines changed

2ls.inc

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

88
run()
99
{
10+
./goto-cc -m$BIT_WIDTH --function $ENTRY $BM -o $LOG.bin
11+
1012
# add property-specific options
1113
if [[ "$PROP" == "termination" ]]; then
1214
PROPERTY1="$PROPERTY --termination --competition-mode"
1315
PROPERTY2="$PROPERTY --nontermination --competition-mode"
1416

1517
# 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 &
18+
$TOOL_BINARY --graphml-witness $LOG.witness --object-bits $OBJ_BITS $PROPERTY1 \
19+
$LOG.bin >> $LOG.ok1 2>&1 &
1820
PID1="$!"
19-
$TOOL_BINARY --graphml-witness $LOG.witness $BIT_WIDTH --object-bits $OBJ_BITS $PROPERTY2 \
20-
--function $ENTRY $BM >> $LOG.ok2 2>&1 &
21+
$TOOL_BINARY --graphml-witness $LOG.witness --object-bits $OBJ_BITS $PROPERTY2 \
22+
$LOG.bin >> $LOG.ok2 2>&1 &
2123
PID2="$!"
2224
# this might not work in all environments
2325
wait -n &> /dev/null
@@ -57,8 +59,8 @@ run()
5759
PROPERTY="$PROPERTY --heap-interval --k-induction --competition-mode"
5860

5961
# 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
62+
$TOOL_BINARY --graphml-witness $LOG.witness --object-bits $OBJ_BITS $PROPERTY \
63+
$LOG.bin >> $LOG.ok 2>&1
6264

6365
# store the exit code
6466
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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@ run()
1111
PROPERTY="$PROPERTY --no-assertions --no-self-loops-to-assumptions"
1212
fi
1313

14+
./goto-cc -m$BIT_WIDTH --function $ENTRY $BM -o $LOG.bin
15+
1416
timeout 875 bash -c ' \
1517
\
1618
ulimit -v 15000000 ; \
1719
\
1820
EC=42 ; \
1921
for c in 2 6 12 17 21 40 200 400 1025 2049 268435456 ; do \
2022
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 ; \
23+
./cbmc-binary --graphml-witness $LOG.witness --unwind $c --stop-on-fail --object-bits $OBJ_BITS $PROPERTY $LOG.bin >> $LOG.latest 2>&1 ; \
2224
ec=$? ; \
2325
if [ $ec -eq 0 ] ; then \
2426
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 ; \
27+
./cbmc-binary --unwinding-assertions --unwind $c --stop-on-fail --object-bits $OBJ_BITS $PROPERTY $LOG.bin > /dev/null 2>&1 || ec=42 ; \
2628
fi ; \
2729
fi ; \
2830
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)