From 97a6519c245053811f8f394ba7c9c9875a094f9d Mon Sep 17 00:00:00 2001 From: rustanleino Date: Thu, 13 Aug 2009 17:38:24 +0000 Subject: 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. --- Source/VCGeneration/VC.ssc | 16 ++++++---------- 1 file 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 mergedSuccessors = new Dictionary(); 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; -- cgit v1.2.3