Skip to content

Commit 1aa0102

Browse files
committed
fixed loop bug
1 parent 557b63c commit 1aa0102

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

Source/Concurrency/YieldingProcChecker.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public static void AddCheckers(CivlTypeChecker civlTypeChecker, List<Declaration
3030
foreach (Implementation impl in program.Implementations.Where(impl => impl.Proc is YieldProcedureDecl).ToList())
3131
{
3232
var yieldProcedureDecl = (YieldProcedureDecl)impl.Proc;
33-
if (yieldProcedureDecl.Layer > layerNum || yieldProcedureDecl.Layer == layerNum && !yieldProcedureDecl.HasMoverType)
33+
if (yieldProcedureDecl.Layer > layerNum ||
34+
yieldProcedureDecl.Layer == layerNum && !yieldProcedureDecl.HasMoverType)
3435
{
3536
duplicator.VisitImplementation(impl);
3637
}

Source/Concurrency/YieldingProcDuplicator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ public override Block VisitBlock(Block node)
194194
public override Cmd VisitAssertCmd(AssertCmd node)
195195
{
196196
var assertCmd = (AssertCmd)base.VisitAssertCmd(node);
197-
bool insideLoopInvariantOfYieldingLoop = enclosingYieldingProc.YieldingLoops.ContainsKey(enclosingBlock) && inPredicatePhase;
198197
if (!node.Layers.Contains(layerNum))
199198
{
200199
assertCmd.Expr = Expr.True;
@@ -204,6 +203,7 @@ public override Cmd VisitAssertCmd(AssertCmd node)
204203
{
205204
return assertCmd;
206205
}
206+
bool insideLoopInvariantOfYieldingLoop = enclosingYieldingProc.IsYieldingLoopHeaderAtProcedureLayer(enclosingBlock) && inPredicatePhase;
207207
if (insideLoopInvariantOfYieldingLoop)
208208
{
209209
return doRefinementCheck ? new AssumeCmd(node.tok, assertCmd.Expr, node.Attributes) : assertCmd;

Source/Core/AST/Absy.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3432,7 +3432,7 @@ public List<CallCmd> DesugaredYieldEnsures
34323432
return desugaredYieldEnsures;
34333433
}
34343434
}
3435-
3435+
34363436
public bool IsYieldingLoopHeader(Block block, int layerNum)
34373437
{
34383438
if (!YieldingLoops.ContainsKey(block))
@@ -3441,6 +3441,11 @@ public bool IsYieldingLoopHeader(Block block, int layerNum)
34413441
}
34423442
return layerNum <= YieldingLoops[block].Layer;
34433443
}
3444+
3445+
public bool IsYieldingLoopHeaderAtProcedureLayer(Block block)
3446+
{
3447+
return IsYieldingLoopHeader(block, Layer);
3448+
}
34443449
}
34453450

34463451
public class LoopProcedure : Procedure

0 commit comments

Comments
 (0)