From 2235d3dc9e090a1d4b13d653138838624c70ba26 Mon Sep 17 00:00:00 2001 From: akashlal Date: Wed, 7 Jul 2010 17:52:18 +0000 Subject: Boogie: Added stratified inlining. It is enabled using the flag /stratifiedInline:1. --- Test/stratifiedinline/Answer | 64 +++++++++++++++++++++++++++++++++++++++ Test/stratifiedinline/bar1.bpl | 26 ++++++++++++++++ Test/stratifiedinline/bar2.bpl | 24 +++++++++++++++ Test/stratifiedinline/bar3.bpl | 41 +++++++++++++++++++++++++ Test/stratifiedinline/bar4.bpl | 38 +++++++++++++++++++++++ Test/stratifiedinline/bar6.bpl | 36 ++++++++++++++++++++++ Test/stratifiedinline/runtest.bat | 22 ++++++++++++++ 7 files changed, 251 insertions(+) create mode 100644 Test/stratifiedinline/Answer create mode 100644 Test/stratifiedinline/bar1.bpl create mode 100644 Test/stratifiedinline/bar2.bpl create mode 100644 Test/stratifiedinline/bar3.bpl create mode 100644 Test/stratifiedinline/bar4.bpl create mode 100644 Test/stratifiedinline/bar6.bpl create mode 100644 Test/stratifiedinline/runtest.bat (limited to 'Test/stratifiedinline') diff --git a/Test/stratifiedinline/Answer b/Test/stratifiedinline/Answer new file mode 100644 index 00000000..aa83b37c --- /dev/null +++ b/Test/stratifiedinline/Answer @@ -0,0 +1,64 @@ +----- Running regression test bar1.bpl +bar1.bpl(25,1): Error BP5003: A postcondition might not hold at this return statement. +bar1.bpl(21,1): Related location: This is the postcondition that might not hold. +Execution trace: + bar1.bpl(24,3): anon0 + Inlined call to procedure foo begins + bar1.bpl(13,5): anon0 + Inlined call to procedure bar begins + bar1.bpl(7,5): anon0 + Inlined call to procedure bar ends + Inlined call to procedure bar begins + bar1.bpl(7,5): anon0 + Inlined call to procedure bar ends + Inlined call to procedure foo ends + +Boogie program verifier finished with 0 verified, 1 error +----- +----- Running regression test bar2.bpl +bar2.bpl(21,3): Error BP5001: This assertion might not hold. +Execution trace: + bar2.bpl(19,3): anon0 + Inlined call to procedure foo begins + bar2.bpl(5,3): anon0 + bar2.bpl(6,7): anon3_Then + Inlined call to procedure foo ends + Inlined call to procedure foo begins + bar2.bpl(5,3): anon0 + bar2.bpl(9,7): anon3_Else + Inlined call to procedure foo ends + +Boogie program verifier finished with 0 verified, 1 error +----- +----- Running regression test bar3.bpl +bar3.bpl(41,1): Error BP5003: A postcondition might not hold at this return statement. +bar3.bpl(34,1): Related location: This is the postcondition that might not hold. +Execution trace: + bar3.bpl(38,3): anon0 + Inlined call to procedure foo begins + bar3.bpl(18,3): anon0 + bar3.bpl(19,7): anon3_Then + Inlined call to procedure bar begins + bar3.bpl(7,3): anon0 + bar3.bpl(8,7): anon3_Then + Inlined call to procedure bar ends + Inlined call to procedure bar begins + bar3.bpl(7,3): anon0 + bar3.bpl(8,7): anon3_Then + Inlined call to procedure bar ends + Inlined call to procedure foo ends + Inlined call to procedure bar begins + bar3.bpl(7,3): anon0 + bar3.bpl(10,7): anon3_Else + Inlined call to procedure bar ends + +Boogie program verifier finished with 0 verified, 1 error +----- +----- Running regression test bar4.bpl + +Boogie program verifier finished with 1 verified, 0 errors +----- +----- Running regression test bar6.bpl + +Boogie program verifier finished with 1 verified, 0 errors +----- diff --git a/Test/stratifiedinline/bar1.bpl b/Test/stratifiedinline/bar1.bpl new file mode 100644 index 00000000..845954d5 --- /dev/null +++ b/Test/stratifiedinline/bar1.bpl @@ -0,0 +1,26 @@ +var x: int; +var y: int; + +procedure {:inline 1} bar() +modifies y; +{ + y := y + 1; +} + +procedure {:inline 1} foo() +modifies x, y; +{ + x := x + 1; + call bar(); + call bar(); + x := x + 1; +} + +procedure main() +requires x == y; +ensures x != y; +modifies x, y; +{ + call foo(); +} + diff --git a/Test/stratifiedinline/bar2.bpl b/Test/stratifiedinline/bar2.bpl new file mode 100644 index 00000000..76991a8f --- /dev/null +++ b/Test/stratifiedinline/bar2.bpl @@ -0,0 +1,24 @@ + +procedure {:inline 1} foo() returns (x: bool) +{ + var b: bool; + if (b) { + x := false; + return; + } else { + x := true; + return; + } +} + +procedure main() +{ + var b1: bool; + var b2: bool; + + call b1 := foo(); + call b2 := foo(); + assert b1 == b2; +} + + diff --git a/Test/stratifiedinline/bar3.bpl b/Test/stratifiedinline/bar3.bpl new file mode 100644 index 00000000..7bd91184 --- /dev/null +++ b/Test/stratifiedinline/bar3.bpl @@ -0,0 +1,41 @@ +var y: int; +var x: int; + +procedure {:inline 1} bar(b: bool) +modifies y; +{ + if (b) { + y := y + 1; + } else { + y := y - 1; + } +} + +procedure {:inline 1} foo() +modifies x, y; +{ + var b: bool; + if (b) { + x := x + 1; + call bar(true); + call bar(true); + x := x + 1; + } else { + x := x - 1; + call bar(false); + call bar(false); + x := x - 1; + } +} + + +procedure main() +requires x == y; +ensures x == y; +modifies x, y; +modifies y; +{ + call foo(); + assert x == y; + call bar(false); +} diff --git a/Test/stratifiedinline/bar4.bpl b/Test/stratifiedinline/bar4.bpl new file mode 100644 index 00000000..84640811 --- /dev/null +++ b/Test/stratifiedinline/bar4.bpl @@ -0,0 +1,38 @@ +var y: int; +var x: int; + +procedure {:inline 1} bar() returns (b: bool) +modifies y; +{ + if (b) { + y := y + 1; + } else { + y := y - 1; + } +} + +procedure {:inline 1} foo() +modifies x, y; +{ + var b: bool; + + call b := bar(); + if (b) { + x := x + 1; + } else { + x := x - 1; + } +} + + +procedure main() returns (b: bool) +requires x == y; +ensures !b ==> x == y+1; +ensures b ==> x+1 == y; +modifies x, y; +modifies y; +{ + call foo(); + assert x == y; + call b := bar(); +} diff --git a/Test/stratifiedinline/bar6.bpl b/Test/stratifiedinline/bar6.bpl new file mode 100644 index 00000000..e133aef7 --- /dev/null +++ b/Test/stratifiedinline/bar6.bpl @@ -0,0 +1,36 @@ +var M: [int]int; + +procedure {:inline 1} bar(y: int) returns (b: bool) +modifies M; +{ + if (b) { + M[y] := M[y] + 1; + } else { + M[y] := M[y] - 1; + } +} + +procedure {:inline 1} foo(x: int, y: int) +modifies M; +{ + var b: bool; + + call b := bar(y); + if (b) { + M[x] := M[x] + 1; + } else { + M[x] := M[x] - 1; + } +} + +procedure main(x: int, y: int) returns (b: bool) +requires x != y; +requires M[x] == M[y]; +ensures !b ==> M[x] == M[y]+1; +ensures b ==> M[x]+1 == M[y]; +modifies M; +{ + call foo(x, y); + assert M[x] == M[y]; + call b := bar(y); +} diff --git a/Test/stratifiedinline/runtest.bat b/Test/stratifiedinline/runtest.bat new file mode 100644 index 00000000..194570d0 --- /dev/null +++ b/Test/stratifiedinline/runtest.bat @@ -0,0 +1,22 @@ +@echo off +setlocal + +set BGEXE=..\..\Binaries\Boogie.exe +rem set BGEXE=mono ..\..\Binaries\Boogie.exe + +echo ----- Running regression test bar1.bpl +%BGEXE% %* /noinfer /stratifiedInline:1 bar1.bpl +echo ----- +echo ----- Running regression test bar2.bpl +%BGEXE% %* /noinfer /stratifiedInline:1 bar2.bpl +echo ----- +echo ----- Running regression test bar3.bpl +%BGEXE% %* /noinfer /stratifiedInline:1 bar3.bpl +echo ----- +echo ----- Running regression test bar4.bpl +%BGEXE% %* /noinfer /stratifiedInline:1 bar4.bpl +echo ----- +echo ----- Running regression test bar6.bpl +%BGEXE% %* /noinfer /stratifiedInline:1 bar6.bpl +echo ----- + -- cgit v1.2.3