diff options
author | Vladimir Marko <vmarko@google.com> | 2015-02-09 12:35:05 +0000 |
---|---|---|
committer | Vladimir Marko <vmarko@google.com> | 2015-02-10 18:09:21 +0000 |
commit | 6a8946ba3d170fee0ff06de42209be4b14e6aff3 (patch) | |
tree | 096e0cf6e9d4b529e22b417dad8432c42b9a8c82 /compiler/dex/mir_dataflow.cc | |
parent | 4ba86c428f839cb75f5838b8327e893694377590 (diff) | |
download | art-6a8946ba3d170fee0ff06de42209be4b14e6aff3.zip art-6a8946ba3d170fee0ff06de42209be4b14e6aff3.tar.gz art-6a8946ba3d170fee0ff06de42209be4b14e6aff3.tar.bz2 |
Quick: Rewrite Phi node insertion.
Delay Phi node insertion to the SSAConversion pass to allow
updating the vreg_to_ssa_map_ with INVALID_SREG when we omit
a Phi in the pruned SSA form.
Change-Id: I450dee21f7dc4353d25fc66f4d0ee01671de6e0e
Diffstat (limited to 'compiler/dex/mir_dataflow.cc')
-rw-r--r-- | compiler/dex/mir_dataflow.cc | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/compiler/dex/mir_dataflow.cc b/compiler/dex/mir_dataflow.cc index f09d1ae..a1f4294 100644 --- a/compiler/dex/mir_dataflow.cc +++ b/compiler/dex/mir_dataflow.cc @@ -1198,11 +1198,30 @@ void MIRGraph::DataFlowSSAFormatExtended(MIR* mir) { /* Entry function to convert a block into SSA representation */ bool MIRGraph::DoSSAConversion(BasicBlock* bb) { - MIR* mir; - if (bb->data_flow_info == NULL) return false; - for (mir = bb->first_mir_insn; mir != NULL; mir = mir->next) { + /* + * Pruned SSA form: Insert phi nodes for each dalvik register marked in phi_node_blocks + * only if the dalvik register is in the live-in set. + */ + BasicBlockId bb_id = bb->id; + for (int dalvik_reg = GetNumOfCodeAndTempVRs() - 1; dalvik_reg >= 0; dalvik_reg--) { + if (temp_.ssa.phi_node_blocks[dalvik_reg]->IsBitSet(bb_id)) { + if (!bb->data_flow_info->live_in_v->IsBitSet(dalvik_reg)) { + /* Variable will be clobbered before being used - no need for phi */ + vreg_to_ssa_map_[dalvik_reg] = INVALID_SREG; + continue; + } + MIR *phi = NewMIR(); + phi->dalvikInsn.opcode = static_cast<Instruction::Code>(kMirOpPhi); + phi->dalvikInsn.vA = dalvik_reg; + phi->offset = bb->start_offset; + phi->m_unit_index = 0; // Arbitrarily assign all Phi nodes to outermost method. + bb->PrependMIR(phi); + } + } + + for (MIR* mir = bb->first_mir_insn; mir != NULL; mir = mir->next) { mir->ssa_rep = static_cast<struct SSARepresentation *>(arena_->Alloc(sizeof(SSARepresentation), kArenaAllocDFInfo)); |