Skip to content

Commit

Permalink
Undo some concurrent changes
Browse files Browse the repository at this point in the history
  • Loading branch information
keyboardDrummer committed Oct 8, 2024
1 parent f22112e commit 86ed884
Showing 1 changed file with 50 additions and 60 deletions.
110 changes: 50 additions & 60 deletions Source/Concurrency/YieldingProcInstrumentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,71 +474,65 @@ private void DesugarConcurrency(Implementation impl, List<Cmd> preconditions)

// add jumps to noninterferenceChecker, returnChecker, and refinementChecker blocks
var implRefinementCheckingBlocks = new List<Block>();
foreach (var block in impl.Blocks) {
if (block.TransferCmd is not GotoCmd gotoCmd)
{
block.TransferCmd = new GotoCmd(block.TransferCmd.tok,
new List<Block> { returnCheckerBlock, returnBlock, noninterferenceCheckerBlock });
continue;
}

var targetBlocks = new List<Block>();
var addEdge = false;
foreach (var nextBlock in gotoCmd.LabelTargets)
foreach (var b in impl.Blocks)
{
if (b.TransferCmd is GotoCmd gotoCmd)
{
if (nextBlock.Cmds.Count <= 0)
var targetBlocks = new List<Block>();
var addEdge = false;
foreach (var nextBlock in gotoCmd.LabelTargets)
{
continue;
}

var cmd = nextBlock.Cmds[0];
if (cmd is not ParCallCmd parCallCmd)
{
continue;
if (nextBlock.cmds.Count > 0)

Check failure on line 485 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=True)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 485 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / LeanAuto CI

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 485 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=True)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 485 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=False)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 485 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=False)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)
{
var cmd = nextBlock.cmds[0];

Check failure on line 487 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=True)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 487 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / LeanAuto CI

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 487 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=True)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 487 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=False)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 487 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=False)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)
if (cmd is ParCallCmd parCallCmd)
{
foreach (var callCmd in parCallCmd.CallCmds)
{
if (refinementBlocks.ContainsKey(callCmd))
{
var targetBlock = refinementBlocks[callCmd];
FixUpImplRefinementCheckingBlock(targetBlock,
CivlAttributes.IsCallMarked(callCmd)
? returnCheckerBlock
: unchangedCheckerBlock);
targetBlocks.Add(targetBlock);
implRefinementCheckingBlocks.Add(targetBlock);
}
}
addEdge = true;
}
}
}

foreach (var callCmd in parCallCmd.CallCmds)
gotoCmd.AddTargets(targetBlocks);
if (addEdge)
{
if (!refinementBlocks.TryGetValue(callCmd, out var targetBlock))
AddEdge(gotoCmd, noninterferenceCheckerBlock);
if (blocksInYieldingLoops.Contains(b))
{
continue;
AddEdge(gotoCmd, unchangedCheckerBlock);
}
else
{
b.Cmds.AddRange(refinementInstrumentation.CreateActionEvaluationCmds());
AddEdge(gotoCmd, refinementCheckerBlock);
}

FixUpImplRefinementCheckingBlock(targetBlock,
CivlAttributes.IsCallMarked(callCmd)
? returnCheckerBlock
: unchangedCheckerBlock);
targetBlocks.Add(targetBlock);
implRefinementCheckingBlocks.Add(targetBlock);
}

addEdge = true;
}

gotoCmd.AddTargets(targetBlocks);
if (!addEdge)
{
continue;
}

AddEdge(gotoCmd, noninterferenceCheckerBlock);
if (blocksInYieldingLoops.Contains(block))
{
AddEdge(gotoCmd, unchangedCheckerBlock);
}
else
{
block.Cmds.AddRange(refinementInstrumentation.CreateActionEvaluationCmds());
AddEdge(gotoCmd, refinementCheckerBlock);
b.TransferCmd = new GotoCmd(b.TransferCmd.tok,
new List<Block> {returnCheckerBlock, returnBlock, noninterferenceCheckerBlock});
}
}

// desugar ParCallCmd
foreach (Block b in impl.Blocks)
{
if (b.Cmds.Count > 0)
if (b.cmds.Count > 0)

Check failure on line 533 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=True)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 533 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / LeanAuto CI

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 533 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=True)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 533 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=False)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 533 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=False)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)
{
var cmd = b.Cmds[0];
var cmd = b.cmds[0];

Check failure on line 535 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=True)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 535 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / LeanAuto CI

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 535 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=True)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 535 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=False)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 535 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=False)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)
if (cmd is ParCallCmd)
{
DesugarParCallCmdInBlock(b, blocksInYieldingLoops.Contains(b));
Expand All @@ -551,9 +545,7 @@ private void DesugarConcurrency(Implementation impl, List<Cmd> preconditions)
impl.Blocks.Add(unchangedCheckerBlock);
impl.Blocks.Add(returnCheckerBlock);
impl.Blocks.Add(returnBlock);
foreach (var block in implRefinementCheckingBlocks) {
impl.Blocks.Add(block);
}
impl.Blocks.AddRange(implRefinementCheckingBlocks);

Check failure on line 548 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=True)

'IList<Block>' does not contain a definition for 'AddRange' and no accessible extension method 'AddRange' accepting a first argument of type 'IList<Block>' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 548 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / LeanAuto CI

'IList<Block>' does not contain a definition for 'AddRange' and no accessible extension method 'AddRange' accepting a first argument of type 'IList<Block>' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 548 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=True)

'IList<Block>' does not contain a definition for 'AddRange' and no accessible extension method 'AddRange' accepting a first argument of type 'IList<Block>' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 548 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=False)

'IList<Block>' does not contain a definition for 'AddRange' and no accessible extension method 'AddRange' accepting a first argument of type 'IList<Block>' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 548 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=False)

'IList<Block>' does not contain a definition for 'AddRange' and no accessible extension method 'AddRange' accepting a first argument of type 'IList<Block>' could be found (are you missing a using directive or an assembly reference?)
impl.Blocks.Insert(0, CreateInitialBlock(impl, preconditions));
}

Expand Down Expand Up @@ -586,33 +578,31 @@ private void SplitBlocks(Implementation impl)
{
var currTransferCmd = b.TransferCmd;
int labelCount = 0;
int lastSplitIndex = b.Cmds.Count;
for (int i = b.Cmds.Count - 1; i >= 0; i--)
int lastSplitIndex = b.cmds.Count;

Check failure on line 581 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=True)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 581 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / LeanAuto CI

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 581 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=True)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 581 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=False)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 581 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=False)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)
for (int i = b.cmds.Count - 1; i >= 0; i--)

Check failure on line 582 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=True)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 582 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / LeanAuto CI

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 582 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=True)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 582 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=False)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 582 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=False)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)
{
var split = false;
var cmd = b.Cmds[i];
var cmd = b.cmds[i];

Check failure on line 585 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=True)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 585 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / LeanAuto CI

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 585 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=True)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 585 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=False)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 585 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=False)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)
if (cmd is ParCallCmd)
{
split = true;
}

if (split)
{
var newBlock = new Block(b.tok, $"{b.Label}_{labelCount++}", b.Cmds.GetRange(i, lastSplitIndex - i),
var newBlock = new Block(b.tok, $"{b.Label}_{labelCount++}", b.cmds.GetRange(i, lastSplitIndex - i),

Check failure on line 593 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=True)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 593 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / LeanAuto CI

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 593 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=True)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 593 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=False)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 593 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=False)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)
currTransferCmd);
newBlocks.Add(newBlock);
currTransferCmd = new GotoCmd(b.tok, new List<Block> {newBlock});
lastSplitIndex = i;
}
}

b.Cmds = b.Cmds.GetRange(0, lastSplitIndex);
b.cmds = b.cmds.GetRange(0, lastSplitIndex);

Check failure on line 601 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=True)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 601 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / LeanAuto CI

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 601 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=True)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 601 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Release, batch_mode=False)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 601 in Source/Concurrency/YieldingProcInstrumentation.cs

View workflow job for this annotation

GitHub Actions / Boogie CI (Debug, batch_mode=False)

'Block' does not contain a definition for 'cmds' and no accessible extension method 'cmds' accepting a first argument of type 'Block' could be found (are you missing a using directive or an assembly reference?)
b.TransferCmd = currTransferCmd;
}

foreach (var newBlock in newBlocks) {
impl.Blocks.Add(newBlock);
}
impl.Blocks.AddRange(newBlocks);
}

private Block CreateNoninterferenceCheckerBlock()
Expand Down Expand Up @@ -724,8 +714,8 @@ private void DesugarParCallCmdInBlock(Block block, bool isBlockInYieldingLoop)
newCmds.AddRange(CreateUpdatesToOldGlobalVars());
newCmds.AddRange(refinementInstrumentation.CreateUpdatesToOldOutputVars());
newCmds.AddRange(CreateUpdatesToPermissionCollector(parCallCmd));
newCmds.AddRange(block.Cmds.GetRange(1, block.Cmds.Count - 1));
block.Cmds = newCmds;
newCmds.AddRange(block.cmds.GetRange(1, block.cmds.Count - 1));
block.cmds = newCmds;
}

private Formal ParCallDesugarFormal(Variable v, int count, bool incoming)
Expand Down

0 comments on commit 86ed884

Please sign in to comment.