Skip to content

Commit

Permalink
Merge remote-tracking branch 'fork/isolatePaths' into isolatePathsNext
Browse files Browse the repository at this point in the history
  • Loading branch information
keyboardDrummer committed Oct 8, 2024
2 parents a438b56 + 6bff2ff commit 9206390
Show file tree
Hide file tree
Showing 23 changed files with 41 additions and 43 deletions.
6 changes: 4 additions & 2 deletions Source/Concurrency/CivlUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,16 @@ public static HavocCmd HavocCmd(params IdentifierExpr[] vars)

public static class BlockHelper
{
public static readonly IToken /*!*/ ReportedNoToken = new Token();

public static Block Block(string label, List<Cmd> cmds)
{
return new Block(Token.NoToken, label, cmds, CmdHelper.ReturnCmd);
return new Block(ReportedNoToken, label, cmds, CmdHelper.ReturnCmd);
}

public static Block Block(string label, List<Cmd> cmds, List<Block> gotoTargets)
{
return new Block(Token.NoToken, label, cmds, new GotoCmd(Token.NoToken, gotoTargets));
return new Block(ReportedNoToken, label, cmds, new GotoCmd(Token.NoToken, gotoTargets));
}
}

Expand Down
2 changes: 0 additions & 2 deletions Source/Core/AST/ICarriesAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ public List<int> FindLayers()
}
return layers.Distinct().OrderBy(l => l).ToList();
}


}

public static class QKeyValueExtensions {
Expand Down
3 changes: 1 addition & 2 deletions Source/Core/Token.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public string /*!*/

public Token next; // ML 2005-03-11 Tokens are kept in linked list

public static readonly IToken /*!*/
NoToken = new Token();
public static readonly IToken /*!*/ NoToken = new Token();

public Token()
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VariableDependenceAnalyser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ private Dictionary<Block, HashSet<Block>> ComputeGlobalControlDependences()
var indirectCallees = ComputeIndirectCallees(callGraph, directCallee);
foreach (var control in GetControllingBlocks(b, localCtrlDeps[impl]))
{
foreach (var c in indirectCallees.Select(Item => Item.Blocks).SelectMany(item => item))
foreach (var c in indirectCallees.Select(item => item.Blocks).SelectMany(item => item))
{
globalCtrlDep[control].Add(c);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- Target framework and package configuration -->
<PropertyGroup>
<Version>3.3.5</Version>
<Version>3.3.0</Version>
<TargetFramework>net6.0</TargetFramework>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Authors>Boogie</Authors>
Expand Down
2 changes: 0 additions & 2 deletions Source/VCGeneration/Counterexample/Counterexample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ public void Print(int indent, TextWriter tw, Action<Block> blockAction = null)
}
else {
// for ErrorTrace == 1 restrict the output;
// do not print tokens with -17:-4 as their location because they have been
// introduced in the translation and do not give any useful feedback to the user
if (Options.ErrorTrace == 1 && block.tok == Token.NoToken) {
continue;
}
Expand Down
6 changes: 6 additions & 0 deletions Source/VCGeneration/Splits/BlockRewriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,10 @@ public List<Block> ComputeNewBlocks(
BlockCoalescer.CoalesceInPlace(newBlocks);
return newBlocks;
}


public static bool ShouldIsolate(bool splitOnEveryAssert, QKeyValue? isolateAttribute)
{
return splitOnEveryAssert || isolateAttribute != null;
}
}
14 changes: 1 addition & 13 deletions Source/VCGeneration/Splits/IsolateAttributeOnAssertsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static (List<ManualSplit> IsolatedParts, ManualSplit Remainder) GetParts(
foreach (var assert in block.Cmds.OfType<AssertCmd>()) {
var attributes = assert.Attributes;
var isolateAttribute = QKeyValue.FindAttribute(attributes, p => p.Key == "isolate");
if (!ShouldIsolate(splitOnEveryAssert, isolateAttribute)) {
if (!BlockRewriter.ShouldIsolate(splitOnEveryAssert, isolateAttribute)) {
continue;
}

Expand Down Expand Up @@ -90,18 +90,6 @@ List<Cmd> GetCommands(Block block) => block.Cmds.Select(cmd =>
isolatedAssertions.Contains(cmd) ? rewriter.TransformAssertCmd(cmd) : cmd).ToList();
}
}

private static bool ShouldIsolate(bool splitOnEveryAssert, QKeyValue? isolateAttribute) {
if (splitOnEveryAssert) {
if (isolateAttribute == null) {
return true;
}

return !isolateAttribute.Params.OfType<string>().Any(p => Equals(p, "none"));
}

return isolateAttribute != null;
}
}


Expand Down
15 changes: 1 addition & 14 deletions Source/VCGeneration/Splits/IsolateAttributeOnJumpsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static (List<ManualSplit> Isolated, ManualSplit Remainder) GetParts(VCGen

var isTypeOfAssert = gotoCmd.tok is GotoFromReturn;
var isolateAttribute = QKeyValue.FindAttribute(gotoCmd.Attributes, p => p.Key == "isolate");
var isolate = ShouldIsolate(isTypeOfAssert && splitOnEveryAssert, isolateAttribute);
var isolate = BlockRewriter.ShouldIsolate(isTypeOfAssert && splitOnEveryAssert, isolateAttribute);
if (!isolate) {
continue;
}
Expand Down Expand Up @@ -62,7 +62,6 @@ public static (List<ManualSplit> Isolated, ManualSplit Remainder) GetParts(VCGen
return (results, GetPartWithoutIsolatedReturns());

ManualSplit GetPartWithoutIsolatedReturns() {
// TODO this needs an extra test. In case the isolated jump is followed by something it dominates
var newBlocks = rewriter.ComputeNewBlocks(blocks.ToHashSet(), (oldBlock, newBlock) => {
if (isolatedBlockJumps.Contains(oldBlock)) {
newBlock.TransferCmd = new ReturnCmd(Token.NoToken);
Expand All @@ -72,18 +71,6 @@ ManualSplit GetPartWithoutIsolatedReturns() {
newBlocks);
}
}

private static bool ShouldIsolate(bool splitOnEveryAssert, QKeyValue? isolateAttribute) {
if (splitOnEveryAssert) {
if (isolateAttribute == null) {
return true;
}

return !isolateAttribute.Params.OfType<string>().Any(p => Equals(p, "none"));
}

return isolateAttribute != null;
}
}


Expand Down
2 changes: 1 addition & 1 deletion Source/VCGeneration/Splits/Split.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private void PrintSplit() {
Thread.Sleep(100);
}

var prefix = (this is ManualSplit manualSplit) ? manualSplit.Token.ShortName : "";
var prefix = this is ManualSplit manualSplit ? manualSplit.Token.ShortName : "";
var name = Implementation.Name + prefix;
using var writer = printToConsole
? new TokenTextWriter("<console>", Options.OutputWriter, false, Options.PrettyPrint, Options)
Expand Down
10 changes: 5 additions & 5 deletions Source/VCGeneration/VerificationConditionGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1352,22 +1352,22 @@ public static Counterexample AssertCmdToCounterexample(VCGenOptions options, Ass
/// <summary>
/// Returns a clone of "cex", but with the location stored in "cex" replaced by those from "assrt".
/// </summary>
public static Counterexample AssertCmdToCloneCounterexample(VCGenOptions options, AssertCmd assrt,
public static Counterexample AssertCmdToCloneCounterexample(VCGenOptions options, AssertCmd assert,
Counterexample cex,
Block implEntryBlock)
{
Contract.Requires(assrt != null);
Contract.Requires(assert != null);
Contract.Requires(cex != null);
Contract.Requires(implEntryBlock != null);
Contract.Ensures(Contract.Result<Counterexample>() != null);

Counterexample cc;
if (assrt is AssertRequiresCmd assertRequiresCmd)
if (assert is AssertRequiresCmd assertRequiresCmd)
{
cc = new CallCounterexample(options, cex.Trace, cex.AugmentedTrace, assertRequiresCmd, cex.Model, cex.MvInfo, cex.Context,
cex.ProofRun, assertRequiresCmd.Checksum);
}
else if (assrt is AssertEnsuresCmd assertEnsuresCmd && cex is ReturnCounterexample returnCounterexample)
else if (assert is AssertEnsuresCmd assertEnsuresCmd && cex is ReturnCounterexample returnCounterexample)
{
// The first three parameters of ReturnCounterexample are: List<Block> trace, List<object> augmentedTrace, TransferCmd failingReturn, Ensures failingEnsures.
// We have the "aa" version of failingEnsures, namely aa.Ensures. The first and third parameters take more work to reconstruct.
Expand Down Expand Up @@ -1451,7 +1451,7 @@ public static Counterexample AssertCmdToCloneCounterexample(VCGenOptions options
}
else
{
cc = new AssertCounterexample(options, cex.Trace, cex.AugmentedTrace, assrt, cex.Model, cex.MvInfo, cex.Context,
cc = new AssertCounterexample(options, cex.Trace, cex.AugmentedTrace, assert, cex.Model, cex.MvInfo, cex.Context,
cex.ProofRun);
}

Expand Down
1 change: 1 addition & 0 deletions Test/civl/regression-tests/intro-nonblocking.bpl.expect
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
intro-nonblocking.bpl(4,13): Error: Cooperation check for intro failed
Execution trace:
(0,0): init

Boogie program verifier finished with 0 verified, 1 error
1 change: 1 addition & 0 deletions Test/civl/regression-tests/left-mover.bpl.expect
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ Execution trace:
left-mover.bpl(6,24): inline$inc$0$Return
left-mover.bpl(26,24): Error: Cooperation check for block failed
Execution trace:
(0,0): init

Boogie program verifier finished with 3 verified, 3 errors
1 change: 1 addition & 0 deletions Test/civl/regression-tests/non-interference-1.bpl.expect
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ non-interference-1.bpl(25,1): Error: Non-interference check failed
Execution trace:
non-interference-1.bpl(7,3): anon0
non-interference-1.bpl(12,5): inline$AtomicIncr$0$anon0
(0,0): inline$Civl_NoninterferenceChecker_yield_Yield$0$L

Boogie program verifier finished with 4 verified, 1 error
2 changes: 2 additions & 0 deletions Test/civl/regression-tests/non-interference-2.bpl.expect
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ non-interference-2.bpl(25,1): Error: Non-interference check failed
Execution trace:
non-interference-2.bpl(7,3): anon0
non-interference-2.bpl(12,5): inline$AtomicIncr$0$anon0
(0,0): inline$Civl_NoninterferenceChecker_yield_PC$0$L
non-interference-2.bpl(25,1): Error: Non-interference check failed
Execution trace:
non-interference-2.bpl(34,3): anon0
(0,0): inline$Civl_NoninterferenceChecker_yield_PC$0$L

Boogie program verifier finished with 2 verified, 2 errors
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pa-noninterference-check.bpl(26,1): Error: Non-interference check failed
Execution trace:
(0,0): init
pa-noninterference-check.bpl(19,7): inline$A_Incr$0$anon0
pa-noninterference-check.bpl(16,34): inline$A_Incr$0$Return

Expand Down
1 change: 1 addition & 0 deletions Test/civl/regression-tests/parallel1.bpl.expect
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ parallel1.bpl(25,1): Error: Non-interference check failed
Execution trace:
parallel1.bpl(7,3): anon0
parallel1.bpl(12,5): inline$AtomicIncr$0$anon0
(0,0): inline$Civl_NoninterferenceChecker_yield_Yield$0$L

Boogie program verifier finished with 3 verified, 1 error
1 change: 1 addition & 0 deletions Test/civl/regression-tests/parallel6.bpl.expect
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ Execution trace:
parallel6.bpl(11,5): anon0_0
parallel6.bpl(30,7): inline$atomic_incr$2$anon0
parallel6.bpl(30,7): inline$atomic_incr$3$anon0
(0,0): Civl_ReturnChecker

Boogie program verifier finished with 7 verified, 1 error
1 change: 1 addition & 0 deletions Test/civl/regression-tests/pending-async-1.bpl.expect
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Execution trace:
pending-async-1.bpl(51,3): anon0$1
pending-async-1.bpl(11,9): inline$B$1$anon0
pending-async-1.bpl(51,3): anon0$2
(0,0): Civl_ReturnChecker
pending-async-1.bpl(67,3): Error: Pending asyncs to action A created by this call are not summarized
Execution trace:
pending-async-1.bpl(67,3): anon0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pending-async-noninterference-fail.bpl(7,1): Error: Non-interference check failed
Execution trace:
(0,0): init
pending-async-noninterference-fail.bpl(12,5): inline$A$0$anon0
pending-async-noninterference-fail.bpl(9,32): inline$A$0$Return

Expand Down
5 changes: 5 additions & 0 deletions Test/civl/regression-tests/refinement.bpl.expect
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@ Execution trace:
refinement.bpl(10,3): anon0$1
refinement.bpl(10,3): anon0_0
refinement.bpl(58,5): inline$INCR$1$anon0
(0,0): Civl_ReturnChecker
refinement.bpl(15,28): Error: A yield-to-yield fragment modifies layer-2 state in a way that does not match the refined atomic action
Execution trace:
refinement.bpl(18,3): anon0
refinement.bpl(64,5): inline$DECR$0$anon0
refinement.bpl(18,3): anon0$1
(0,0): Civl_RefinementChecker
refinement.bpl(15,28): Error: A yield-to-yield fragment modifies layer-2 state subsequent to a yield-to-yield fragment that already modified layer-2 state
Execution trace:
refinement.bpl(18,3): anon0
refinement.bpl(64,5): inline$DECR$0$anon0
refinement.bpl(18,3): anon0$1
refinement.bpl(18,3): anon0_0
refinement.bpl(58,5): inline$INCR$0$anon0
(0,0): Civl_ReturnChecker
refinement.bpl(37,28): Error: On some path no yield-to-yield fragment matched the refined atomic action
Execution trace:
refinement.bpl(41,1): anon0
(0,0): Civl_ReturnChecker
refinement.bpl(43,28): Error: A yield-to-yield fragment illegally modifies layer-2 globals
Execution trace:
refinement.bpl(46,3): anon0
Expand All @@ -28,5 +32,6 @@ Execution trace:
refinement.bpl(46,3): anon0_0
refinement.bpl(48,3): anon2_LoopHead
refinement.bpl(58,5): inline$INCR$1$anon0
(0,0): Civl_UnchangedChecker

Boogie program verifier finished with 3 verified, 5 errors
4 changes: 4 additions & 0 deletions Test/civl/regression-tests/refinement2.bpl.expect
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
refinement2.bpl(13,28): Error: On some path no yield-to-yield fragment matched the refined atomic action
Execution trace:
refinement2.bpl(16,5): anon0
(0,0): Civl_call_refinement_4
refinement2.bpl(27,28): inline$atomic_nop$0$Return
(0,0): Civl_ReturnChecker
refinement2.bpl(13,28): Error: A yield-to-yield fragment illegally modifies layer-2 globals
Execution trace:
refinement2.bpl(16,5): anon0
(0,0): Civl_call_refinement_3
refinement2.bpl(22,7): inline$atomic_incr$0$anon0
refinement2.bpl(19,28): inline$atomic_incr$0$Return
(0,0): Civl_UnchangedChecker

Boogie program verifier finished with 1 verified, 2 errors
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ yield-invariant-fails.bpl(7,1): Error: Non-interference check failed
Execution trace:
yield-invariant-fails.bpl(11,5): anon0
yield-invariant-fails.bpl(19,7): inline$atomic_A$0$anon0
(0,0): inline$Civl_NoninterferenceChecker_yield_Inv$0$L

Boogie program verifier finished with 0 verified, 1 error

0 comments on commit 9206390

Please sign in to comment.