From 8b20f88b0a8d1b374dd5eaae289d19734c77b8f8 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Fri, 19 Jun 2015 16:17:05 +0100 Subject: Be careful with predecessor/successor index. When we simplify the CFG, we must preserve things that were already simplified. For example, the index in the predecessor list or successor list of a block must be preserved for ensuring the first block is a loop pre header. bug:21867463 Change-Id: Ic3fcb3eb2c3fb109d8a57ee2a6b6d4d65fdb9410 --- compiler/optimizing/nodes.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'compiler/optimizing/nodes.cc') diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index 68c197e607..01eb2d7f86 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -180,8 +180,9 @@ void HGraph::SplitCriticalEdge(HBasicBlock* block, HBasicBlock* successor) { HBasicBlock* new_block = new (arena_) HBasicBlock(this, successor->GetDexPc()); AddBlock(new_block); new_block->AddInstruction(new (arena_) HGoto()); - block->ReplaceSuccessor(successor, new_block); - new_block->AddSuccessor(successor); + // Use `InsertBetween` to ensure the predecessor index and successor index of + // `block` and `successor` are preserved. + new_block->InsertBetween(block, successor); if (successor->IsLoopHeader()) { // If we split at a back edge boundary, make the new block the back edge. HLoopInformation* info = successor->GetLoopInformation(); -- cgit v1.2.3-59-g8ed1b