diff --git a/Source/Boogie-NetCore.sln b/Source/Boogie-NetCore.sln
index f40ada657..c51fd2333 100644
--- a/Source/Boogie-NetCore.sln
+++ b/Source/Boogie-NetCore.sln
@@ -31,8 +31,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Houdini-NetCore", "Houdini\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Predication-NetCore", "Predication\Predication-NetCore.csproj", "{7A4B3721-D902-4265-94DB-CA8B0BB295B7}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Doomed-NetCore", "Doomed\Doomed-NetCore.csproj", "{CE190976-D727-4038-8D8A-8C5579E48CCF}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExecutionEngine-NetCore", "ExecutionEngine\ExecutionEngine-NetCore.csproj", "{51768B2E-FFF9-49F0-96D7-022250A4BEB4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Concurrency-NetCore", "Concurrency\Concurrency-NetCore.csproj", "{4AC86856-E985-4DBC-B089-20D5B9317A99}"
diff --git a/Source/Boogie.sln b/Source/Boogie.sln
index 85a084c22..0ba695c5b 100644
--- a/Source/Boogie.sln
+++ b/Source/Boogie.sln
@@ -36,8 +36,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Houdini", "Houdini\Houdini.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Predication", "Predication\Predication.csproj", "{AFAA5CE1-C41B-44F0-88F8-FD8A43826D44}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Doomed", "Doomed\Doomed.csproj", "{884386A3-58E9-40BB-A273-B24976775553}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExecutionEngine", "ExecutionEngine\ExecutionEngine.csproj", "{EAA5EB79-D475-4601-A59B-825C191CD25F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BVD", "BVD\BVD.csproj", "{8A05D14E-F2BF-4890-BBE0-D76B18A50797}"
diff --git a/Source/BoogieDriver/BoogieDriver-NetCore.csproj b/Source/BoogieDriver/BoogieDriver-NetCore.csproj
index 9414572dd..8a121f235 100644
--- a/Source/BoogieDriver/BoogieDriver-NetCore.csproj
+++ b/Source/BoogieDriver/BoogieDriver-NetCore.csproj
@@ -22,7 +22,6 @@
-
diff --git a/Source/BoogieDriver/BoogieDriver.csproj b/Source/BoogieDriver/BoogieDriver.csproj
index 52a3bd0d4..ef32db776 100644
--- a/Source/BoogieDriver/BoogieDriver.csproj
+++ b/Source/BoogieDriver/BoogieDriver.csproj
@@ -214,10 +214,6 @@
{B230A69C-C466-4065-B9C1-84D80E76D802}
Core
-
- {884386A3-58E9-40BB-A273-B24976775553}
- Doomed
-
{EAA5EB79-D475-4601-A59B-825C191CD25F}
ExecutionEngine
diff --git a/Source/Core/CommandLineOptions.cs b/Source/Core/CommandLineOptions.cs
index 4ed6044b7..6775d20ce 100644
--- a/Source/Core/CommandLineOptions.cs
+++ b/Source/Core/CommandLineOptions.cs
@@ -305,7 +305,7 @@ public virtual void AttributeUsage() {
///
public virtual void ApplyDefaultOptions() {
}
-
+
///
/// Parses the command-line arguments "args" into the global flag variables. Returns true
/// if there were no errors.
@@ -413,14 +413,12 @@ void ObjectInvariant2() {
public string PrintFile = null;
public int PrintUnstructured = 0;
public bool UseBaseNameForFileName = false;
- public int DoomStrategy = -1;
- public bool DoomRestartTP = false;
public bool PrintDesugarings = false;
public bool PrintLambdaLifting = false;
public bool FreeVarLambdaLifting = false;
public string ProverLogFilePath = null;
public bool ProverLogFileAppend = false;
-
+
public bool PrintInstrumented = false;
public bool InstrumentWithAsserts = false;
public string ProverPreamble = null;
@@ -564,7 +562,6 @@ public enum OwnershipModelOption {
public bool ForceBplErrors = false; // if true, boogie error is shown even if "msg" attribute is present
public bool UseArrayTheory = false;
public bool WeakArrayTheory = false;
- public bool UseLabels = true;
public bool RunDiagnosticsOnTimeout = false;
public bool TraceDiagnosticsOnTimeout = false;
public int TimeLimitPerAssertionInPercent = 10;
@@ -599,20 +596,6 @@ public int StepsBeforeWidening
public int TrustLayersUpto = -1;
public int TrustLayersDownto = int.MaxValue;
- public enum VCVariety {
- Structured,
- Block,
- Local,
- BlockNested,
- BlockReach,
- BlockNestedReach,
- Dag,
- DagIterative,
- Doomed,
- Unspecified
- }
- public VCVariety vcVariety = VCVariety.Unspecified; // will not be Unspecified after command line has been parsed
-
public bool RemoveEmptyBlocks = true;
public bool CoalesceBlocks = true;
public bool PruneInfeasibleEdges = true;
@@ -737,7 +720,7 @@ public enum Inlining {
public int StratifiedInliningVerbose = 0; // verbosity level
public int RecursionBound = 500;
public bool NonUniformUnfolding = false;
- public int StackDepthBound = 0;
+ public int StackDepthBound = 0;
public string inferLeastForUnsat = null;
// Inference mode for fixed point engine
@@ -749,11 +732,11 @@ public enum FixedPointInferenceMode {
Call
};
public FixedPointInferenceMode FixedPointMode = FixedPointInferenceMode.Procedure;
-
+
public string PrintFixedPoint = null;
public string PrintConjectures = null;
-
+
public bool ExtractLoopsUnrollIrreducible = true; // unroll irreducible loops? (set programmatically)
public enum TypeEncoding {
@@ -789,7 +772,7 @@ public IEnumerable ProcsToCheck {
}
private List procsToCheck = null; // null means "no restriction"
-
+
[ContractInvariantMethod]
void ObjectInvariant5() {
Contract.Invariant(cce.NonNullElements(this.procsToCheck, true));
@@ -890,7 +873,7 @@ protected override bool ParseOption(string name, CommandLineOptionEngine.Command
int val = 1;
if (ps.GetNumericArgument(ref val, 2)) {
PrettyPrint = val == 1;
- }
+ }
return true;
case "CivlDesugaredFile":
@@ -919,13 +902,13 @@ protected override bool ParseOption(string name, CommandLineOptionEngine.Command
}
return true;
- case "proverPreamble":
+ case "proverPreamble":
if (ps.ConfirmArgumentCount(1))
{
ProverPreamble = args[ps.i];
}
return true;
-
+
case "logPrefix":
if (ps.ConfirmArgumentCount(1)) {
string s = cce.NonNull(args[ps.i]);
@@ -1152,47 +1135,6 @@ protected override bool ParseOption(string name, CommandLineOptionEngine.Command
}
return true;
}
- case "vc":
- if (ps.ConfirmArgumentCount(1)) {
- switch (args[ps.i]) {
- case "s":
- case "structured":
- vcVariety = VCVariety.Structured;
- break;
- case "b":
- case "block":
- vcVariety = VCVariety.Block;
- break;
- case "l":
- case "local":
- vcVariety = VCVariety.Local;
- break;
- case "n":
- case "nested":
- vcVariety = VCVariety.BlockNested;
- break;
- case "m":
- vcVariety = VCVariety.BlockNestedReach;
- break;
- case "r":
- vcVariety = VCVariety.BlockReach;
- break;
- case "d":
- case "dag":
- vcVariety = VCVariety.Dag;
- break;
- case "i":
- vcVariety = VCVariety.DagIterative;
- break;
- case "doomed":
- vcVariety = VCVariety.Doomed;
- break;
- default:
- ps.Error("Invalid argument \"{0}\" to option {1}", args[ps.i], ps.s);
- break;
- }
- }
- return true;
case "proverDll":
if (ps.ConfirmArgumentCount(1)) {
@@ -1207,28 +1149,18 @@ protected override bool ParseOption(string name, CommandLineOptionEngine.Command
ProverOptions = ProverOptions.Concat1(cce.NonNull(args[ps.i]));
}
return true;
-
+
case "proverHelp":
if (ps.ConfirmArgumentCount(0)) {
ProverHelpRequested = true;
}
return true;
- case "DoomStrategy":
- ps.GetNumericArgument(ref DoomStrategy);
- return true;
-
- case "DoomRestartTP":
- if (ps.ConfirmArgumentCount(0)) {
- DoomRestartTP = true;
- }
- return true;
-
case "extractLoops":
if (ps.ConfirmArgumentCount(0)) {
ExtractLoops = true;
}
- return true;
+ return true;
case "deterministicExtractLoops":
if (ps.ConfirmArgumentCount(0)) {
@@ -1502,7 +1434,7 @@ protected override bool ParseOption(string name, CommandLineOptionEngine.Command
case "traceCaching":
ps.GetNumericArgument(ref TraceCaching, 4);
return true;
-
+
case "platform":
if (ps.ConfirmArgumentCount(1)) {
StringCollection platformOptions = this.ParseNamedArgumentList(args[ps.i]);
@@ -1563,9 +1495,8 @@ protected override bool ParseOption(string name, CommandLineOptionEngine.Command
ps.CheckBooleanFlag("reflectAdd", ref ReflectAdd) ||
ps.CheckBooleanFlag("monomorphize", ref Monomorphize) ||
ps.CheckBooleanFlag("useArrayTheory", ref UseArrayTheory) ||
- ps.CheckBooleanFlag("weakArrayTheory", ref WeakArrayTheory) ||
+ ps.CheckBooleanFlag("weakArrayTheory", ref WeakArrayTheory) ||
ps.CheckBooleanFlag("doModSetAnalysis", ref DoModSetAnalysis) ||
- ps.CheckBooleanFlag("doNotUseLabels", ref UseLabels, false) ||
ps.CheckBooleanFlag("runDiagnosticsOnTimeout", ref RunDiagnosticsOnTimeout) ||
ps.CheckBooleanFlag("traceDiagnosticsOnTimeout", ref TraceDiagnosticsOnTimeout) ||
ps.CheckBooleanFlag("boolControlVC", ref SIBoolControlVC, true) ||
@@ -1597,7 +1528,6 @@ protected override bool ParseOption(string name, CommandLineOptionEngine.Command
public override void ApplyDefaultOptions() {
Contract.Ensures(TheProverFactory != null);
- Contract.Ensures(vcVariety != VCVariety.Unspecified);
base.ApplyDefaultOptions();
@@ -1617,17 +1547,8 @@ public override void ApplyDefaultOptions() {
TheProverFactory = ProverFactory.Load(ProverDllName);
}
- var proverOpts = TheProverFactory.BlankProverOptions();
- proverOpts.Parse(ProverOptions);
if (ProverHelpRequested) {
- Console.WriteLine(proverOpts.Help);
- }
- if (!TheProverFactory.SupportsLabels(proverOpts)) {
- UseLabels = false;
- }
-
- if (vcVariety == VCVariety.Unspecified) {
- vcVariety = TheProverFactory.DefaultVCVariety;
+ Console.WriteLine(TheProverFactory.BlankProverOptions().Help);
}
if (UseArrayTheory) {
@@ -1853,7 +1774,7 @@ identifies variables
expressions into templates with holes. By default, holes
are maximally large subexpressions that do not contain
bound variables. This option performs a form of lambda
- lifting in which holes are the lambda's free variables.
+ lifting in which holes are the lambda's free variables.
/overlookTypeErrors : skip any implementation with resolution or type
checking errors
@@ -1961,7 +1882,7 @@ verify several program snapshots (named .v0.bpl
3 - use the more advanced caching and report errors according
to the new source locations for errors and their
related locations (but not /errorTrace and CaptureState
- locations)
+ locations)
/traceCaching:
0 (default) - none
1 - for testing
@@ -1975,12 +1896,6 @@ verify each input program separately
/coalesceBlocks:
0 = do not coalesce blocks
1 = coalesce blocks (default)
- /vc: n = nested block,
- m = nested block reach,
- b = flat block, r = flat block reach,
- s = structured, l = local,
- d = dag (default)
- doomed = doomed
/traceverify print debug output during verification condition generation
/subsumption:
apply subsumption to asserted conditions:
@@ -2025,7 +1940,7 @@ how to encode types when sending VC to theorem prover
p = predicates (default)
a = arguments
m = monomorphic
- /monomorphize
+ /monomorphize
Do not abstract map types in the encoding (this is an
experimental feature that will not do the right thing if
the program uses polymorphism)
@@ -2065,7 +1980,7 @@ assertion in the keep going mode. Defaults to 30s.
/vcsPathCostMult:
/vcsAssumeMult:
The cost of a block is
- ( + *) *
+ ( + *) *
(1.0 + *)
defaults to 1.0, defaults to 0.01.
The cost of a single assertion or assumption is
diff --git a/Source/Core/VCExp.cs b/Source/Core/VCExp.cs
index 210fb24e7..1a74ef04c 100644
--- a/Source/Core/VCExp.cs
+++ b/Source/Core/VCExp.cs
@@ -254,17 +254,6 @@ public virtual bool SupportsDags {
}
}
- public virtual CommandLineOptions.VCVariety DefaultVCVariety {
- get {
- Contract.Ensures(Contract.Result() != CommandLineOptions.VCVariety.Unspecified);
- return CommandLineOptions.VCVariety.DagIterative;
- }
- }
-
- public virtual bool SupportsLabels(ProverOptions options) {
- return true;
- }
-
public virtual void Close() {
}
diff --git a/Source/Doomed/DoomCheck.cs b/Source/Doomed/DoomCheck.cs
deleted file mode 100644
index c1d6736fd..000000000
--- a/Source/Doomed/DoomCheck.cs
+++ /dev/null
@@ -1,407 +0,0 @@
-//-----------------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
-//
-//-----------------------------------------------------------------------------
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Threading;
-using System.IO;
-using Microsoft.Boogie;
-using Microsoft.Boogie.GraphUtil;
-using System.Diagnostics.Contracts;
-using Microsoft.Basetypes;
-using Microsoft.Boogie.VCExprAST;
-
-namespace VC
-{
- internal class Evc {
-
- public DoomErrorHandler ErrorHandler {
- set {
- m_ErrorHandler = value;
- }
- }
-
- [ContractInvariantMethod]
-void ObjectInvariant()
-{
- Contract.Invariant(m_Checker!=null);
-}
-
- private Checker m_Checker;
- private DoomErrorHandler m_ErrorHandler;
-
- [NotDelayed]
- public Evc(Checker check) {
- Contract.Requires(check != null);
- m_Checker = check;
-
- }
-
- public void Initialize(VCExpr evc) {
- Contract.Requires(evc != null);
- m_Checker.PushVCExpr(evc);
- }
-
-
- public bool CheckReachvar(List lv,Dictionary finalreachvars,
- int k, int l, bool usenew , out ProverInterface.Outcome outcome) {
- Contract.Requires(lv != null);
-
- VCExpr vc = VCExpressionGenerator.False;
- if (usenew )
- {
- foreach (Variable v in lv)
- {
-
- vc = m_Checker.VCExprGen.Or(
- m_Checker.VCExprGen.Neq(
- m_Checker.VCExprGen.Integer(BigNum.ZERO),
- m_Checker.TheoremProver.Context.BoogieExprTranslator.LookupVariable(v)),
- vc);
- }
- //Console.WriteLine("TPQuery k={0}, l={1}, |Sp|={2}", k, l, finalreachvars.Count);
-
- VCExpr vc21 = m_Checker.VCExprGen.Integer(BigNum.ZERO); // Ask: is the necessary or can we use the same instance term in two inequalities?
- VCExpr vc22 = m_Checker.VCExprGen.Integer(BigNum.ZERO);
-
- foreach (KeyValuePair kvp in finalreachvars)
- {
-
- vc21 = m_Checker.VCExprGen.Add(vc21, m_Checker.TheoremProver.Context.BoogieExprTranslator.Translate(kvp.Key));
- vc22 = m_Checker.VCExprGen.Add(vc22, m_Checker.TheoremProver.Context.BoogieExprTranslator.Translate(kvp.Key));
- }
-
- VCExpr post = m_Checker.VCExprGen.Gt(m_Checker.VCExprGen.Integer(BigNum.FromInt(l)), vc21);
-
- if (k != -1)
- {
- post = m_Checker.VCExprGen.Or(
- post, m_Checker.VCExprGen.Gt(vc22, m_Checker.VCExprGen.Integer(BigNum.FromInt(k)))
- );
- }
- vc = (m_Checker.VCExprGen.Or(vc, (post) ));
-
- }
- else
- {
-
- foreach (Variable v in lv)
- {
-
- vc = m_Checker.VCExprGen.Or(
- m_Checker.VCExprGen.Eq(
- m_Checker.VCExprGen.Integer(BigNum.ONE),
- m_Checker.TheoremProver.Context.BoogieExprTranslator.LookupVariable(v)),
- vc);
- }
- Contract.Assert(vc != null);
-
- // Add the desired outcome of the reachability variables
- foreach (KeyValuePair kvp in finalreachvars)
- {
- vc = m_Checker.VCExprGen.Or(
- m_Checker.VCExprGen.Neq(
- m_Checker.VCExprGen.Integer(BigNum.FromInt(kvp.Value)),
- m_Checker.TheoremProver.Context.BoogieExprTranslator.Translate(kvp.Key)),
- vc);
- }
-
- }
-
- // Todo: Check if vc is trivial true or false
- outcome = ProverInterface.Outcome.Undetermined;
- Contract.Assert(m_ErrorHandler != null);
- try
- {
- m_Checker.BeginCheck(lv[0].Name, vc, m_ErrorHandler);
- m_Checker.ProverTask.Wait();
- outcome = m_Checker.ReadOutcome();
- }
- catch (UnexpectedProverOutputException e)
- {
- if (CommandLineOptions.Clo.TraceVerify)
- {
- Console.WriteLine("Prover is unable to check {0}! Reason:", lv[0].Name);
- Console.WriteLine(e.ToString());
- }
- return false;
- }
- finally
- {
- m_Checker.GoBackToIdle();
- }
- return true;
- }
- }
-
- internal class DoomCheck {
-
- [ContractInvariantMethod]
- void ObjectInvariant()
- {
- Contract.Invariant(Label2Absy!=null);
- Contract.Invariant(m_Check != null);
- Contract.Invariant(m_Evc != null);
- Contract.Invariant(m_Order != null);
- }
-
- #region Attributes
- public Dictionary Label2Absy;
- public DoomErrorHandler ErrorHandler {
- set {
- m_ErrHandler = value;
- m_Evc.ErrorHandler = value;
- }
-
- get {
- return m_ErrHandler;
- }
- }
-
- private DoomErrorHandler m_ErrHandler;
- private Checker m_Check;
- private DoomDetectionStrategy m_Order;
- private Evc m_Evc;
- #endregion
-
- public void __DEBUG_PrintStatistics()
- {
- Console.WriteLine("Checked/Total: Bl {0} / {1} EQ {2} / {3} {4} Tr {5} {6} / {7}", m_Order.__DEBUG_BlocksChecked, m_Order.__DEBUG_BlocksTotal, m_Order.__DEBUG_EQCChecked, m_Order.__DEBUG_EQCTotal, m_Order.__DEBUG_EQCLeaf, m_Order.__DEBUG_TracesChecked, m_Order.__DEBUG_InfeasibleTraces, m_Order.__DEBUG_TracesTotal);
- }
-
- [NotDelayed]
- public DoomCheck (Implementation passive_impl, Block unifiedExit, Checker check, List uncheckable, out int assertionCount) {
- Contract.Requires(passive_impl != null);
- Contract.Requires(check != null);
- Contract.Requires(uncheckable != null);
- m_Check = check;
-
- int replaceThisByCmdLineOption = CommandLineOptions.Clo.DoomStrategy ;
- if (CommandLineOptions.Clo.DoomStrategy!=-1) Console.Write("Running experiments using {0} /", replaceThisByCmdLineOption);
- switch (replaceThisByCmdLineOption)
- {
- default:
- {
- if (CommandLineOptions.Clo.DoomStrategy != -1) Console.WriteLine("Path Cover specialK Strategy");
- m_Order = new PathCoverStrategyK(passive_impl, unifiedExit, uncheckable);
- break;
- }
- case 1:
- {
- if (CommandLineOptions.Clo.DoomStrategy != -1) Console.WriteLine("Path Cover L Strategy");
- m_Order = new PathCoverStrategy(passive_impl, unifiedExit, uncheckable);
- break;
- }
- case 2:
- {
- if (CommandLineOptions.Clo.DoomStrategy != -1) Console.WriteLine("hasse strategy");
- m_Order = new HierachyStrategy(passive_impl, unifiedExit, uncheckable);
-
- break;
- }
- case 3:
- {
- if (CommandLineOptions.Clo.DoomStrategy != -1) Console.WriteLine("hasse+ce strategy");
- m_Order = new HierachyCEStrategy(passive_impl, unifiedExit, uncheckable);
- break;
- }
- case 4:
- {
- if (CommandLineOptions.Clo.DoomStrategy != -1) Console.WriteLine("no strategy");
- m_Order = new NoStrategy(passive_impl, unifiedExit, uncheckable);
- break;
- }
-
- }
-
- Label2Absy = new Dictionary(); // This is only a dummy
- m_Evc = new Evc(check);
- Dictionary l2a = null;
- VCExpr vce = this.GenerateEVC(passive_impl, out l2a, check, out assertionCount);
- Contract.Assert(vce != null);
- Contract.Assert( l2a!=null);
- Label2Absy = l2a;
-
- m_Evc.Initialize(vce);
- }
-
-
- public void RespawnChecker(Implementation passive_impl, Checker check)
- {
- Contract.Requires(check != null);
- m_Check = check;
- Label2Absy = new Dictionary(); // This is only a dummy
- m_Evc = new Evc(check);
- Dictionary l2a = null;
- int assertionCount; // compute and then ignore
- VCExpr vce = this.GenerateEVC(passive_impl, out l2a, check, out assertionCount);
- Contract.Assert(vce != null);
- Contract.Assert(l2a != null);
- Label2Absy = l2a;
-
- m_Evc.Initialize(vce);
- }
-
- /* - Set b to the next block that needs to be checked.
- - Returns false and set b to null if all blocks are checked.
- - Has to be alternated with CheckLabel; might crash otherwise
- */
- public bool GetNextBlock(out List lb)
- {
- return m_Order.GetNextBlock(out lb);
- }
-
- public Stopwatch DEBUG_ProverTime = new Stopwatch();
-
- /* - Checking a label means to ask the prover if |= ( rvar=false -> vc ) holds.
- - outcome is set to Outcome.Invalid if the Block denoted by reachvar is doomed.
- - returns false if the theorem prover throws an exception, otherwise true.
- */
- public bool CheckLabel(List lv,Dictionary finalreachvars, out ProverInterface.Outcome outcome) {
- Contract.Requires(lv != null);
- outcome = ProverInterface.Outcome.Undetermined;
- DEBUG_ProverTime.Reset();
- DEBUG_ProverTime.Start();
- if (m_Evc.CheckReachvar(lv,finalreachvars,m_Order.MaxBlocks,m_Order.MinBlocks,m_Order.HACK_NewCheck, out outcome) ) {
- DEBUG_ProverTime.Stop();
- if (!m_Order.SetCurrentResult(lv, outcome, m_ErrHandler)) {
- outcome = ProverInterface.Outcome.Undetermined;
- }
- return true;
- } else {
- DEBUG_ProverTime.Stop();
- Console.WriteLine(outcome);
- m_Order.SetCurrentResult(lv, ProverInterface.Outcome.Undetermined, m_ErrHandler);
- return false;
- }
- }
-
- public List!>!*/>> DoomedSequences {
- get {
- Contract.Ensures(Contract.ForAll(Contract.Result>>(), i=> cce.NonNullElements(i)));
-
- return m_Order.DetectedBlock;
- }
- }
-
-
- #region Error Verification Condition Generation
- /*
- #region _TESTING_NEW_STUFF_
- CommandLineOptions.Clo.vcVariety = CommandLineOptions.VCVariety.Block;
- //VCExpr wp = Wlp.Block(block, SuccCorrect, context); // Computes wp.S.true
-
- CommandLineOptions.Clo.vcVariety = CommandLineOptions.VCVariety.Doomed;
- #endregion
-
- */
-
- VCExpr GenerateEVC(Implementation impl, out Dictionary label2absy, Checker ch, out int assertionCount) {
- Contract.Requires(impl != null);
- Contract.Requires(ch != null);
- Contract.Ensures(Contract.Result() != null);
-
- TypecheckingContext tc = new TypecheckingContext(null);
- impl.Typecheck(tc);
- label2absy = new Dictionary();
- VCExpr vc;
- switch (CommandLineOptions.Clo.vcVariety) {
- case CommandLineOptions.VCVariety.Doomed:
- vc = LetVC(cce.NonNull(impl.Blocks[0]), label2absy, ch.TheoremProver.Context, out assertionCount);
- break;
-
- default:
- Contract.Assert(false); throw new cce.UnreachableException(); // unexpected enumeration value
- }
- return vc;
- }
-
- public VCExpr LetVC(Block startBlock,
- Dictionary label2absy,
- ProverContext proverCtxt,
- out int assertionCount)
- {
- Contract.Requires(startBlock != null);
- Contract.Requires(label2absy != null);
- Contract.Requires(proverCtxt != null);
- Contract.Ensures(Contract.Result() != null);
-
- Hashtable/**/ blockVariables = new Hashtable/**/();
- List bindings = new List();
- VCExpr startCorrect = LetVC(startBlock, label2absy, blockVariables, bindings, proverCtxt, out assertionCount);
- if (CommandLineOptions.Clo.vcVariety == CommandLineOptions.VCVariety.Doomed) {
- return proverCtxt.ExprGen.Let(bindings, proverCtxt.ExprGen.Not(startCorrect) );
- } else {
- return proverCtxt.ExprGen.Let(bindings, startCorrect );
- }
- }
-
- VCExpr LetVC(Block block,
- Dictionary label2absy,
- Hashtable/**/ blockVariables,
- List bindings,
- ProverContext proverCtxt,
- out int assertionCount)
- {
- Contract.Requires(label2absy != null);
- Contract.Requires(blockVariables != null);
- Contract.Requires(proverCtxt != null);
- Contract.Requires(cce.NonNullElements(bindings));
- Contract.Ensures(Contract.Result() != null);
-
- assertionCount = 0;
- VCExpressionGenerator gen = proverCtxt.ExprGen;
- Contract.Assert(gen != null);
- VCExprVar v = (VCExprVar)blockVariables[block];
- if (v == null) {
- /*
- * For block A (= block), generate:
- * LET_binding A_correct = wp(A_body, (/\ S \in Successors(A) :: S_correct))
- * with the side effect of adding the let bindings to "bindings" for any
- * successor not yet visited.
- */
- VCExpr SuccCorrect;
- GotoCmd gotocmd = block.TransferCmd as GotoCmd;
- if (gotocmd == null) {
- if (CommandLineOptions.Clo.vcVariety == CommandLineOptions.VCVariety.Doomed) {
- SuccCorrect = VCExpressionGenerator.False;
- } else {
- SuccCorrect = VCExpressionGenerator.True;
- }
- } else {
- Contract.Assert( gotocmd.labelTargets != null);
- List SuccCorrectVars = new List(gotocmd.labelTargets.Count);
- foreach (Block successor in gotocmd.labelTargets) {
- Contract.Assert(successor != null);
- int ac;
- VCExpr s = LetVC(successor, label2absy, blockVariables, bindings, proverCtxt, out ac);
- assertionCount += ac;
- SuccCorrectVars.Add(s);
- }
- SuccCorrect = gen.NAry(VCExpressionGenerator.AndOp, SuccCorrectVars);
- }
-
- VCContext context = new VCContext(label2absy, proverCtxt);
- // m_Context = context;
-
- VCExpr vc = Wlp.Block(block, SuccCorrect, context);
- assertionCount += context.AssertionCount;
- v = gen.Variable(block.Label + "_correct", Microsoft.Boogie.Type.Bool);
-
- bindings.Add(gen.LetBinding(v, vc));
- blockVariables.Add(block, v);
- }
- return v;
- }
-
-
- #endregion
-
- }
-
-}
diff --git a/Source/Doomed/DoomErrorHandler.cs b/Source/Doomed/DoomErrorHandler.cs
deleted file mode 100644
index ce14ff73f..000000000
--- a/Source/Doomed/DoomErrorHandler.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Threading;
-using System.IO;
-using Microsoft.Boogie;
-using Microsoft.Boogie.GraphUtil;
-using System.Diagnostics.Contracts;
-using Microsoft.Basetypes;
-using Microsoft.Boogie.VCExprAST;
-
-namespace VC
-{
- internal class DoomErrorHandler : ProverInterface.ErrorHandler
- {
-
- protected Dictionary label2Absy;
- protected VerifierCallback callback;
- private List m_CurrentTrace = new List();
-
- [ContractInvariantMethod]
- void ObjectInvariant()
- {
- Contract.Invariant(label2Absy != null);
- Contract.Invariant(callback != null);
- Contract.Invariant(cce.NonNullElements(m_CurrentTrace));
- }
-
-
- public DoomErrorHandler(Dictionary label2Absy, VerifierCallback callback)
- {
- Contract.Requires(label2Absy != null);
- Contract.Requires(callback != null);
- this.label2Absy = label2Absy;
- this.callback = callback;
- }
-
- public override Absy Label2Absy(string label)
- {
- //Contract.Requires(label != null);
- Contract.Ensures(Contract.Result() != null);
-
- int id = int.Parse(label);
- return cce.NonNull((Absy)label2Absy[id]);
- }
-
- public override void OnProverWarning(string msg)
- {
- //Contract.Requires(msg != null);
- this.callback.OnWarning(msg);
- }
-
-
- public List/*!>!*/ TraceNodes
- {
- get
- {
- Contract.Ensures(cce.NonNullElements(Contract.Result>()));
-
- return m_CurrentTrace;
- }
- }
-
- public override void OnModel(IList/*!>!*/ labels, Model model, ProverInterface.Outcome proverOutcome)
- {
- // TODO: it would be better to check which reachability variables are actually set to one!
- List traceNodes = new List();
- List assertNodes = new List();
- foreach (string s in labels)
- {
- Contract.Assert(s != null);
- Absy node = Label2Absy(s);
- if (node is Block)
- {
- Block b = (Block)node;
- traceNodes.Add(b);
- //Console.Write("{0}, ", b.Label);
- }
- }
- m_CurrentTrace.AddRange(traceNodes);
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/Source/Doomed/Doomed-NetCore.csproj b/Source/Doomed/Doomed-NetCore.csproj
deleted file mode 100644
index b1366ab7f..000000000
--- a/Source/Doomed/Doomed-NetCore.csproj
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
- Library
- BoogieDoomed
- netcoreapp3.1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- runtime; build; native; contentfiles; analyzers
- all
-
-
-
-
diff --git a/Source/Doomed/Doomed.csproj b/Source/Doomed/Doomed.csproj
deleted file mode 100644
index eefe8e069..000000000
--- a/Source/Doomed/Doomed.csproj
+++ /dev/null
@@ -1,186 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {884386A3-58E9-40BB-A273-B24976775553}
- Library
- Properties
- Doomed
- BoogieDoomed
- v4.5
- 512
-
- 12.0.0
- 2.0
- 0
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- False
- False
- True
- False
- False
- False
- True
- True
- True
- True
- True
- True
- True
- True
- False
- True
- False
- True
- False
- False
- False
- False
- True
- False
- True
- True
- True
- False
- False
-
-
-
-
-
-
-
- True
- False
- False
- True
- Full
- DoNotBuild
- 0
- false
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
- False
- False
- True
- False
- False
- False
- True
- True
- False
- False
- False
- True
- True
- False
- False
- False
- True
- False
- True
- True
- False
- False
-
-
-
-
-
-
-
- True
- False
- Full
- DoNotBuild
- 0
- false
-
-
- true
-
-
- ..\InterimKey.snk
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- version.cs
-
-
-
-
- {43DFAD18-3E35-4558-9BE2-CAFF6B5BA8A0}
- Basetypes
-
-
- {ACCC0156-0921-43ED-8F67-AD8BDC8CDE31}
- CodeContractsExtender
-
-
- {B230A69C-C466-4065-B9C1-84D80E76D802}
- Core
-
-
- {69A2B0B8-BCAC-4101-AE7A-556FCC58C06E}
- Graph
-
-
- {ACEF88D5-DADD-46DA-BAE1-2144D63F4C83}
- Model
-
-
- {FCD3AC7F-9DFD-46C8-AB1E-09F0B0F16DC5}
- ParserHelper
-
-
- {56FFDBCA-7D14-43B8-A6CA-22A20E417EE1}
- VCExpr
-
-
- {E1F10180-C7B9-4147-B51F-FA1B701966DC}
- VCGeneration
-
-
-
-
-
-
-
-
diff --git a/Source/Doomed/DoomedLoopUnrolling.cs b/Source/Doomed/DoomedLoopUnrolling.cs
deleted file mode 100644
index 0905deedc..000000000
--- a/Source/Doomed/DoomedLoopUnrolling.cs
+++ /dev/null
@@ -1,650 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Threading;
-using System.IO;
-using Microsoft.Boogie;
-using Microsoft.Boogie.GraphUtil;
-using System.Diagnostics.Contracts;
-using Microsoft.Basetypes;
-using Microsoft.Boogie.VCExprAST;
-
-namespace VC
-{
- #region Loop handeling for doomed code detection
-
- #region Loop Remover
- internal class LoopRemover
- {
- GraphAnalyzer m_GraphAnalyzer;
-
- public LoopRemover(GraphAnalyzer ga)
- {
- m_GraphAnalyzer = ga;
- }
-
- private void m_RemoveBackEdge(Loop l)
- {
- // first remove the backedges of the nested loops
- foreach (Loop c in l.NestedLoops) m_RemoveBackEdge(c);
- //Debugger.Break();
- GraphNode loopSkip = null;
- foreach (GraphNode gn in l.Cutpoint.Suc)
- {
- if (l.LoopExitNodes.Contains(gn))
- {
- loopSkip = gn; break;
- }
- }
- if (loopSkip == null)
- { // We didn't find a loop exit node. There must be a bug
- Debugger.Break();
- }
- foreach (GraphNode gn in l.Cutpoint.LoopingPred)
- {
- List newsuc = new List();
- foreach (GraphNode s in gn.Suc)
- {
- if (s == l.Cutpoint) newsuc.Add(loopSkip);
- else newsuc.Add(s);
- }
- gn.Suc = newsuc;
- }
- }
-
- private void m_AbstractLoop(Loop l)
- {
- foreach (Loop c in l.NestedLoops) m_AbstractLoop(c);
- m_HavocLoopBody(l);
- m_RemoveBackEdge(l);
- }
-
- public void AbstractLoopUnrolling()
- {
- foreach (Loop l in m_GraphAnalyzer.Graphloops)
- {
- m_MarkLoopExitUncheckable(l);
- m_AbstractLoopUnrolling(l,null, "",true);
- }
- }
-
- private void m_HavocLoopBody(Loop l)
- {
- List loopblocks = new List();
- foreach (GraphNode g in l.LoopNodes) loopblocks.Add(g.Label);
- HavocCmd hcmd = m_ComputHavocCmd(loopblocks, l.Cutpoint.Label.tok);
-
- //Add Havoc before and after the loop body
- foreach (GraphNode g in l.Cutpoint.Suc) // before
- {
- if (l.LoopNodes.Contains(g)) m_AddHavocCmdToFront(g.Label, hcmd);
- }
- foreach (GraphNode g in l.Cutpoint.Pre) // and after
- {
- if (l.LoopNodes.Contains(g)) m_AddHavocCmdToFront(g.Label, hcmd);
- }
- }
-
- private void m_AddHavocCmdToFront(Block b, HavocCmd hcmd)
- {
- List cs = new List();
- cs.Add(hcmd); cs.AddRange(b.Cmds);
- b.Cmds = cs;
- }
-
- private HavocCmd m_ComputHavocCmd(List bl, IToken tok)
- {
- Contract.Requires(bl != null);
- Contract.Requires(tok != null);
- Contract.Ensures(Contract.Result() != null);
-
- List varsToHavoc = new List();
- foreach (Block b in bl)
- {
- Contract.Assert(b != null);
- foreach (Cmd c in b.Cmds)
- {
- Contract.Assert(c != null);
- c.AddAssignedVariables(varsToHavoc);
- }
- }
- List havocExprs = new List();
- foreach (Variable v in varsToHavoc)
- {
- Contract.Assert(v != null);
- IdentifierExpr ie = new IdentifierExpr(Token.NoToken, v);
- if (!havocExprs.Contains(ie))
- havocExprs.Add(ie);
- }
- // pass the token of the enclosing loop header to the HavocCmd so we can reconstruct
- // the source location for this later on
- return new HavocCmd(tok, havocExprs);
- }
-
- private void m_AbstractLoopUnrolling(Loop l, Loop parent, string prefix, bool unfold)
- {
- //Debugger.Break();
- if (unfold)
- {
-
- Loop first = new Loop(l, m_GraphAnalyzer,prefix+"FI_");
- Loop last = new Loop(l, m_GraphAnalyzer,prefix+"LA_");
- Loop abs = new Loop(l, m_GraphAnalyzer, prefix + "AB_");
- foreach (Loop c in first.NestedLoops) m_AbstractLoopUnrolling(c, first, prefix + "FI_", false);
- foreach (Loop c in last.NestedLoops) m_AbstractLoopUnrolling(c, last, prefix + "LA_", false);
- foreach (Loop c in abs.NestedLoops) m_AbstractLoopUnrolling(c, abs, prefix + "AB_", true);
-
- //Debugger.Break();
-
- if (parent != null)
- {
- foreach (GraphNode gn in l.LoopNodes)
- {
- if (parent.LoopNodes.Contains(gn)) parent.LoopNodes.Remove(gn);
- }
- foreach (GraphNode gn in abs.LoopNodes)
- {
- if (!parent.LoopNodes.Contains(gn)) parent.LoopNodes.Add(gn);
- }
- foreach (GraphNode gn in first.LoopNodes)
- {
- if (!parent.LoopNodes.Contains(gn)) parent.LoopNodes.Add(gn);
- }
- foreach (GraphNode gn in last.LoopNodes)
- {
- if (!parent.LoopNodes.Contains(gn)) parent.LoopNodes.Add(gn);
- }
- }
-
- m_HavocLoopBody(abs);
- List backupPre = new List();
- backupPre.AddRange(l.Cutpoint.Pre);
- foreach (GraphNode pre in backupPre)
- {
- if (!l.Cutpoint.LoopingPred.Contains(pre))
- {
- pre.RemoveEdgeTo(l.Cutpoint);
- pre.RemoveEdgeTo(abs.Cutpoint);
- pre.AddEdgeTo(first.Cutpoint);
- }
- }
-
- m_RemoveRegularLoopExit(last);
- m_RemoveRegularLoopExit(abs);
-
- m_ReplaceBackEdge(first, abs.Cutpoint);
- m_ReplaceBackEdge(abs, last.Cutpoint);
- foreach (GraphNode gn in first.Cutpoint.Suc)
- {
- if (!first.LoopNodes.Contains(gn))
- {
- m_ReplaceBackEdge(last, gn);
- break;
- }
- }
-
- // Remove all remaining connections to the original loop
- foreach (GraphNode gn in l.LoopExitNodes)
- {
- List tmp = new List();
- tmp.AddRange(gn.Pre);
- foreach (GraphNode g in tmp)
- {
- if (l.LoopNodes.Contains(g))
- {
- //Debugger.Break();
- g.RemoveEdgeTo(gn);
- }
- }
- }
- foreach (GraphNode gn in l.LoopNodes)
- {
- m_GraphAnalyzer.DeleteGraphNode(gn);
- }
- foreach (GraphNode gn in first.LoopNodes)
- {
- if (gn != first.Cutpoint && !m_GraphAnalyzer.UncheckableNodes.Contains(gn) )
- m_GraphAnalyzer.UncheckableNodes.Add(gn);
- }
- foreach (GraphNode gn in last.LoopNodes)
- {
- if (gn != last.Cutpoint && !m_GraphAnalyzer.UncheckableNodes.Contains(gn))
- m_GraphAnalyzer.UncheckableNodes.Add(gn);
- }
- MakeLoopExitUncheckable(last.LoopExitNodes);
- }
- else
- {
- foreach (Loop c in l.NestedLoops) m_AbstractLoopUnrolling(c, l, prefix, false);
- m_AbstractLoop(l);
- //MakeLoopExitUncheckable(l.LoopExitNodes);
- }
- }
-
- // the loop exit has to be marked uncheckable because otherwise
- // while(true) would report unreachable code.
- private void m_MarkLoopExitUncheckable(Loop l)
- {
-
- foreach (GraphNode g in l.Cutpoint.Suc)
- {
- if (!l.LoopNodes.Contains(g))
- {
- foreach (GraphNode g_ in m_MarkLoopExitUncheckable(g, l))
- {
- if (!m_GraphAnalyzer.UncheckableNodes.Contains(g_))
- m_GraphAnalyzer.UncheckableNodes.Add(g_);
- }
- }
- }
- }
-
- private List m_MarkLoopExitUncheckable(GraphNode g, Loop l)
- {
- List ret = new List();
-
- if (g.Pre.Count > 1) return ret;
- ret.Add(g);
- foreach (GraphNode gn in g.Suc)
- {
- ret.AddRange(m_MarkLoopExitUncheckable(gn, l));
- }
-
- return ret;
- }
-
- // to avoid problems with unreachable code after while(true) {}, try to make the loopexit nodes uncheckable.
- private void MakeLoopExitUncheckable(List le)
- {
- foreach (GraphNode gn in le)
- {
- if (gn.Suc.Count==1) m_GraphAnalyzer.UncheckableNodes.Add(gn);
- }
- }
-
- private void m_RemoveRegularLoopExit(Loop l)
- {
- List lg = new List();
- lg.AddRange( l.Cutpoint.Suc );
- foreach (GraphNode gn in lg)
- {
- if (l.LoopExitNodes.Contains(gn))
- {
- l.Cutpoint.RemoveEdgeTo(gn);
- l.LoopExitNodes.Remove(gn);
- }
- }
- }
-
- private void m_ReplaceBackEdge(Loop l, GraphNode loopSkip)
- {
-
- foreach (GraphNode gn in l.Cutpoint.LoopingPred)
- {
- List newsuc = new List();
- foreach (GraphNode s in gn.Suc)
- {
- if (s == l.Cutpoint) newsuc.Add(loopSkip);
- else newsuc.Add(s);
- }
- gn.Suc = newsuc;
- }
- }
-
-
- }
- #endregion
-
- #region Graph Analyzer
- internal class GraphAnalyzer
- {
- public List UncheckableNodes = new List();
-
- public Dictionary GraphMap = new Dictionary();
-
- public List Graphloops = null;
-
- public GraphAnalyzer(List blocks)
- {
- //ExitBlock = dedicatedExitBlock;
- if (blocks.Count < 1) return;
- foreach (Block b in blocks) GraphMap[b] = new GraphNode(b);
- foreach (Block b in blocks)
- {
- foreach (Block pre in b.Predecessors) GraphMap[b].Pre.Add(GraphMap[pre]);
- GotoCmd gc = b.TransferCmd as GotoCmd;
- if (gc != null)
- {
- foreach (Block suc in gc.labelTargets) GraphMap[b].Suc.Add(GraphMap[suc]);
- }
- }
-
-
- m_DetectCutPoints(GraphMap[blocks[0]]);
-
- //m_DetectCutPoints(GraphMap[blocks[0]], null, new List());
- Graphloops = m_CollectLoops(GraphMap[blocks[0]], null);
-
- }
-
- public List ToImplementation(out List uncheckables)
- {
- List blocks = new List();
- uncheckables = new List();
-
- foreach (KeyValuePair kvp in GraphMap)
- {
- Block b = kvp.Key;
- if (UncheckableNodes.Contains(GraphMap[b])) uncheckables.Add(b);
- blocks.Add(b);
- b.Predecessors = new List();
- foreach (GraphNode p in kvp.Value.Pre) b.Predecessors.Add(p.Label);
- if (kvp.Value.Suc.Count > 0)
- {
- List bs = new List();
- foreach (GraphNode s in kvp.Value.Suc) bs.Add(s.Label);
- b.TransferCmd = new GotoCmd(b.tok, bs);
- }
- else
- {
- b.TransferCmd = new ReturnCmd(b.tok);
- }
- }
-
- return blocks;
- }
-
- public GraphNode CloneGraphNode(GraphNode gn, string prefix)
- {
- List cmds = new List(gn.Label.Cmds);
-
- Block b = new Block(gn.Label.tok, prefix+gn.Label.Label, cmds, gn.Label.TransferCmd);
- GraphNode clone = new GraphNode(b);
- clone.IsCutpoint = gn.IsCutpoint;
- clone.Suc.AddRange(gn.Suc);
- clone.Pre.AddRange(gn.Pre);
- clone.LoopingPred.AddRange(gn.LoopingPred);
- GraphMap[b] = clone;
- //if (gn.Label == ExitBlock) ExitBlock = b;
- return clone;
- }
-
- public void DeleteGraphNode(GraphNode gn)
- {
- List affected = new List();
-
- foreach (KeyValuePair kvp in GraphMap)
- {
- if (kvp.Value == gn && !affected.Contains(kvp.Key)) affected.Add(kvp.Key);
- }
- foreach (Block b in affected)
- {
- GraphMap.Remove(b);
- }
- }
-/*
- private void m_DetectCutPoints(GraphNode gn, GraphNode pred, List visited )
- {
- if (visited.Contains(gn) )
- {
- if (pred != null && !gn.LoopingPred.Contains(pred)) gn.LoopingPred.Add(pred);
- gn.IsCutpoint = true;
- Console.WriteLine("Normal RootNode {0}", gn.Label.Label);
- return;
- }
- else
- {
- List visited_ = new List();
- visited_.AddRange(visited);
- visited_.Add(gn);
- foreach (GraphNode next in gn.Suc)
- {
- m_DetectCutPoints(next,gn,visited_);
- }
- }
-
- }
-*/
-
-
- private void m_DetectCutPoints(GraphNode gn)
- {
- List todo = new List();
- List done = new List();
- todo.Add(gn);
-
- GraphNode current = null;
- todo[0].Index = 0;
-
- while (todo.Count > 0)
- {
- current = todo[0];
- todo.Remove(current);
-
- bool ready = true;
- foreach (GraphNode p in current.Pre)
- {
- if (!done.Contains(p) )
- {
- _loopbacktracking.Clear();
- if (!m_isLoop(current, p, todo, done))
- {
- todo.Add(current);
- ready = false;
- break;
- }
- else
- {
- if (!current.LoopingPred.Contains(p)) current.LoopingPred.Add(p);
- current.IsCutpoint = true;
- }
- }
- }
- if (!ready) continue;
- done.Add(current);
- foreach (GraphNode s in current.Suc)
- {
- if (!todo.Contains(s) && !done.Contains(s)) todo.Add(s);
- }
- }
-
- }
-
- List _loopbacktracking = new List();
- private bool m_isLoop(GraphNode loophead, GraphNode gn, List l1, List l2)
- {
- if (loophead == gn) return true;
- if (l1.Contains(gn) || l2.Contains(gn) || _loopbacktracking.Contains(gn)) return false;
- _loopbacktracking.Add(gn);
- foreach (GraphNode p in gn.Pre)
- {
- if (m_isLoop(loophead, p, l1, l2)) return true;
- }
- return false;
- }
-
- private List m_CollectLoops(GraphNode gn, Loop lastLoop)
- {
- List ret = new List();
- if (gn.Visited) return ret;
- gn.Visited = true;
- List loopingSucs = new List();
- if (gn.IsCutpoint)
- {
- Loop l = new Loop(gn);
- if (lastLoop != null)
- {
- lastLoop.SucLoops.Add(l);
- l.PreLoops.Add(lastLoop);
- }
- loopingSucs = l.LoopNodes;
- lastLoop = l;
- ret.Add(lastLoop);
- }
- foreach (GraphNode suc in gn.Suc)
- {
- if (!loopingSucs.Contains(suc)) ret.AddRange(m_CollectLoops(suc, lastLoop));
- }
- //Debugger.Break();
- return ret;
- }
- }
- #endregion
-
- #region GraphNodeStructure
- internal class GraphNode
- {
- public int Index = -1; // Used for scc detection
- public int LowLink = -1; // Used for scc detection
-
- public GraphNode(Block b)
- {
- Label = b; IsCutpoint = false;
- }
- public Block Label;
- public List Pre = new List();
- public List Suc = new List();
- public bool IsCutpoint;
- public bool Visited = false;
- public List LoopingPred = new List();
-
- public void AddEdgeTo(GraphNode other)
- {
- if (!this.Suc.Contains(other)) this.Suc.Add(other);
- if (!other.Pre.Contains(this)) other.Pre.Add(this);
- }
-
- public void RemoveEdgeTo(GraphNode other)
- {
- if (this.Suc.Contains(other)) this.Suc.Remove(other);
- if (other.Pre.Contains(this)) other.Pre.Remove(this);
- }
-
- }
- #endregion
-
- #region LoopStructure
- internal class Loop
- {
- public Loop(GraphNode cutpoint)
- {
- if (!cutpoint.IsCutpoint)
- {
- Debugger.Break();
- }
- Cutpoint = cutpoint;
- LoopNodes.Add(Cutpoint);
- foreach (GraphNode gn in Cutpoint.LoopingPred)
- {
- CollectLoopBody(gn);
- }
- CollectLoopExitNodes();
- }
-
- // Copy Constructor
- public Loop(Loop l, GraphAnalyzer ga, string prefix)
- {
-
- Dictionary clonemap = new Dictionary();
- GraphNode clonecutpoint = null;
- foreach (GraphNode gn in l.LoopNodes)
- {
- clonemap[gn] = ga.CloneGraphNode(gn, prefix);
- if (gn == l.Cutpoint) clonecutpoint = clonemap[gn];
- }
-
- if (clonecutpoint == null)
- {
- Debugger.Break();
- return;
- }
- // Replace the pre and post nodes by the corresponding clone
- foreach (GraphNode gn in l.LoopNodes)
- {
- List newl = new List();
- foreach (GraphNode g in clonemap[gn].Pre)
- {
- if (clonemap.ContainsKey(g)) newl.Add(clonemap[g]);
- else newl.Add(g);
- }
- clonemap[gn].Pre = newl;
- newl = new List();
- foreach (GraphNode g in clonemap[gn].Suc)
- {
- if (clonemap.ContainsKey(g)) newl.Add(clonemap[g]);
- else newl.Add(g);
- }
- clonemap[gn].Suc = newl;
- newl = new List();
- foreach (GraphNode g in clonemap[gn].LoopingPred)
- {
- if (clonemap.ContainsKey(g)) newl.Add(clonemap[g]);
- else newl.Add(g);
- }
- clonemap[gn].LoopingPred = newl;
- }
-
- foreach (GraphNode gn in l.Cutpoint.LoopingPred)
- {
- clonecutpoint.LoopingPred.Remove(gn);
- clonecutpoint.LoopingPred.Add(clonemap[gn]);
- }
-
-
-
- SucLoops.AddRange(l.SucLoops);
- PreLoops.AddRange(l.PreLoops);
- Cutpoint = clonecutpoint;
- LoopNodes.Add(Cutpoint);
- foreach (GraphNode gn in Cutpoint.LoopingPred)
- {
- CollectLoopBody(gn);
- }
- CollectLoopExitNodes();
- }
-
- private void CollectLoopBody(GraphNode gn)
- {
- if (gn == Cutpoint) return;
- if (!LoopNodes.Contains(gn))
- {
- if (gn.IsCutpoint) // nested loop found
- {
- Loop lo = new Loop(gn);
- foreach (GraphNode lgn in lo.LoopNodes)
- {
- if (!LoopNodes.Contains(lgn)) LoopNodes.Add(lgn);
- }
- NestedLoops.Add(lo);
- }
- else
- {
- LoopNodes.Add(gn);
- }
- foreach (GraphNode pre in gn.Pre) if (!gn.LoopingPred.Contains(pre)) CollectLoopBody(pre);
- }
- }
-
- private void CollectLoopExitNodes()
- {
- foreach (GraphNode gn in LoopNodes)
- {
- foreach (GraphNode gn_ in gn.Suc)
- {
- if (!LoopNodes.Contains(gn_) && !LoopExitNodes.Contains(gn_)) LoopExitNodes.Add(gn_);
- }
- }
- }
-
- public GraphNode Cutpoint;
- public List LoopExitNodes = new List();
- public List NestedLoops = new List();
- public List SucLoops = new List();
- public List PreLoops = new List();
- public List LoopNodes = new List();
- }
- #endregion
-
- #endregion
-}
\ No newline at end of file
diff --git a/Source/Doomed/DoomedStrategy.cs b/Source/Doomed/DoomedStrategy.cs
deleted file mode 100644
index 76261827d..000000000
--- a/Source/Doomed/DoomedStrategy.cs
+++ /dev/null
@@ -1,528 +0,0 @@
-//-----------------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
-//
-//-----------------------------------------------------------------------------
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Threading;
-using System.IO;
-using Microsoft.Boogie;
-using Microsoft.Boogie.GraphUtil;
-using System.Diagnostics.Contracts;
-using Microsoft.Basetypes;
-using Microsoft.Boogie.VCExprAST;
-
-namespace VC
-{
- #region SuperClass for different doomed code detection strategies
- abstract internal class DoomDetectionStrategy
- {
- public int __DEBUG_BlocksChecked = 0;
- public int __DEBUG_BlocksTotal = 0;
- public int __DEBUG_InfeasibleTraces = 0;
- public int __DEBUG_TracesChecked = 0;
- public int __DEBUG_TracesTotal = 0;
- public int __DEBUG_EQCTotal = 0;
- public int __DEBUG_EQCLeaf = 0;
- public int __DEBUG_EQCChecked = 0;
-
- //Please use this one to toggle your Debug output
- protected bool __DEBUGOUT = CommandLineOptions.Clo.DoomStrategy != -1;
-
- protected Implementation impl;
- protected BlockHierachy m_BlockH = null;
-
- protected int m_MaxBranchingDepth = 0;
- protected int m_MaxK = 0;
-
- protected Stopwatch sw = new Stopwatch();
-
-
- // This is the List with all detected doomed program points. This List is used by VCDoomed.cs to
- // create an error message
- public List
/*!*/>/*!*/ DetectedBlock = new List
/*!*/>();
-
- private List __DEBUG_minelements = new List();
-
- // There is no default constructor, because these parameters are needed for most subclasses
- public DoomDetectionStrategy(Implementation imp, Block unifiedexit, List unreach)
- {
- m_BlockH = new BlockHierachy(imp, unifiedexit);
- __DEBUG_EQCLeaf = m_BlockH.Leaves.Count;
-
- //foreach (BlockHierachyNode bhn in m_BlockH.Leaves)
- //{
- // if (bhn.Content.Count > 0) __DEBUG_minelements.Add(bhn.Content[0]);
- //}
- //if (imp.Blocks.Count>0) m_GatherInfo(imp.Blocks[0], 0, 0,0);
-
-
- if (__DEBUGOUT)
- {
- Console.WriteLine("MaBranchingDepth {0} MaxMinPP {1} ", m_MaxBranchingDepth, m_MaxK);
-
- Console.WriteLine("AvgLeaverPerPath {0} AvgPLen {1}", 0, 0);
- }
-
- MaxBlocks = imp.Blocks.Count;
- MinBlocks = imp.Blocks.Count;
- HACK_NewCheck = false;
- __DEBUG_BlocksTotal = imp.Blocks.Count;
- }
-
- public int MaxBlocks, MinBlocks;
- public bool HACK_NewCheck;
-
- // This method is called by the prover while it returns true. The prover checks for each
- // List lb if
- // |= !lb_1 /\ ... /\ !lb_n => wlp(Program, false)
- // and passes the result to SetCurrentResult
- abstract public bool GetNextBlock(out List passBlock);
-
- // This method is called to inform about the prover outcome for the previous GetNextBlock call.
- abstract public bool SetCurrentResult(List reachvar, ProverInterface.Outcome outcome, DoomErrorHandler cb);
-
- protected List m_GetErrorTraceFromCE(DoomErrorHandler cb)
- {
- BlockHierachyNode tn=null;
- List errortrace = new List();
- foreach (Block b in cb.TraceNodes)
- {
- if (errortrace.Contains(b)) continue;
- if (m_BlockH.BlockToHierachyMap.TryGetValue(b, out tn))
- {
- foreach (Block b_ in tn.Unavoidable)
- {
- if (!errortrace.Contains(b_)) errortrace.Add(b_);
- }
- foreach (Block b_ in tn.Content)
- {
- if (!errortrace.Contains(b_)) errortrace.Add(b_);
- }
- }
- }
- return errortrace;
- }
-
- private List __pathLength = new List();
- private List __leavespp = new List();
- protected void m_GatherInfo(Block b, int branchingdepth, int leavespp, int plen)
- {
- if (b.Predecessors.Count > 1) branchingdepth--;
-
- GotoCmd gc = b.TransferCmd as GotoCmd;
- if (__DEBUG_minelements.Contains(b)) leavespp++;
- plen++;
- if (gc != null && gc.labelTargets.Count>0)
- {
- if (gc.labelTargets.Count > 1) branchingdepth++;
- m_MaxBranchingDepth = (branchingdepth > m_MaxBranchingDepth) ? branchingdepth : m_MaxBranchingDepth;
- foreach (Block s in gc.labelTargets)
- {
- m_GatherInfo(s, branchingdepth, leavespp,plen);
- }
- }
- else
- {
- __pathLength.Add(plen);
- __leavespp.Add(leavespp);
- m_MaxK = (m_MaxK > leavespp) ? m_MaxK : leavespp;
- }
- }
-
-
-
- }
- #endregion
-
- #region BruteForce Strategy
- internal class NoStrategy : DoomDetectionStrategy
- {
- private List m_Blocks = new List();
- private int m_Current = 0;
-
- public NoStrategy(Implementation imp, Block unifiedexit, List unreach)
- : base(imp, unifiedexit, unreach)
- {
- m_Blocks = imp.Blocks;
- }
-
- override public bool GetNextBlock(out List lb)
- {
- if (m_Current < m_Blocks.Count)
- {
- lb = new List();
- lb.Add(m_Blocks[m_Current]);
- m_Current++;
- return true;
- }
- lb = null;
- return false;
- }
-
- // This method is called to inform about the prover outcome for the previous GetNextBlock call.
- override public bool SetCurrentResult(List reachvar, ProverInterface.Outcome outcome, DoomErrorHandler cb)
- {
- this.__DEBUG_BlocksChecked++;
- // outcome==Valid means that there is no feasible execution for the current block/path (i.e., might be doomed)
- if (outcome == ProverInterface.Outcome.Valid && m_Current <= m_Blocks.Count)
- {
- List lb = new List();
- lb.Add(m_Blocks[m_Current - 1]);
- DetectedBlock.Add(lb);
- }
- return true;
- }
- }
- #endregion
-
- #region Only check the minimal elements of the Hasse diagram
- internal class HierachyStrategy : DoomDetectionStrategy
- {
- private List m_Blocks = new List();
- private List m_doomedBlocks = new List();
- private int m_Current = 0;
-
- public HierachyStrategy(Implementation imp, Block unifiedexit, List unreach)
- : base(imp, unifiedexit, unreach)
- {
- foreach (BlockHierachyNode bhn in m_BlockH.Leaves)
- {
- if (bhn.Content.Count > 0)
- {
- m_Blocks.Add(bhn.Content[0]);
- }
- }
- }
-
- override public bool GetNextBlock(out List lb)
- {
- sw.Start();
- if (m_Current < m_Blocks.Count)
- {
- lb = new List();
- lb.Add(m_Blocks[m_Current]);
- m_Current++;
- return true;
- }
- else
- {
- DetectedBlock.Add(m_BlockH.GetOtherDoomedBlocks(m_doomedBlocks));
- }
- lb = null;
- return false;
- }
-
- // This method is called to inform about the prover outcome for the previous GetNextBlock call.
- override public bool SetCurrentResult(List reachvar, ProverInterface.Outcome outcome, DoomErrorHandler cb)
- {
- this.__DEBUG_BlocksChecked++;
- // outcome==Valid means that there is no feasible execution for the current block/path (i.e., might be doomed)
- if (outcome == ProverInterface.Outcome.Valid && m_Current <= m_Blocks.Count)
- {
- m_doomedBlocks.Add(m_Blocks[m_Current - 1]);
- }
- if (__DEBUGOUT) Console.WriteLine("K := {0,3} , out {1,8}, time {2,12}", MaxBlocks, outcome, sw.ElapsedTicks);
- sw.Stop();
- sw.Reset();
-
- return true;
- }
- }
- #endregion
-
- #region Only check the minimal elements of the Hasse diagram and use CEs
- internal class HierachyCEStrategy : DoomDetectionStrategy
- {
- private List m_Blocks = new List();
- private List m_doomedBlocks = new List();
- private Block m_Current = null;
-
- public HierachyCEStrategy(Implementation imp, Block unifiedexit, List unreach)
- : base(imp, unifiedexit, unreach)
- {
- foreach (BlockHierachyNode bhn in m_BlockH.Leaves)
- {
- if (bhn.Content.Count > 0)
- {
- m_Blocks.Add(bhn.Content[0]);
- }
- }
- }
-
- override public bool GetNextBlock(out List lb)
- {
- m_Current = null;
- if (m_Blocks.Count > 0)
- {
- m_Current = m_Blocks[0];
- m_Blocks.Remove(m_Current);
- lb = new List();
- lb.Add(m_Current);
- return true;
- }
- else
- {
- DetectedBlock.Add(m_BlockH.GetOtherDoomedBlocks(m_doomedBlocks));
- }
- lb = null;
- return false;
- }
-
- // This method is called to inform about the prover outcome for the previous GetNextBlock call.
- override public bool SetCurrentResult(List reachvar, ProverInterface.Outcome outcome, DoomErrorHandler cb)
- {
- this.__DEBUG_BlocksChecked++;
- // outcome==Valid means that there is no feasible execution for the current block/path (i.e., might be doomed)
- if (outcome == ProverInterface.Outcome.Valid && m_Current != null)
- {
- m_doomedBlocks.Add(m_Current);
- }
- else if (outcome == ProverInterface.Outcome.Invalid)
- {
- List errortrace = m_GetErrorTraceFromCE(cb);
- foreach (Block b in errortrace)
- {
- if (m_Blocks.Contains(b))
- {
- m_Blocks.Remove(b);
- }
- }
- cb.TraceNodes.Clear();
- }
- return true;
- }
- }
- #endregion
-
- #region Path Cover Optimization with L
- internal class PathCoverStrategy : DoomDetectionStrategy
- {
- List m_Uncheckedlocks = new List();
- List m_Ignore = new List();
-
- Random m_Random = new Random();
- bool m_NoMoreMoves = false;
-
- private List m_foundBlock = new List();
-
- public PathCoverStrategy(Implementation imp, Block unifiedexit, List unreach)
- : base(imp, unifiedexit, unreach)
- {
- m_Ignore = unreach;
- HACK_NewCheck = true;
- impl = imp;
- foreach (BlockHierachyNode bhn in m_BlockH.Leaves)
- {
- if (bhn.Content.Count > 0)
- {
- m_Uncheckedlocks.Add(bhn.Content[0]);
- }
-
- }
- m_MaxK = m_BlockH.GetMaxK(m_Uncheckedlocks);
- MinBlocks = m_MaxK / 2 + (m_MaxK % 2 > 0 ? 1 : 0);
- MaxBlocks = -1;
- }
-
- override public bool GetNextBlock(out List lb)
- {
- sw.Start();
-
- lb = new List();
-
- if (m_Uncheckedlocks.Count == 0 || m_NoMoreMoves)
- {
- if (m_Uncheckedlocks.Count > 0)
- {
- DetectedBlock.Add(m_BlockH.GetOtherDoomedBlocks(m_Uncheckedlocks));
- }
-
- return false;
- }
-
- lb.AddRange(m_Uncheckedlocks);
-
- return true;
- }
-
- override public bool SetCurrentResult(List reachvar, ProverInterface.Outcome outcome, DoomErrorHandler cb)
- {
- this.__DEBUG_BlocksChecked++;
- // Valid means infeasible...
- int oldl = MinBlocks;
- int oldsize = m_Uncheckedlocks.Count;
-
-
- if (outcome == ProverInterface.Outcome.Valid)
- {
- this.__DEBUG_InfeasibleTraces++;
- if (MinBlocks == 1)
- {
- m_NoMoreMoves = true;
- }
- else
- {
- MinBlocks = 1;
- }
- }
- else if (outcome == ProverInterface.Outcome.Invalid)
- {
- this.__DEBUG_TracesChecked++;
-
- List errortrace = m_GetErrorTraceFromCE(cb);
- foreach (Block b in errortrace)
- {
- if (m_Uncheckedlocks.Contains(b))
- {
- m_Uncheckedlocks.Remove(b);
- }
- }
- cb.TraceNodes.Clear();
- m_MaxK = m_BlockH.GetMaxK(m_Uncheckedlocks);
- if (m_MaxK < 1)
- {
- m_NoMoreMoves = true; m_Uncheckedlocks.Clear();
- }
- MinBlocks = m_MaxK / 2 + (m_MaxK % 2 > 0 ? 1 : 0);
- //if (MinBlocks > m_MaxK) MinBlocks = m_MaxK;
-
- }
- else
- {
- m_NoMoreMoves = true; m_Uncheckedlocks.Clear();
- }
- if (__DEBUGOUT)
- Console.WriteLine("K := {0,3}, L := {1,3}, deltaSp {2,3}, out {3,8}, time {4,8}", MaxBlocks, oldl, (oldsize - m_Uncheckedlocks.Count), outcome, sw.ElapsedTicks);
- sw.Stop();
- sw.Reset();
- return true;
- }
-
-
- }
- #endregion
-
- #region Path Cover Optimization with K
- internal class PathCoverStrategyK : DoomDetectionStrategy
- {
- List m_Uncheckedlocks = new List();
- List m_Ignore = new List();
-
- Random m_Random = new Random();
- bool m_NoMoreMoves = false;
-
- private List m_foundBlock = new List();
-
- public PathCoverStrategyK(Implementation imp, Block unifiedexit, List unreach)
- : base(imp, unifiedexit, unreach)
- {
- m_Ignore = unreach;
- HACK_NewCheck = true;
- impl = imp;
- foreach (BlockHierachyNode bhn in m_BlockH.Leaves)
- {
- if (bhn.Content.Count > 0)
- {
- m_Uncheckedlocks.Add(bhn.Content[0]);
- }
-
- }
-
- m_MaxK = m_BlockH.GetMaxK(m_Uncheckedlocks);
-
- MaxBlocks = m_Uncheckedlocks.Count;
- if (m_MaxK < m_Uncheckedlocks.Count && m_MaxK > 0)
- {
- MaxBlocks = m_MaxK;
- }
- else if (m_MaxK >= m_Uncheckedlocks.Count)
- {
- MaxBlocks = m_Uncheckedlocks.Count;
- }
- else
- {
- MaxBlocks = 1;
- }
- //Console.WriteLine("InitK {0}, Max {1}", m_MaxK, MaxBlocks);
- }
-
- override public bool GetNextBlock(out List lb)
- {
- sw.Start();
-
- lb = new List();
-
- if (m_Uncheckedlocks.Count == 0 || m_NoMoreMoves)
- {
- if (m_Uncheckedlocks.Count > 0)
- {
- DetectedBlock.Add(m_BlockH.GetOtherDoomedBlocks(m_Uncheckedlocks));
- }
-
- return false;
- }
-
- lb.AddRange(m_Uncheckedlocks);
-
- MaxBlocks = MaxBlocks > m_Uncheckedlocks.Count ? m_Uncheckedlocks.Count : MaxBlocks;
- MinBlocks = MaxBlocks / 2 + (MaxBlocks % 2 > 0 ? 1 : 0);
- return true;
- }
-
- override public bool SetCurrentResult(List reachvar, ProverInterface.Outcome outcome, DoomErrorHandler cb)
- {
- this.__DEBUG_BlocksChecked++;
- // Valid means infeasible...
- int oldk = MaxBlocks;
- int oldl = MinBlocks;
- int oldsize = m_Uncheckedlocks.Count;
-
- if (outcome == ProverInterface.Outcome.Valid)
- {
- this.__DEBUG_InfeasibleTraces++;
- if (MaxBlocks == 1)
- {
- m_NoMoreMoves = true;
- }
- else
- {
- MaxBlocks /= 2;
- }
- }
- else if (outcome == ProverInterface.Outcome.Invalid)
- {
- this.__DEBUG_TracesChecked++;
-
- List errortrace = m_GetErrorTraceFromCE(cb);
- foreach (Block b in errortrace)
- {
- if (m_Uncheckedlocks.Contains(b))
- {
- m_Uncheckedlocks.Remove(b);
- }
- }
- cb.TraceNodes.Clear();
-
- int k = m_BlockH.GetMaxK(m_Uncheckedlocks);
- MaxBlocks = (k > MaxBlocks) ? MaxBlocks : k;
- }
- else
- {
- m_NoMoreMoves = true; m_Uncheckedlocks.Clear();
- }
- if (__DEBUGOUT)
- Console.WriteLine("K := {0,3}, L := {1,3}, deltaSp {2,3}, out {3,8}, time {4,8}", oldk, oldl, (oldsize - m_Uncheckedlocks.Count), outcome, sw.ElapsedTicks);
- sw.Stop();
- sw.Reset();
- return true;
- }
-
-
- }
- #endregion
-
-}
\ No newline at end of file
diff --git a/Source/Doomed/HasseDiagram.cs b/Source/Doomed/HasseDiagram.cs
deleted file mode 100644
index c866662e4..000000000
--- a/Source/Doomed/HasseDiagram.cs
+++ /dev/null
@@ -1,424 +0,0 @@
-//-----------------------------------------------------------------------------
-//
-// Copyright (C) Microsoft Corporation. All Rights Reserved.
-//
-//-----------------------------------------------------------------------------
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Threading;
-using System.IO;
-using Microsoft.Boogie;
-using Microsoft.Boogie.GraphUtil;
-using System.Diagnostics.Contracts;
-using Microsoft.Basetypes;
-using Microsoft.Boogie.VCExprAST;
-
-namespace VC
-{
- internal class BlockHierachyNode
- {
- public List Unavoidable;
- public List Content = new List();
- public List Parents = new List();
- public List Children = new List();
-
- public bool Checked, Doomed, DoubleChecked;
-
- public BlockHierachyNode(Block current, List unavoidable)
- {
- Checked = false; Doomed = false; DoubleChecked = false;
- Unavoidable = unavoidable;
- Content.Add(current);
- }
-
- public static bool operator <(BlockHierachyNode left, BlockHierachyNode right)
- {
- return Compare(left,right)>0;
- }
-
- public static bool operator >(BlockHierachyNode left, BlockHierachyNode right)
- {
- return Compare(left, right) < 0;
- }
-
- // Compare the unavoidable blocks of two BlockHierachyNodes.
- // returns 0 if sets have the same size, -1 if l2 has an element
- // that is not in l1, otherwise the size of the intersection.
- public static int Compare(BlockHierachyNode l1, BlockHierachyNode l2)
- {
- List tmp = new List();
- tmp.AddRange(l2.Unavoidable);
- foreach (Block b in l1.Unavoidable)
- {
- if (tmp.Contains(b)) tmp.Remove(b);
- else return -1;
- }
- return tmp.Count;
- }
- }
-
- internal class HasseDiagram
- {
- public readonly List Leaves = new List();
- public readonly List Roots = new List();
-
- public HasseDiagram(List nodes)
- {
- Dictionary> largerElements = new Dictionary>();
- foreach (BlockHierachyNode left in nodes)
- {
- largerElements[left] = new List();
- foreach (BlockHierachyNode right in nodes)
- {
- if (left != right)
- {
- if (left < right)
- {
- largerElements[left].Add(right);
- }
- }
- }
- if (largerElements[left].Count == 0) Leaves.Add(left);
- }
-
- List done = new List();
- List lastround = null;
-
- //Debugger.Break();
-
- // Now that we have the leaves, build the Hasse diagram
- while (done.Count < nodes.Count)
- {
- List maxelements = new List();
- maxelements.AddRange(nodes);
- foreach (BlockHierachyNode bhn in nodes)
- {
- if (!done.Contains(bhn))
- {
- foreach (BlockHierachyNode tmp in largerElements[bhn])
- {
- if (maxelements.Contains(tmp)) maxelements.Remove(tmp);
- }
- }
- else
- {
- maxelements.Remove(bhn);
- }
- }
-
- done.AddRange(maxelements);
-
- if (lastround != null)
- {
- foreach (BlockHierachyNode tmp in lastround)
- {
- foreach (BlockHierachyNode tmp2 in maxelements)
- {
- if (largerElements[tmp].Contains(tmp2))
- {
- if (!tmp.Children.Contains(tmp2)) tmp.Children.Add(tmp2);
- if (!tmp2.Parents.Contains(tmp)) tmp2.Parents.Add(tmp);
- }
- }
- }
- }
- else
- {
- Roots.AddRange(maxelements);
- }
- lastround = maxelements;
- }
- }
-
-
- }
-
- internal class BlockHierachy
- {
- public BlockHierachyNode RootNode = null;
- readonly public Dictionary BlockToHierachyMap = new Dictionary();
- readonly public Dictionary> Dominators = new Dictionary>();
- readonly public Dictionary> PostDominators = new Dictionary>();
- readonly public List Leaves = new List();
-
- private Implementation m_Impl;
-
- public BlockHierachy(Implementation impl, Block unifiedExit)
- {
- m_Impl = impl;
- List blocks = impl.Blocks;
- List tmp_hnodes = new List();
- Dictionary> unavoidable = new Dictionary>();
-
- BfsTraverser(blocks[0], true, Dominators);
- BfsTraverser(unifiedExit, false, PostDominators);
-
- foreach (Block b in blocks)
- {
- List l1 = Dominators[b];
- List l2 = PostDominators[b];
- unavoidable[b] = m_MergeLists(l1, l2);
-
- BlockHierachyNode bhn = new BlockHierachyNode(b, unavoidable[b]);
- bool found = false;
- foreach (KeyValuePair kvp in BlockToHierachyMap)
- {
- if (BlockHierachyNode.Compare(kvp.Value, bhn) == 0) // using the overloaded compare operator
- {
- kvp.Value.Content.AddRange(bhn.Content);
- BlockToHierachyMap[b] = kvp.Value;
- found = true;
- break;
- }
- }
- if (!found)
- {
- BlockToHierachyMap[b] = bhn;
- tmp_hnodes.Add(bhn);
- }
- }
-
- HasseDiagram hd = new HasseDiagram(tmp_hnodes);
- Leaves = hd.Leaves;
- }
-
- public int GetMaxK(List blocks)
- {
- m_GetMaxK(blocks);
- return (m_MaxK>0) ? m_MaxK : 1;
- }
-
- private int m_MaxK = 0;
- private void m_GetMaxK(List blocks)
- {
- m_MaxK = 0;
- Dictionary kstore = new Dictionary();
- List todo = new List();
- List done = new List();
- todo.Add(m_Impl.Blocks[0]);
- kstore[m_Impl.Blocks[0]] = 0;
- int localmax;
- Block current = null;
- while (todo.Count > 0)
- {
- current = todo[0];
- todo.Remove(current);
- bool ready = true;
- localmax = 0;
- if (current.Predecessors!=null) {
- foreach (Block p in current.Predecessors)
- {
- if (!done.Contains(p))
- {
- ready = false; break;
- }
- else localmax = (localmax > kstore[p]) ? localmax : kstore[p];
- }
- }
- if (!ready)
- {
- todo.Add(current); continue;
- }
- done.Add(current);
- kstore[current] = (blocks.Contains(current)) ? localmax +1 : localmax;
-
- m_MaxK = (kstore[current] > m_MaxK) ? kstore[current] : m_MaxK;
-
- GotoCmd gc = current.TransferCmd as GotoCmd;
- if (gc != null)
- {
- foreach (Block s in gc.labelTargets)
- {
- if (!todo.Contains(s)) todo.Add(s);
- }
- }
- }
-
- }
-
- public List GetOtherDoomedBlocks(List doomedblocks)
- {
- List alsoDoomed = new List