Index: optimizer/FlowGraph.h =================================================================== --- optimizer/FlowGraph.h (revision 469074) +++ optimizer/FlowGraph.h (working copy) @@ -57,7 +57,7 @@ // If !isTaken, then the false edge is converted, and the true edge // is deleted. In either case, the branch instruction br is removed // from block. - static void foldBranch(ControlFlowGraph& fg, Node* block, BranchInst* br, bool isTaken); + static void foldBranch(ControlFlowGraph& fg, BranchInst* br, bool isTaken); static void foldSwitch(ControlFlowGraph& fg, Node* block, SwitchInst* sw, uint32 target); Index: optimizer/simplifier.cpp =================================================================== --- optimizer/simplifier.cpp (revision 469074) +++ optimizer/simplifier.cpp (working copy) @@ -21,6 +21,7 @@ * */ + #include "Opcode.h" #include "Opnd.h" #include "Type.h" @@ -3821,7 +3822,7 @@ void SimplifierWithInstFactory::foldBranch(BranchInst* br, bool isTaken) { - FlowGraph::foldBranch(flowGraph, currentCfgNode,br,isTaken); + FlowGraph::foldBranch(flowGraph, br,isTaken); } void Index: optimizer/tailduplicator.cpp =================================================================== --- optimizer/tailduplicator.cpp (revision 469074) +++ optimizer/tailduplicator.cpp (working copy) @@ -116,8 +116,8 @@ ControlFlowGraph& fg = _irm.getFlowGraph(); Node* copy = FlowGraph::tailDuplicate(_irm, t2, tail, defUses); - FlowGraph::foldBranch(fg, copy, ((Inst*)copy->getLastInst())->asBranchInst(), true); - FlowGraph::foldBranch(fg, tail, ((Inst*)tail->getLastInst())->asBranchInst(), false); + FlowGraph::foldBranch(fg, ((Inst*)copy->getLastInst())->asBranchInst(), true); + FlowGraph::foldBranch(fg, ((Inst*)tail->getLastInst())->asBranchInst(), false); } void Index: optimizer/FlowGraph.cpp =================================================================== --- optimizer/FlowGraph.cpp (revision 469074) +++ optimizer/FlowGraph.cpp (working copy) @@ -66,10 +66,11 @@ void -FlowGraph::foldBranch(ControlFlowGraph& fg, Node* block, BranchInst* br, bool isTaken) +FlowGraph::foldBranch(ControlFlowGraph& fg, BranchInst* br, bool isTaken) { - assert(br == block->getLastInst()); - assert(block->getOutDegree() == 2); + Node* block = br->getNode(); + assert(block->getOutDegree() == 2); + fg.removeEdge(block->getOutEdge(isTaken ? Edge::Kind_False : Edge::Kind_True)); br->unlink(); } Index: optimizer/hashvaluenumberer.cpp =================================================================== --- optimizer/hashvaluenumberer.cpp (revision 469074) +++ optimizer/hashvaluenumberer.cpp (working copy) @@ -2520,9 +2520,9 @@ BranchInst *branchi = inst->asBranchInst(); if (branchi) { if (optimizedOpcode == Op_TauUnsafe) { - FlowGraph::foldBranch(fg, block, branchi, false); // not taken + FlowGraph::foldBranch(fg, branchi, false); // not taken } else { - FlowGraph::foldBranch(fg, block, branchi, true); // taken + FlowGraph::foldBranch(fg, branchi, true); // taken } return; } Index: shared/ControlFlowGraph.cpp =================================================================== --- shared/ControlFlowGraph.cpp (revision 469074) +++ shared/ControlFlowGraph.cpp (working copy) @@ -223,13 +223,14 @@ void ControlFlowGraph::removeNode(Nodes::iterator pos, bool erase) { Node* node = *pos; - assert(node!=entryNode); + if (node == entryNode) { + entryNode=NULL; + } if (node == returnNode) { returnNode = NULL; } else if(node == unwindNode) { unwindNode = NULL; } else if (node == exitNode) { - assert(0); exitNode = NULL; }