diff options
| author | 2015-02-04 14:52:20 +0000 | |
|---|---|---|
| committer | 2015-02-04 15:08:37 +0000 | |
| commit | be31ff94d66a0037c445eb57dc82f2a51bb46d9e (patch) | |
| tree | 2eb41a8786b2f0d1d42bc9bbecfe831b3b9bc17c /compiler/optimizing/nodes.cc | |
| parent | a6919983bfc7e2c1eb69a4408f940146a2b78d59 (diff) | |
Fix a bug in the inliner.
Code did not work in the presence of multiple returns.
Spotted by Mark P. Mendell.
Change-Id: I237050a0d79c0cfaa479e9b886f7450879e84713
Diffstat (limited to 'compiler/optimizing/nodes.cc')
| -rw-r--r-- | compiler/optimizing/nodes.cc | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index f1868cb35f..cd36598171 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -867,8 +867,11 @@ void HGraph::InlineInto(HGraph* outer_graph, HInvoke* invoke) { } if (GetBlocks().Size() == 3) { - // Simple case: Put the first block's instruction into `invoke`'s block. + // Simple case of an entry block, a body block, and an exit block. + // Put the body block's instruction into `invoke`'s block. HBasicBlock* body = GetBlocks().Get(1); + DCHECK(GetBlocks().Get(0)->IsEntryBlock()); + DCHECK(GetBlocks().Get(2)->IsExitBlock()); DCHECK(!body->IsExitBlock()); HInstruction* last = body->GetLastInstruction(); @@ -886,7 +889,7 @@ void HGraph::InlineInto(HGraph* outer_graph, HInvoke* invoke) { } else { // Need to inline multiple blocks. We split `invoke`'s block // into two blocks, merge the first block of the inlined graph into - // the first half, and replace the exit block if the inlined graph + // the first half, and replace the exit block of the inlined graph // with the second half. ArenaAllocator* allocator = outer_graph->GetArena(); HBasicBlock* at = invoke->GetBlock(); @@ -908,10 +911,9 @@ void HGraph::InlineInto(HGraph* outer_graph, HInvoke* invoke) { if (!last->IsReturnVoid()) { if (return_value != nullptr) { if (!return_value->IsPhi()) { - HPhi* phi = new (allocator) HPhi( - allocator, kNoRegNumber, to->GetPredecessors().Size(), invoke->GetType()); - return_value->AsPhi()->AddInput(return_value); + HPhi* phi = new (allocator) HPhi(allocator, kNoRegNumber, 0, invoke->GetType()); to->AddPhi(phi); + phi->AddInput(return_value); return_value = phi; } return_value->AsPhi()->AddInput(last->InputAt(0)); |