blob: 5f89c214f26e8ead9ed9b3453e527bc1951754a2 [file] [log] [blame]
buzbee67bf8852011-08-17 17:51:35 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Nicolas Geoffray0e336432014-02-26 18:24:38 +000017#include "bit_vector_block_iterator.h"
buzbeeeaf09bc2012-11-15 14:51:41 -080018#include "compiler_internals.h"
Ian Rogers8d3a1172013-06-04 01:13:28 -070019#include "dataflow_iterator-inl.h"
buzbee67bf8852011-08-17 17:51:35 -070020
buzbee1fd33462013-03-25 13:40:45 -070021#define NOTVISITED (-1)
22
Elliott Hughes11d1b0c2012-01-23 16:57:47 -080023namespace art {
24
buzbeea5abf702013-04-12 14:39:29 -070025void MIRGraph::ClearAllVisitedFlags() {
buzbee56c71782013-09-05 17:13:19 -070026 AllNodesIterator iter(this);
buzbeea5abf702013-04-12 14:39:29 -070027 for (BasicBlock* bb = iter.Next(); bb != NULL; bb = iter.Next()) {
28 bb->visited = false;
29 }
30}
31
buzbee311ca162013-02-28 15:56:43 -080032BasicBlock* MIRGraph::NeedsVisit(BasicBlock* bb) {
buzbeee5f01222012-06-14 15:19:35 -070033 if (bb != NULL) {
34 if (bb->visited || bb->hidden) {
35 bb = NULL;
36 }
37 }
38 return bb;
39}
40
Brian Carlstrom2ce745c2013-07-17 17:44:30 -070041BasicBlock* MIRGraph::NextUnvisitedSuccessor(BasicBlock* bb) {
buzbee0d829482013-10-11 15:24:55 -070042 BasicBlock* res = NeedsVisit(GetBasicBlock(bb->fall_through));
buzbeee5f01222012-06-14 15:19:35 -070043 if (res == NULL) {
buzbee0d829482013-10-11 15:24:55 -070044 res = NeedsVisit(GetBasicBlock(bb->taken));
buzbeee5f01222012-06-14 15:19:35 -070045 if (res == NULL) {
buzbee0d829482013-10-11 15:24:55 -070046 if (bb->successor_block_list_type != kNotUsed) {
47 GrowableArray<SuccessorBlockInfo*>::Iterator iterator(bb->successor_blocks);
buzbeee5f01222012-06-14 15:19:35 -070048 while (true) {
buzbee862a7602013-04-05 10:58:54 -070049 SuccessorBlockInfo *sbi = iterator.Next();
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -070050 if (sbi == NULL) {
51 break;
52 }
buzbee0d829482013-10-11 15:24:55 -070053 res = NeedsVisit(GetBasicBlock(sbi->block));
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -070054 if (res != NULL) {
55 break;
56 }
buzbeee5f01222012-06-14 15:19:35 -070057 }
58 }
59 }
60 }
61 return res;
62}
63
Brian Carlstrom2ce745c2013-07-17 17:44:30 -070064void MIRGraph::MarkPreOrder(BasicBlock* block) {
buzbeee5f01222012-06-14 15:19:35 -070065 block->visited = true;
buzbeefa57c472012-11-21 12:06:18 -080066 /* Enqueue the pre_order block id */
buzbee0d829482013-10-11 15:24:55 -070067 if (block->id != NullBasicBlockId) {
68 dfs_order_->Insert(block->id);
69 }
buzbeee5f01222012-06-14 15:19:35 -070070}
71
Brian Carlstrom2ce745c2013-07-17 17:44:30 -070072void MIRGraph::RecordDFSOrders(BasicBlock* block) {
buzbeee5f01222012-06-14 15:19:35 -070073 std::vector<BasicBlock*> succ;
buzbee311ca162013-02-28 15:56:43 -080074 MarkPreOrder(block);
buzbeee5f01222012-06-14 15:19:35 -070075 succ.push_back(block);
76 while (!succ.empty()) {
77 BasicBlock* curr = succ.back();
buzbeefa57c472012-11-21 12:06:18 -080078 BasicBlock* next_successor = NextUnvisitedSuccessor(curr);
79 if (next_successor != NULL) {
buzbee311ca162013-02-28 15:56:43 -080080 MarkPreOrder(next_successor);
buzbeefa57c472012-11-21 12:06:18 -080081 succ.push_back(next_successor);
buzbeee5f01222012-06-14 15:19:35 -070082 continue;
83 }
buzbee862a7602013-04-05 10:58:54 -070084 curr->dfs_id = dfs_post_order_->Size();
buzbee0d829482013-10-11 15:24:55 -070085 if (curr->id != NullBasicBlockId) {
86 dfs_post_order_->Insert(curr->id);
87 }
buzbeee5f01222012-06-14 15:19:35 -070088 succ.pop_back();
89 }
90}
91
buzbee5b537102012-01-17 17:33:47 -080092/* Sort the blocks by the Depth-First-Search */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -070093void MIRGraph::ComputeDFSOrders() {
buzbeefa57c472012-11-21 12:06:18 -080094 /* Initialize or reset the DFS pre_order list */
buzbee862a7602013-04-05 10:58:54 -070095 if (dfs_order_ == NULL) {
buzbee0d829482013-10-11 15:24:55 -070096 dfs_order_ = new (arena_) GrowableArray<BasicBlockId>(arena_, GetNumBlocks(),
97 kGrowableArrayDfsOrder);
Bill Buzbeea114add2012-05-03 15:00:40 -070098 } else {
99 /* Just reset the used length on the counter */
buzbee862a7602013-04-05 10:58:54 -0700100 dfs_order_->Reset();
Bill Buzbeea114add2012-05-03 15:00:40 -0700101 }
buzbee67bf8852011-08-17 17:51:35 -0700102
buzbeefa57c472012-11-21 12:06:18 -0800103 /* Initialize or reset the DFS post_order list */
buzbee862a7602013-04-05 10:58:54 -0700104 if (dfs_post_order_ == NULL) {
buzbee0d829482013-10-11 15:24:55 -0700105 dfs_post_order_ = new (arena_) GrowableArray<BasicBlockId>(arena_, GetNumBlocks(),
106 kGrowableArrayDfsPostOrder);
Bill Buzbeea114add2012-05-03 15:00:40 -0700107 } else {
108 /* Just reset the used length on the counter */
buzbee862a7602013-04-05 10:58:54 -0700109 dfs_post_order_->Reset();
Bill Buzbeea114add2012-05-03 15:00:40 -0700110 }
buzbee5b537102012-01-17 17:33:47 -0800111
buzbeee5f01222012-06-14 15:19:35 -0700112 // Reset visited flags from all nodes
buzbeea5abf702013-04-12 14:39:29 -0700113 ClearAllVisitedFlags();
114
buzbeee5f01222012-06-14 15:19:35 -0700115 // Record dfs orders
buzbee311ca162013-02-28 15:56:43 -0800116 RecordDFSOrders(GetEntryBlock());
buzbeee5f01222012-06-14 15:19:35 -0700117
buzbee862a7602013-04-05 10:58:54 -0700118 num_reachable_blocks_ = dfs_order_->Size();
buzbee67bf8852011-08-17 17:51:35 -0700119}
120
121/*
122 * Mark block bit on the per-Dalvik register vector to denote that Dalvik
123 * register idx is defined in BasicBlock bb.
124 */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700125bool MIRGraph::FillDefBlockMatrix(BasicBlock* bb) {
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700126 if (bb->data_flow_info == NULL) {
127 return false;
128 }
buzbee67bf8852011-08-17 17:51:35 -0700129
buzbee862a7602013-04-05 10:58:54 -0700130 ArenaBitVector::Iterator iterator(bb->data_flow_info->def_v);
Bill Buzbeea114add2012-05-03 15:00:40 -0700131 while (true) {
buzbee862a7602013-04-05 10:58:54 -0700132 int idx = iterator.Next();
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700133 if (idx == -1) {
134 break;
135 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700136 /* Block bb defines register idx */
buzbee862a7602013-04-05 10:58:54 -0700137 def_block_matrix_[idx]->SetBit(bb->id);
Bill Buzbeea114add2012-05-03 15:00:40 -0700138 }
139 return true;
buzbee67bf8852011-08-17 17:51:35 -0700140}
141
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700142void MIRGraph::ComputeDefBlockMatrix() {
buzbee311ca162013-02-28 15:56:43 -0800143 int num_registers = cu_->num_dalvik_registers;
buzbeefa57c472012-11-21 12:06:18 -0800144 /* Allocate num_dalvik_registers bit vector pointers */
buzbee311ca162013-02-28 15:56:43 -0800145 def_block_matrix_ = static_cast<ArenaBitVector**>
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700146 (arena_->Alloc(sizeof(ArenaBitVector *) * num_registers,
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000147 kArenaAllocDFInfo));
Bill Buzbeea114add2012-05-03 15:00:40 -0700148 int i;
buzbee67bf8852011-08-17 17:51:35 -0700149
buzbeefa57c472012-11-21 12:06:18 -0800150 /* Initialize num_register vectors with num_blocks bits each */
151 for (i = 0; i < num_registers; i++) {
buzbee862a7602013-04-05 10:58:54 -0700152 def_block_matrix_[i] =
153 new (arena_) ArenaBitVector(arena_, GetNumBlocks(), false, kBitMapBMatrix);
Bill Buzbeea114add2012-05-03 15:00:40 -0700154 }
buzbee56c71782013-09-05 17:13:19 -0700155 AllNodesIterator iter(this);
buzbee311ca162013-02-28 15:56:43 -0800156 for (BasicBlock* bb = iter.Next(); bb != NULL; bb = iter.Next()) {
157 FindLocalLiveIn(bb);
158 }
buzbee56c71782013-09-05 17:13:19 -0700159 AllNodesIterator iter2(this);
buzbee311ca162013-02-28 15:56:43 -0800160 for (BasicBlock* bb = iter2.Next(); bb != NULL; bb = iter2.Next()) {
161 FillDefBlockMatrix(bb);
162 }
buzbee67bf8852011-08-17 17:51:35 -0700163
Bill Buzbeea114add2012-05-03 15:00:40 -0700164 /*
165 * Also set the incoming parameters as defs in the entry block.
166 * Only need to handle the parameters for the outer method.
167 */
buzbee311ca162013-02-28 15:56:43 -0800168 int num_regs = cu_->num_dalvik_registers;
169 int in_reg = num_regs - cu_->num_ins;
buzbeefa57c472012-11-21 12:06:18 -0800170 for (; in_reg < num_regs; in_reg++) {
buzbee862a7602013-04-05 10:58:54 -0700171 def_block_matrix_[in_reg]->SetBit(GetEntryBlock()->id);
Bill Buzbeea114add2012-05-03 15:00:40 -0700172 }
buzbee67bf8852011-08-17 17:51:35 -0700173}
174
buzbeea5abf702013-04-12 14:39:29 -0700175void MIRGraph::ComputeDomPostOrderTraversal(BasicBlock* bb) {
176 if (dom_post_order_traversal_ == NULL) {
177 // First time - create the array.
178 dom_post_order_traversal_ =
buzbee0d829482013-10-11 15:24:55 -0700179 new (arena_) GrowableArray<BasicBlockId>(arena_, num_reachable_blocks_,
buzbeea5abf702013-04-12 14:39:29 -0700180 kGrowableArrayDomPostOrderTraversal);
181 } else {
182 dom_post_order_traversal_->Reset();
Bill Buzbeea114add2012-05-03 15:00:40 -0700183 }
buzbeea5abf702013-04-12 14:39:29 -0700184 ClearAllVisitedFlags();
185 std::vector<std::pair<BasicBlock*, ArenaBitVector::Iterator*> > work_stack;
186 bb->visited = true;
Brian Carlstrom413e89f2013-10-21 23:53:49 -0700187 work_stack.push_back(std::make_pair(bb, bb->i_dominated->GetIterator()));
buzbeea5abf702013-04-12 14:39:29 -0700188 while (!work_stack.empty()) {
Sebastien Hertz74e256b2013-10-04 10:40:37 +0200189 const std::pair<BasicBlock*, ArenaBitVector::Iterator*>& curr = work_stack.back();
buzbeea5abf702013-04-12 14:39:29 -0700190 BasicBlock* curr_bb = curr.first;
191 ArenaBitVector::Iterator* curr_idom_iter = curr.second;
192 int bb_idx = curr_idom_iter->Next();
193 while ((bb_idx != -1) && (NeedsVisit(GetBasicBlock(bb_idx)) == NULL)) {
194 bb_idx = curr_idom_iter->Next();
195 }
196 if (bb_idx != -1) {
197 BasicBlock* new_bb = GetBasicBlock(bb_idx);
198 new_bb->visited = true;
199 work_stack.push_back(
Brian Carlstrom413e89f2013-10-21 23:53:49 -0700200 std::make_pair(new_bb, new_bb->i_dominated->GetIterator()));
buzbeea5abf702013-04-12 14:39:29 -0700201 } else {
202 // no successor/next
buzbee0d829482013-10-11 15:24:55 -0700203 if (curr_bb->id != NullBasicBlockId) {
204 dom_post_order_traversal_->Insert(curr_bb->id);
205 }
buzbeea5abf702013-04-12 14:39:29 -0700206 work_stack.pop_back();
buzbee67bf8852011-08-17 17:51:35 -0700207
buzbeea5abf702013-04-12 14:39:29 -0700208 /* hacky loop detection */
buzbee0d829482013-10-11 15:24:55 -0700209 if ((curr_bb->taken != NullBasicBlockId) && curr_bb->dominators->IsBitSet(curr_bb->taken)) {
Bill Buzbee0b1191c2013-10-28 22:11:59 +0000210 curr_bb->nesting_depth++;
buzbeea5abf702013-04-12 14:39:29 -0700211 attributes_ |= METHOD_HAS_LOOP;
212 }
213 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700214 }
buzbee67bf8852011-08-17 17:51:35 -0700215}
216
buzbee311ca162013-02-28 15:56:43 -0800217void MIRGraph::CheckForDominanceFrontier(BasicBlock* dom_bb,
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700218 const BasicBlock* succ_bb) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700219 /*
220 * TODO - evaluate whether phi will ever need to be inserted into exit
221 * blocks.
222 */
buzbee0d829482013-10-11 15:24:55 -0700223 if (succ_bb->i_dom != dom_bb->id &&
buzbeefa57c472012-11-21 12:06:18 -0800224 succ_bb->block_type == kDalvikByteCode &&
225 succ_bb->hidden == false) {
buzbee862a7602013-04-05 10:58:54 -0700226 dom_bb->dom_frontier->SetBit(succ_bb->id);
Bill Buzbeea114add2012-05-03 15:00:40 -0700227 }
buzbee67bf8852011-08-17 17:51:35 -0700228}
229
230/* Worker function to compute the dominance frontier */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700231bool MIRGraph::ComputeDominanceFrontier(BasicBlock* bb) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700232 /* Calculate DF_local */
buzbee0d829482013-10-11 15:24:55 -0700233 if (bb->taken != NullBasicBlockId) {
234 CheckForDominanceFrontier(bb, GetBasicBlock(bb->taken));
Bill Buzbeea114add2012-05-03 15:00:40 -0700235 }
buzbee0d829482013-10-11 15:24:55 -0700236 if (bb->fall_through != NullBasicBlockId) {
237 CheckForDominanceFrontier(bb, GetBasicBlock(bb->fall_through));
Bill Buzbeea114add2012-05-03 15:00:40 -0700238 }
buzbee0d829482013-10-11 15:24:55 -0700239 if (bb->successor_block_list_type != kNotUsed) {
240 GrowableArray<SuccessorBlockInfo*>::Iterator iterator(bb->successor_blocks);
Bill Buzbeea114add2012-05-03 15:00:40 -0700241 while (true) {
buzbee862a7602013-04-05 10:58:54 -0700242 SuccessorBlockInfo *successor_block_info = iterator.Next();
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700243 if (successor_block_info == NULL) {
244 break;
245 }
buzbee0d829482013-10-11 15:24:55 -0700246 BasicBlock* succ_bb = GetBasicBlock(successor_block_info->block);
buzbee311ca162013-02-28 15:56:43 -0800247 CheckForDominanceFrontier(bb, succ_bb);
Bill Buzbeea114add2012-05-03 15:00:40 -0700248 }
249 }
buzbee67bf8852011-08-17 17:51:35 -0700250
Bill Buzbeea114add2012-05-03 15:00:40 -0700251 /* Calculate DF_up */
Nicolas Geoffray0e336432014-02-26 18:24:38 +0000252 BitVectorBlockIterator it(bb->i_dominated, cu_);
Jean Christophe Beylerf7a82b42014-02-10 22:12:58 -0800253 for (BasicBlock *dominated_bb = it.Next(); dominated_bb != nullptr; dominated_bb = it.Next()) {
Nicolas Geoffray0e336432014-02-26 18:24:38 +0000254 BitVectorBlockIterator inner_it(dominated_bb->dom_frontier, cu_);
Jean Christophe Beylerf7a82b42014-02-10 22:12:58 -0800255 for (BasicBlock *df_up_block = inner_it.Next(); df_up_block != nullptr;
256 df_up_block = inner_it.Next()) {
buzbee311ca162013-02-28 15:56:43 -0800257 CheckForDominanceFrontier(bb, df_up_block);
buzbee67bf8852011-08-17 17:51:35 -0700258 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700259 }
buzbee67bf8852011-08-17 17:51:35 -0700260
Bill Buzbeea114add2012-05-03 15:00:40 -0700261 return true;
buzbee67bf8852011-08-17 17:51:35 -0700262}
263
264/* Worker function for initializing domination-related data structures */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700265void MIRGraph::InitializeDominationInfo(BasicBlock* bb) {
buzbee311ca162013-02-28 15:56:43 -0800266 int num_total_blocks = GetBasicBlockListCount();
buzbee67bf8852011-08-17 17:51:35 -0700267
Brian Carlstromdf629502013-07-17 22:39:56 -0700268 if (bb->dominators == NULL) {
buzbee862a7602013-04-05 10:58:54 -0700269 bb->dominators = new (arena_) ArenaBitVector(arena_, num_total_blocks,
270 false /* expandable */, kBitMapDominators);
271 bb->i_dominated = new (arena_) ArenaBitVector(arena_, num_total_blocks,
272 false /* expandable */, kBitMapIDominated);
273 bb->dom_frontier = new (arena_) ArenaBitVector(arena_, num_total_blocks,
274 false /* expandable */, kBitMapDomFrontier);
Bill Buzbeea114add2012-05-03 15:00:40 -0700275 } else {
buzbee862a7602013-04-05 10:58:54 -0700276 bb->dominators->ClearAllBits();
277 bb->i_dominated->ClearAllBits();
278 bb->dom_frontier->ClearAllBits();
Bill Buzbeea114add2012-05-03 15:00:40 -0700279 }
280 /* Set all bits in the dominator vector */
buzbee862a7602013-04-05 10:58:54 -0700281 bb->dominators->SetInitialBits(num_total_blocks);
buzbee67bf8852011-08-17 17:51:35 -0700282
buzbee862a7602013-04-05 10:58:54 -0700283 return;
buzbee67bf8852011-08-17 17:51:35 -0700284}
285
buzbee5b537102012-01-17 17:33:47 -0800286/*
buzbeefa57c472012-11-21 12:06:18 -0800287 * Walk through the ordered i_dom list until we reach common parent.
288 * Given the ordering of i_dom_list, this common parent represents the
buzbee5b537102012-01-17 17:33:47 -0800289 * last element of the intersection of block1 and block2 dominators.
290 */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700291int MIRGraph::FindCommonParent(int block1, int block2) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700292 while (block1 != block2) {
293 while (block1 < block2) {
buzbee311ca162013-02-28 15:56:43 -0800294 block1 = i_dom_list_[block1];
Bill Buzbeea114add2012-05-03 15:00:40 -0700295 DCHECK_NE(block1, NOTVISITED);
buzbee5b537102012-01-17 17:33:47 -0800296 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700297 while (block2 < block1) {
buzbee311ca162013-02-28 15:56:43 -0800298 block2 = i_dom_list_[block2];
Bill Buzbeea114add2012-05-03 15:00:40 -0700299 DCHECK_NE(block2, NOTVISITED);
300 }
301 }
302 return block1;
buzbee5b537102012-01-17 17:33:47 -0800303}
304
305/* Worker function to compute each block's immediate dominator */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700306bool MIRGraph::ComputeblockIDom(BasicBlock* bb) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700307 /* Special-case entry block */
buzbee0d829482013-10-11 15:24:55 -0700308 if ((bb->id == NullBasicBlockId) || (bb == GetEntryBlock())) {
buzbee5b537102012-01-17 17:33:47 -0800309 return false;
Bill Buzbeea114add2012-05-03 15:00:40 -0700310 }
311
312 /* Iterate through the predecessors */
buzbee0d829482013-10-11 15:24:55 -0700313 GrowableArray<BasicBlockId>::Iterator iter(bb->predecessors);
Bill Buzbeea114add2012-05-03 15:00:40 -0700314
315 /* Find the first processed predecessor */
buzbee862a7602013-04-05 10:58:54 -0700316 int idom = -1;
Bill Buzbeea114add2012-05-03 15:00:40 -0700317 while (true) {
buzbee0d829482013-10-11 15:24:55 -0700318 BasicBlock* pred_bb = GetBasicBlock(iter.Next());
buzbeefa57c472012-11-21 12:06:18 -0800319 CHECK(pred_bb != NULL);
buzbee311ca162013-02-28 15:56:43 -0800320 if (i_dom_list_[pred_bb->dfs_id] != NOTVISITED) {
buzbeefa57c472012-11-21 12:06:18 -0800321 idom = pred_bb->dfs_id;
Bill Buzbeea114add2012-05-03 15:00:40 -0700322 break;
323 }
324 }
325
326 /* Scan the rest of the predecessors */
327 while (true) {
buzbee0d829482013-10-11 15:24:55 -0700328 BasicBlock* pred_bb = GetBasicBlock(iter.Next());
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700329 if (!pred_bb) {
330 break;
331 }
buzbee311ca162013-02-28 15:56:43 -0800332 if (i_dom_list_[pred_bb->dfs_id] == NOTVISITED) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700333 continue;
334 } else {
buzbee311ca162013-02-28 15:56:43 -0800335 idom = FindCommonParent(pred_bb->dfs_id, idom);
Bill Buzbeea114add2012-05-03 15:00:40 -0700336 }
337 }
338
339 DCHECK_NE(idom, NOTVISITED);
340
341 /* Did something change? */
buzbee311ca162013-02-28 15:56:43 -0800342 if (i_dom_list_[bb->dfs_id] != idom) {
343 i_dom_list_[bb->dfs_id] = idom;
Bill Buzbeea114add2012-05-03 15:00:40 -0700344 return true;
345 }
346 return false;
buzbee5b537102012-01-17 17:33:47 -0800347}
348
349/* Worker function to compute each block's domintors */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700350bool MIRGraph::ComputeBlockDominators(BasicBlock* bb) {
buzbee311ca162013-02-28 15:56:43 -0800351 if (bb == GetEntryBlock()) {
buzbee862a7602013-04-05 10:58:54 -0700352 bb->dominators->ClearAllBits();
Bill Buzbeea114add2012-05-03 15:00:40 -0700353 } else {
buzbee0d829482013-10-11 15:24:55 -0700354 bb->dominators->Copy(GetBasicBlock(bb->i_dom)->dominators);
Bill Buzbeea114add2012-05-03 15:00:40 -0700355 }
buzbee862a7602013-04-05 10:58:54 -0700356 bb->dominators->SetBit(bb->id);
Bill Buzbeea114add2012-05-03 15:00:40 -0700357 return false;
buzbee5b537102012-01-17 17:33:47 -0800358}
359
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700360bool MIRGraph::SetDominators(BasicBlock* bb) {
buzbee311ca162013-02-28 15:56:43 -0800361 if (bb != GetEntryBlock()) {
362 int idom_dfs_idx = i_dom_list_[bb->dfs_id];
buzbeefa57c472012-11-21 12:06:18 -0800363 DCHECK_NE(idom_dfs_idx, NOTVISITED);
buzbee862a7602013-04-05 10:58:54 -0700364 int i_dom_idx = dfs_post_order_->Get(idom_dfs_idx);
buzbee311ca162013-02-28 15:56:43 -0800365 BasicBlock* i_dom = GetBasicBlock(i_dom_idx);
buzbee0d829482013-10-11 15:24:55 -0700366 bb->i_dom = i_dom->id;
buzbeefa57c472012-11-21 12:06:18 -0800367 /* Add bb to the i_dominated set of the immediate dominator block */
buzbee862a7602013-04-05 10:58:54 -0700368 i_dom->i_dominated->SetBit(bb->id);
Bill Buzbeea114add2012-05-03 15:00:40 -0700369 }
370 return false;
buzbee5b537102012-01-17 17:33:47 -0800371}
372
buzbee67bf8852011-08-17 17:51:35 -0700373/* Compute dominators, immediate dominator, and dominance fronter */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700374void MIRGraph::ComputeDominators() {
buzbee311ca162013-02-28 15:56:43 -0800375 int num_reachable_blocks = num_reachable_blocks_;
buzbee67bf8852011-08-17 17:51:35 -0700376
Bill Buzbeea114add2012-05-03 15:00:40 -0700377 /* Initialize domination-related data structures */
buzbee56c71782013-09-05 17:13:19 -0700378 PreOrderDfsIterator iter(this);
buzbee311ca162013-02-28 15:56:43 -0800379 for (BasicBlock* bb = iter.Next(); bb != NULL; bb = iter.Next()) {
380 InitializeDominationInfo(bb);
381 }
buzbee67bf8852011-08-17 17:51:35 -0700382
buzbeefa57c472012-11-21 12:06:18 -0800383 /* Initalize & Clear i_dom_list */
buzbee311ca162013-02-28 15:56:43 -0800384 if (i_dom_list_ == NULL) {
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700385 i_dom_list_ = static_cast<int*>(arena_->Alloc(sizeof(int) * num_reachable_blocks,
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000386 kArenaAllocDFInfo));
Bill Buzbeea114add2012-05-03 15:00:40 -0700387 }
buzbeefa57c472012-11-21 12:06:18 -0800388 for (int i = 0; i < num_reachable_blocks; i++) {
buzbee311ca162013-02-28 15:56:43 -0800389 i_dom_list_[i] = NOTVISITED;
Bill Buzbeea114add2012-05-03 15:00:40 -0700390 }
buzbee5b537102012-01-17 17:33:47 -0800391
buzbeefa57c472012-11-21 12:06:18 -0800392 /* For post-order, last block is entry block. Set its i_dom to istelf */
buzbee311ca162013-02-28 15:56:43 -0800393 DCHECK_EQ(GetEntryBlock()->dfs_id, num_reachable_blocks-1);
394 i_dom_list_[GetEntryBlock()->dfs_id] = GetEntryBlock()->dfs_id;
buzbee5b537102012-01-17 17:33:47 -0800395
Bill Buzbeea114add2012-05-03 15:00:40 -0700396 /* Compute the immediate dominators */
buzbee56c71782013-09-05 17:13:19 -0700397 RepeatingReversePostOrderDfsIterator iter2(this);
buzbee311ca162013-02-28 15:56:43 -0800398 bool change = false;
399 for (BasicBlock* bb = iter2.Next(false); bb != NULL; bb = iter2.Next(change)) {
400 change = ComputeblockIDom(bb);
401 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700402
403 /* Set the dominator for the root node */
buzbee862a7602013-04-05 10:58:54 -0700404 GetEntryBlock()->dominators->ClearAllBits();
405 GetEntryBlock()->dominators->SetBit(GetEntryBlock()->id);
Bill Buzbeea114add2012-05-03 15:00:40 -0700406
buzbee0d829482013-10-11 15:24:55 -0700407 GetEntryBlock()->i_dom = 0;
Bill Buzbeea114add2012-05-03 15:00:40 -0700408
buzbee56c71782013-09-05 17:13:19 -0700409 PreOrderDfsIterator iter3(this);
buzbee311ca162013-02-28 15:56:43 -0800410 for (BasicBlock* bb = iter3.Next(); bb != NULL; bb = iter3.Next()) {
411 SetDominators(bb);
Bill Buzbeea114add2012-05-03 15:00:40 -0700412 }
buzbee67bf8852011-08-17 17:51:35 -0700413
buzbee56c71782013-09-05 17:13:19 -0700414 ReversePostOrderDfsIterator iter4(this);
buzbee311ca162013-02-28 15:56:43 -0800415 for (BasicBlock* bb = iter4.Next(); bb != NULL; bb = iter4.Next()) {
416 ComputeBlockDominators(bb);
417 }
buzbee5b537102012-01-17 17:33:47 -0800418
buzbeea5abf702013-04-12 14:39:29 -0700419 // Compute the dominance frontier for each block.
buzbee311ca162013-02-28 15:56:43 -0800420 ComputeDomPostOrderTraversal(GetEntryBlock());
buzbee56c71782013-09-05 17:13:19 -0700421 PostOrderDOMIterator iter5(this);
buzbee311ca162013-02-28 15:56:43 -0800422 for (BasicBlock* bb = iter5.Next(); bb != NULL; bb = iter5.Next()) {
423 ComputeDominanceFrontier(bb);
424 }
buzbee67bf8852011-08-17 17:51:35 -0700425}
426
427/*
428 * Perform dest U= src1 ^ ~src2
429 * This is probably not general enough to be placed in BitVector.[ch].
430 */
buzbee311ca162013-02-28 15:56:43 -0800431void MIRGraph::ComputeSuccLineIn(ArenaBitVector* dest, const ArenaBitVector* src1,
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700432 const ArenaBitVector* src2) {
buzbee862a7602013-04-05 10:58:54 -0700433 if (dest->GetStorageSize() != src1->GetStorageSize() ||
434 dest->GetStorageSize() != src2->GetStorageSize() ||
435 dest->IsExpandable() != src1->IsExpandable() ||
436 dest->IsExpandable() != src2->IsExpandable()) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700437 LOG(FATAL) << "Incompatible set properties";
438 }
buzbee67bf8852011-08-17 17:51:35 -0700439
Bill Buzbeea114add2012-05-03 15:00:40 -0700440 unsigned int idx;
buzbee862a7602013-04-05 10:58:54 -0700441 for (idx = 0; idx < dest->GetStorageSize(); idx++) {
442 dest->GetRawStorage()[idx] |= src1->GetRawStorageWord(idx) & ~(src2->GetRawStorageWord(idx));
Bill Buzbeea114add2012-05-03 15:00:40 -0700443 }
buzbee67bf8852011-08-17 17:51:35 -0700444}
445
446/*
447 * Iterate through all successor blocks and propagate up the live-in sets.
448 * The calculated result is used for phi-node pruning - where we only need to
449 * insert a phi node if the variable is live-in to the block.
450 */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700451bool MIRGraph::ComputeBlockLiveIns(BasicBlock* bb) {
buzbee311ca162013-02-28 15:56:43 -0800452 ArenaBitVector* temp_dalvik_register_v = temp_dalvik_register_v_;
buzbee67bf8852011-08-17 17:51:35 -0700453
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700454 if (bb->data_flow_info == NULL) {
455 return false;
456 }
buzbee862a7602013-04-05 10:58:54 -0700457 temp_dalvik_register_v->Copy(bb->data_flow_info->live_in_v);
buzbee0d829482013-10-11 15:24:55 -0700458 BasicBlock* bb_taken = GetBasicBlock(bb->taken);
459 BasicBlock* bb_fall_through = GetBasicBlock(bb->fall_through);
460 if (bb_taken && bb_taken->data_flow_info)
461 ComputeSuccLineIn(temp_dalvik_register_v, bb_taken->data_flow_info->live_in_v,
buzbeefa57c472012-11-21 12:06:18 -0800462 bb->data_flow_info->def_v);
buzbee0d829482013-10-11 15:24:55 -0700463 if (bb_fall_through && bb_fall_through->data_flow_info)
464 ComputeSuccLineIn(temp_dalvik_register_v, bb_fall_through->data_flow_info->live_in_v,
buzbeefa57c472012-11-21 12:06:18 -0800465 bb->data_flow_info->def_v);
buzbee0d829482013-10-11 15:24:55 -0700466 if (bb->successor_block_list_type != kNotUsed) {
467 GrowableArray<SuccessorBlockInfo*>::Iterator iterator(bb->successor_blocks);
Bill Buzbeea114add2012-05-03 15:00:40 -0700468 while (true) {
buzbee862a7602013-04-05 10:58:54 -0700469 SuccessorBlockInfo *successor_block_info = iterator.Next();
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700470 if (successor_block_info == NULL) {
471 break;
472 }
buzbee0d829482013-10-11 15:24:55 -0700473 BasicBlock* succ_bb = GetBasicBlock(successor_block_info->block);
buzbeefa57c472012-11-21 12:06:18 -0800474 if (succ_bb->data_flow_info) {
buzbee311ca162013-02-28 15:56:43 -0800475 ComputeSuccLineIn(temp_dalvik_register_v, succ_bb->data_flow_info->live_in_v,
buzbeefa57c472012-11-21 12:06:18 -0800476 bb->data_flow_info->def_v);
Bill Buzbeea114add2012-05-03 15:00:40 -0700477 }
buzbee67bf8852011-08-17 17:51:35 -0700478 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700479 }
buzbee862a7602013-04-05 10:58:54 -0700480 if (!temp_dalvik_register_v->Equal(bb->data_flow_info->live_in_v)) {
481 bb->data_flow_info->live_in_v->Copy(temp_dalvik_register_v);
Bill Buzbeea114add2012-05-03 15:00:40 -0700482 return true;
483 }
484 return false;
buzbee67bf8852011-08-17 17:51:35 -0700485}
486
487/* Insert phi nodes to for each variable to the dominance frontiers */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700488void MIRGraph::InsertPhiNodes() {
buzbeefa57c472012-11-21 12:06:18 -0800489 int dalvik_reg;
buzbee862a7602013-04-05 10:58:54 -0700490 ArenaBitVector* phi_blocks =
491 new (arena_) ArenaBitVector(arena_, GetNumBlocks(), false, kBitMapPhi);
492 ArenaBitVector* tmp_blocks =
493 new (arena_) ArenaBitVector(arena_, GetNumBlocks(), false, kBitMapTmpBlocks);
494 ArenaBitVector* input_blocks =
495 new (arena_) ArenaBitVector(arena_, GetNumBlocks(), false, kBitMapInputBlocks);
buzbee67bf8852011-08-17 17:51:35 -0700496
buzbee311ca162013-02-28 15:56:43 -0800497 temp_dalvik_register_v_ =
buzbee862a7602013-04-05 10:58:54 -0700498 new (arena_) ArenaBitVector(arena_, cu_->num_dalvik_registers, false, kBitMapRegisterV);
buzbee67bf8852011-08-17 17:51:35 -0700499
buzbee56c71782013-09-05 17:13:19 -0700500 RepeatingPostOrderDfsIterator iter(this);
buzbee311ca162013-02-28 15:56:43 -0800501 bool change = false;
502 for (BasicBlock* bb = iter.Next(false); bb != NULL; bb = iter.Next(change)) {
503 change = ComputeBlockLiveIns(bb);
504 }
buzbee67bf8852011-08-17 17:51:35 -0700505
Bill Buzbeea114add2012-05-03 15:00:40 -0700506 /* Iterate through each Dalvik register */
buzbee311ca162013-02-28 15:56:43 -0800507 for (dalvik_reg = cu_->num_dalvik_registers - 1; dalvik_reg >= 0; dalvik_reg--) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700508 bool change;
buzbee67bf8852011-08-17 17:51:35 -0700509
buzbee862a7602013-04-05 10:58:54 -0700510 input_blocks->Copy(def_block_matrix_[dalvik_reg]);
511 phi_blocks->ClearAllBits();
buzbee67bf8852011-08-17 17:51:35 -0700512
Bill Buzbeea114add2012-05-03 15:00:40 -0700513 /* Calculate the phi blocks for each Dalvik register */
514 do {
515 change = false;
buzbee862a7602013-04-05 10:58:54 -0700516 tmp_blocks->ClearAllBits();
517 ArenaBitVector::Iterator iterator(input_blocks);
buzbee67bf8852011-08-17 17:51:35 -0700518
Bill Buzbeea114add2012-05-03 15:00:40 -0700519 while (true) {
buzbee862a7602013-04-05 10:58:54 -0700520 int idx = iterator.Next();
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700521 if (idx == -1) {
522 break;
buzbee67bf8852011-08-17 17:51:35 -0700523 }
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700524 BasicBlock* def_bb = GetBasicBlock(idx);
Bill Buzbeea114add2012-05-03 15:00:40 -0700525
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700526 /* Merge the dominance frontier to tmp_blocks */
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700527 // TUNING: hot call to Union().
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700528 if (def_bb->dom_frontier != NULL) {
529 tmp_blocks->Union(def_bb->dom_frontier);
530 }
531 }
532 if (!phi_blocks->Equal(tmp_blocks)) {
533 change = true;
534 phi_blocks->Copy(tmp_blocks);
535
536 /*
537 * Iterate through the original blocks plus the new ones in
538 * the dominance frontier.
539 */
540 input_blocks->Copy(phi_blocks);
541 input_blocks->Union(def_block_matrix_[dalvik_reg]);
Bill Buzbeea114add2012-05-03 15:00:40 -0700542 }
543 } while (change);
544
545 /*
buzbeefa57c472012-11-21 12:06:18 -0800546 * Insert a phi node for dalvik_reg in the phi_blocks if the Dalvik
Bill Buzbeea114add2012-05-03 15:00:40 -0700547 * register is in the live-in set.
548 */
buzbee862a7602013-04-05 10:58:54 -0700549 ArenaBitVector::Iterator iterator(phi_blocks);
Bill Buzbeea114add2012-05-03 15:00:40 -0700550 while (true) {
buzbee862a7602013-04-05 10:58:54 -0700551 int idx = iterator.Next();
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700552 if (idx == -1) {
553 break;
554 }
buzbee311ca162013-02-28 15:56:43 -0800555 BasicBlock* phi_bb = GetBasicBlock(idx);
Bill Buzbeea114add2012-05-03 15:00:40 -0700556 /* Variable will be clobbered before being used - no need for phi */
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700557 if (!phi_bb->data_flow_info->live_in_v->IsBitSet(dalvik_reg)) {
558 continue;
559 }
buzbee862a7602013-04-05 10:58:54 -0700560 MIR *phi =
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000561 static_cast<MIR*>(arena_->Alloc(sizeof(MIR), kArenaAllocDFInfo));
buzbeecbd6d442012-11-17 14:11:25 -0800562 phi->dalvikInsn.opcode = static_cast<Instruction::Code>(kMirOpPhi);
buzbeefa57c472012-11-21 12:06:18 -0800563 phi->dalvikInsn.vA = dalvik_reg;
564 phi->offset = phi_bb->start_offset;
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700565 phi->m_unit_index = 0; // Arbitrarily assign all Phi nodes to outermost method.
Jean Christophe Beylercdacac42014-03-13 14:54:59 -0700566 phi_bb->PrependMIR(phi);
buzbee67bf8852011-08-17 17:51:35 -0700567 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700568 }
buzbee67bf8852011-08-17 17:51:35 -0700569}
570
571/*
572 * Worker function to insert phi-operands with latest SSA names from
573 * predecessor blocks
574 */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700575bool MIRGraph::InsertPhiNodeOperands(BasicBlock* bb) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700576 /* Phi nodes are at the beginning of each block */
buzbee0d829482013-10-11 15:24:55 -0700577 for (MIR* mir = bb->first_mir_insn; mir != NULL; mir = mir->next) {
buzbeecbd6d442012-11-17 14:11:25 -0800578 if (mir->dalvikInsn.opcode != static_cast<Instruction::Code>(kMirOpPhi))
Bill Buzbeea114add2012-05-03 15:00:40 -0700579 return true;
buzbeefa57c472012-11-21 12:06:18 -0800580 int ssa_reg = mir->ssa_rep->defs[0];
581 DCHECK_GE(ssa_reg, 0); // Shouldn't see compiler temps here
buzbee311ca162013-02-28 15:56:43 -0800582 int v_reg = SRegToVReg(ssa_reg);
buzbee67bf8852011-08-17 17:51:35 -0700583
Bill Buzbeea114add2012-05-03 15:00:40 -0700584 /* Iterate through the predecessors */
buzbee0d829482013-10-11 15:24:55 -0700585 GrowableArray<BasicBlockId>::Iterator iter(bb->predecessors);
586 size_t num_uses = bb->predecessors->Size();
587 mir->ssa_rep->num_uses = num_uses;
588 int* uses = static_cast<int*>(arena_->Alloc(sizeof(int) * num_uses,
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000589 kArenaAllocDFInfo));
buzbee0d829482013-10-11 15:24:55 -0700590 mir->ssa_rep->uses = uses;
591 mir->ssa_rep->fp_use =
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000592 static_cast<bool*>(arena_->Alloc(sizeof(bool) * num_uses, kArenaAllocDFInfo));
buzbee0d829482013-10-11 15:24:55 -0700593 BasicBlockId* incoming =
594 static_cast<BasicBlockId*>(arena_->Alloc(sizeof(BasicBlockId) * num_uses,
Vladimir Marko83cc7ae2014-02-12 18:02:05 +0000595 kArenaAllocDFInfo));
buzbee0d829482013-10-11 15:24:55 -0700596 mir->meta.phi_incoming = incoming;
597 int idx = 0;
Bill Buzbeea114add2012-05-03 15:00:40 -0700598 while (true) {
buzbee0d829482013-10-11 15:24:55 -0700599 BasicBlock* pred_bb = GetBasicBlock(iter.Next());
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700600 if (!pred_bb) {
601 break;
602 }
buzbeefa57c472012-11-21 12:06:18 -0800603 int ssa_reg = pred_bb->data_flow_info->vreg_to_ssa_map[v_reg];
buzbee0d829482013-10-11 15:24:55 -0700604 uses[idx] = ssa_reg;
605 incoming[idx] = pred_bb->id;
606 idx++;
Bill Buzbeea114add2012-05-03 15:00:40 -0700607 }
608 }
609
610 return true;
buzbee67bf8852011-08-17 17:51:35 -0700611}
612
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700613void MIRGraph::DoDFSPreOrderSSARename(BasicBlock* block) {
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700614 if (block->visited || block->hidden) {
615 return;
616 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700617 block->visited = true;
buzbeef0cde542011-09-13 14:55:02 -0700618
Bill Buzbeea114add2012-05-03 15:00:40 -0700619 /* Process this block */
buzbee311ca162013-02-28 15:56:43 -0800620 DoSSAConversion(block);
621 int map_size = sizeof(int) * cu_->num_dalvik_registers;
buzbeef0cde542011-09-13 14:55:02 -0700622
Bill Buzbeea114add2012-05-03 15:00:40 -0700623 /* Save SSA map snapshot */
Vladimir Marko5d474472014-03-21 17:10:58 +0000624 ScopedArenaAllocator allocator(&cu_->arena_stack);
buzbee862a7602013-04-05 10:58:54 -0700625 int* saved_ssa_map =
Vladimir Marko5d474472014-03-21 17:10:58 +0000626 static_cast<int*>(allocator.Alloc(map_size, kArenaAllocDalvikToSSAMap));
buzbee311ca162013-02-28 15:56:43 -0800627 memcpy(saved_ssa_map, vreg_to_ssa_map_, map_size);
buzbeef0cde542011-09-13 14:55:02 -0700628
buzbee0d829482013-10-11 15:24:55 -0700629 if (block->fall_through != NullBasicBlockId) {
630 DoDFSPreOrderSSARename(GetBasicBlock(block->fall_through));
Bill Buzbeea114add2012-05-03 15:00:40 -0700631 /* Restore SSA map snapshot */
buzbee311ca162013-02-28 15:56:43 -0800632 memcpy(vreg_to_ssa_map_, saved_ssa_map, map_size);
Bill Buzbeea114add2012-05-03 15:00:40 -0700633 }
buzbee0d829482013-10-11 15:24:55 -0700634 if (block->taken != NullBasicBlockId) {
635 DoDFSPreOrderSSARename(GetBasicBlock(block->taken));
Bill Buzbeea114add2012-05-03 15:00:40 -0700636 /* Restore SSA map snapshot */
buzbee311ca162013-02-28 15:56:43 -0800637 memcpy(vreg_to_ssa_map_, saved_ssa_map, map_size);
Bill Buzbeea114add2012-05-03 15:00:40 -0700638 }
buzbee0d829482013-10-11 15:24:55 -0700639 if (block->successor_block_list_type != kNotUsed) {
640 GrowableArray<SuccessorBlockInfo*>::Iterator iterator(block->successor_blocks);
Bill Buzbeea114add2012-05-03 15:00:40 -0700641 while (true) {
buzbee862a7602013-04-05 10:58:54 -0700642 SuccessorBlockInfo *successor_block_info = iterator.Next();
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700643 if (successor_block_info == NULL) {
644 break;
645 }
buzbee0d829482013-10-11 15:24:55 -0700646 BasicBlock* succ_bb = GetBasicBlock(successor_block_info->block);
buzbee311ca162013-02-28 15:56:43 -0800647 DoDFSPreOrderSSARename(succ_bb);
Bill Buzbeea114add2012-05-03 15:00:40 -0700648 /* Restore SSA map snapshot */
buzbee311ca162013-02-28 15:56:43 -0800649 memcpy(vreg_to_ssa_map_, saved_ssa_map, map_size);
buzbeef0cde542011-09-13 14:55:02 -0700650 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700651 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700652 return;
buzbeef0cde542011-09-13 14:55:02 -0700653}
654
Elliott Hughes11d1b0c2012-01-23 16:57:47 -0800655} // namespace art