summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar rustanleino <unknown>2009-08-13 17:38:24 +0000
committerGravatar rustanleino <unknown>2009-08-13 17:38:24 +0000
commit97a6519c245053811f8f394ba7c9c9875a094f9d (patch)
tree59bc18779f09ce87b07a32f84163c7a57f44a594
parentecdfc58e314d98fcf0616cebc4e411d8aa007df7 (diff)
Fixed bug where the remove-empty-blocks optimization had not updated the start block. Now it does. After the remove-empty-blocks optimization, the only possibly empty block is the start block. That is, the optimization does not change the name of the start block.
-rw-r--r--Source/VCGeneration/VC.ssc16
1 files changed, 6 insertions, 10 deletions
diff --git a/Source/VCGeneration/VC.ssc b/Source/VCGeneration/VC.ssc
index 617e52e6..eb54d1b9 100644
--- a/Source/VCGeneration/VC.ssc
+++ b/Source/VCGeneration/VC.ssc
@@ -3127,12 +3127,11 @@ namespace VC
static BlockSeq! RemoveEmptyBlocks(Block! b)
{
assert b.TraversingStatus == Block.VisitState.ToVisit;
- BlockSeq! retVal = removeEmptyBlocksWorker(b);
-
+ BlockSeq retVal = removeEmptyBlocksWorker(b, true);
return retVal;
}
- private static BlockSeq! removeEmptyBlocksWorker(Block! b)
+ private static BlockSeq! removeEmptyBlocksWorker(Block! b, bool startNode)
{
BlockSeq bs = new BlockSeq();
GotoCmd gtc = b.TransferCmd as GotoCmd;
@@ -3153,7 +3152,7 @@ namespace VC
// merge result into a *set* of blocks
Dictionary<Block,bool> mergedSuccessors = new Dictionary<Block,bool>();
foreach (Block! dest in gtc.labelTargets){
- BlockSeq! ys = removeEmptyBlocksWorker(dest);
+ BlockSeq! ys = removeEmptyBlocksWorker(dest, false);
foreach (Block successor in ys){
if (!mergedSuccessors.ContainsKey(successor))
mergedSuccessors.Add(successor,true);
@@ -3162,12 +3161,9 @@ namespace VC
b.TraversingStatus = Block.VisitState.AlreadyVisited;
BlockSeq setOfSuccessors = new BlockSeq();
- if (mergedSuccessors.Keys != null)
- {
- foreach (Block d in mergedSuccessors.Keys)
- setOfSuccessors.Add(d);
- }
- if (b.Cmds.Length == 0)
+ foreach (Block d in mergedSuccessors.Keys)
+ setOfSuccessors.Add(d);
+ if (b.Cmds.Length == 0 && !startNode)
return setOfSuccessors;
// otherwise, update the list of successors of b to be the blocks in setOfSuccessors
gtc.labelTargets = setOfSuccessors;