diff options
author | Andreas Gampe <agampe@google.com> | 2014-06-13 13:44:40 -0700 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2014-06-13 13:46:51 -0700 |
commit | 4439596b00c91f565370bf0813cc2f9165093693 (patch) | |
tree | 2e2e9ccaea2cea7e4066f2b90cfab50f36b4f099 | |
parent | 08eeb38bb95dbb41dbdb0ea023749889b126af61 (diff) | |
download | android_art-4439596b00c91f565370bf0813cc2f9165093693.tar.gz android_art-4439596b00c91f565370bf0813cc2f9165093693.tar.bz2 android_art-4439596b00c91f565370bf0813cc2f9165093693.zip |
ART: Hide unreachable basic blocks in the compiler
Unreachable blocks are not handled uniformly in the optimization
passes. Uniformly hide them to avoid initialization errors.
Bug: 15573463
Change-Id: Ia9e89fa357d5672a6cd8389f28a06ff618fe60ee
-rw-r--r-- | compiler/dex/frontend.cc | 2 | ||||
-rw-r--r-- | compiler/dex/mir_graph.cc | 2 | ||||
-rw-r--r-- | compiler/dex/mir_graph.h | 6 | ||||
-rw-r--r-- | compiler/dex/ssa_transformation.cc | 10 |
4 files changed, 15 insertions, 5 deletions
diff --git a/compiler/dex/frontend.cc b/compiler/dex/frontend.cc index d45379712b..ca15964b92 100644 --- a/compiler/dex/frontend.cc +++ b/compiler/dex/frontend.cc @@ -756,7 +756,7 @@ static bool CanCompileMethod(uint32_t method_idx, const DexFile& dex_file, support_list_size = arraysize(x86_64_support_list); } - for (int idx = 0; idx < cu.mir_graph->GetNumBlocks(); idx++) { + for (unsigned int idx = 0; idx < cu.mir_graph->GetNumBlocks(); idx++) { BasicBlock* bb = cu.mir_graph->GetBasicBlock(idx); if (bb == NULL) continue; if (bb->block_type == kDead) continue; diff --git a/compiler/dex/mir_graph.cc b/compiler/dex/mir_graph.cc index a2676c82ca..63a55707e5 100644 --- a/compiler/dex/mir_graph.cc +++ b/compiler/dex/mir_graph.cc @@ -586,7 +586,7 @@ void MIRGraph::InlineMethod(const DexFile::CodeItem* code_item, uint32_t access_ if (current_method_ == 0) { DCHECK(entry_block_ == NULL); DCHECK(exit_block_ == NULL); - DCHECK_EQ(num_blocks_, 0); + DCHECK_EQ(num_blocks_, 0U); // Use id 0 to represent a null block. BasicBlock* null_block = NewMemBB(kNullBlock, num_blocks_++); DCHECK_EQ(null_block->id, NullBasicBlockId); diff --git a/compiler/dex/mir_graph.h b/compiler/dex/mir_graph.h index b6cec662c3..27b8ca43aa 100644 --- a/compiler/dex/mir_graph.h +++ b/compiler/dex/mir_graph.h @@ -587,7 +587,7 @@ class MIRGraph { return m_units_[m_unit_index]->GetCodeItem()->insns_; } - int GetNumBlocks() const { + unsigned int GetNumBlocks() const { return num_blocks_; } @@ -607,7 +607,7 @@ class MIRGraph { return exit_block_; } - BasicBlock* GetBasicBlock(int block_id) const { + BasicBlock* GetBasicBlock(unsigned int block_id) const { return (block_id == NullBasicBlockId) ? NULL : block_list_.Get(block_id); } @@ -1149,7 +1149,7 @@ class MIRGraph { ArenaBitVector* try_block_addr_; BasicBlock* entry_block_; BasicBlock* exit_block_; - int num_blocks_; + unsigned int num_blocks_; const DexFile::CodeItem* current_code_item_; GrowableArray<uint16_t> dex_pc_to_block_map_; // FindBlock lookup cache. std::vector<DexCompilationUnit*> m_units_; // List of methods included in this graph diff --git a/compiler/dex/ssa_transformation.cc b/compiler/dex/ssa_transformation.cc index 43243254f1..e26745ad5e 100644 --- a/compiler/dex/ssa_transformation.cc +++ b/compiler/dex/ssa_transformation.cc @@ -117,6 +117,16 @@ void MIRGraph::ComputeDFSOrders() { RecordDFSOrders(GetEntryBlock()); num_reachable_blocks_ = dfs_order_->Size(); + + if (num_reachable_blocks_ != num_blocks_) { + // Hide all unreachable blocks. + AllNodesIterator iter(this); + for (BasicBlock* bb = iter.Next(); bb != NULL; bb = iter.Next()) { + if (!bb->visited) { + bb->Hide(cu_); + } + } + } } /* |