blob: 0f79f4128ff6e081e3d26d133eb560f7409185b1 [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
buzbeeeaf09bc2012-11-15 14:51:41 -080017#include "compiler_internals.h"
Ian Rogers8d3a1172013-06-04 01:13:28 -070018#include "dataflow_iterator-inl.h"
buzbee67bf8852011-08-17 17:51:35 -070019
buzbee1fd33462013-03-25 13:40:45 -070020#define NOTVISITED (-1)
21
Elliott Hughes11d1b0c2012-01-23 16:57:47 -080022namespace art {
23
buzbeea5abf702013-04-12 14:39:29 -070024void MIRGraph::ClearAllVisitedFlags() {
buzbee56c71782013-09-05 17:13:19 -070025 AllNodesIterator iter(this);
buzbeea5abf702013-04-12 14:39:29 -070026 for (BasicBlock* bb = iter.Next(); bb != NULL; bb = iter.Next()) {
27 bb->visited = false;
28 }
29}
30
buzbee311ca162013-02-28 15:56:43 -080031BasicBlock* MIRGraph::NeedsVisit(BasicBlock* bb) {
buzbeee5f01222012-06-14 15:19:35 -070032 if (bb != NULL) {
33 if (bb->visited || bb->hidden) {
34 bb = NULL;
35 }
36 }
37 return bb;
38}
39
Brian Carlstrom2ce745c2013-07-17 17:44:30 -070040BasicBlock* MIRGraph::NextUnvisitedSuccessor(BasicBlock* bb) {
buzbee0d829482013-10-11 15:24:55 -070041 BasicBlock* res = NeedsVisit(GetBasicBlock(bb->fall_through));
buzbeee5f01222012-06-14 15:19:35 -070042 if (res == NULL) {
buzbee0d829482013-10-11 15:24:55 -070043 res = NeedsVisit(GetBasicBlock(bb->taken));
buzbeee5f01222012-06-14 15:19:35 -070044 if (res == NULL) {
buzbee0d829482013-10-11 15:24:55 -070045 if (bb->successor_block_list_type != kNotUsed) {
46 GrowableArray<SuccessorBlockInfo*>::Iterator iterator(bb->successor_blocks);
buzbeee5f01222012-06-14 15:19:35 -070047 while (true) {
buzbee862a7602013-04-05 10:58:54 -070048 SuccessorBlockInfo *sbi = iterator.Next();
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -070049 if (sbi == NULL) {
50 break;
51 }
buzbee0d829482013-10-11 15:24:55 -070052 res = NeedsVisit(GetBasicBlock(sbi->block));
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -070053 if (res != NULL) {
54 break;
55 }
buzbeee5f01222012-06-14 15:19:35 -070056 }
57 }
58 }
59 }
60 return res;
61}
62
Brian Carlstrom2ce745c2013-07-17 17:44:30 -070063void MIRGraph::MarkPreOrder(BasicBlock* block) {
buzbeee5f01222012-06-14 15:19:35 -070064 block->visited = true;
buzbeefa57c472012-11-21 12:06:18 -080065 /* Enqueue the pre_order block id */
buzbee0d829482013-10-11 15:24:55 -070066 if (block->id != NullBasicBlockId) {
67 dfs_order_->Insert(block->id);
68 }
buzbeee5f01222012-06-14 15:19:35 -070069}
70
Brian Carlstrom2ce745c2013-07-17 17:44:30 -070071void MIRGraph::RecordDFSOrders(BasicBlock* block) {
buzbeee5f01222012-06-14 15:19:35 -070072 std::vector<BasicBlock*> succ;
buzbee311ca162013-02-28 15:56:43 -080073 MarkPreOrder(block);
buzbeee5f01222012-06-14 15:19:35 -070074 succ.push_back(block);
75 while (!succ.empty()) {
76 BasicBlock* curr = succ.back();
buzbeefa57c472012-11-21 12:06:18 -080077 BasicBlock* next_successor = NextUnvisitedSuccessor(curr);
78 if (next_successor != NULL) {
buzbee311ca162013-02-28 15:56:43 -080079 MarkPreOrder(next_successor);
buzbeefa57c472012-11-21 12:06:18 -080080 succ.push_back(next_successor);
buzbeee5f01222012-06-14 15:19:35 -070081 continue;
82 }
buzbee862a7602013-04-05 10:58:54 -070083 curr->dfs_id = dfs_post_order_->Size();
buzbee0d829482013-10-11 15:24:55 -070084 if (curr->id != NullBasicBlockId) {
85 dfs_post_order_->Insert(curr->id);
86 }
buzbeee5f01222012-06-14 15:19:35 -070087 succ.pop_back();
88 }
89}
90
buzbee5b537102012-01-17 17:33:47 -080091/* Sort the blocks by the Depth-First-Search */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -070092void MIRGraph::ComputeDFSOrders() {
buzbeefa57c472012-11-21 12:06:18 -080093 /* Initialize or reset the DFS pre_order list */
buzbee862a7602013-04-05 10:58:54 -070094 if (dfs_order_ == NULL) {
buzbee0d829482013-10-11 15:24:55 -070095 dfs_order_ = new (arena_) GrowableArray<BasicBlockId>(arena_, GetNumBlocks(),
96 kGrowableArrayDfsOrder);
Bill Buzbeea114add2012-05-03 15:00:40 -070097 } else {
98 /* Just reset the used length on the counter */
buzbee862a7602013-04-05 10:58:54 -070099 dfs_order_->Reset();
Bill Buzbeea114add2012-05-03 15:00:40 -0700100 }
buzbee67bf8852011-08-17 17:51:35 -0700101
buzbeefa57c472012-11-21 12:06:18 -0800102 /* Initialize or reset the DFS post_order list */
buzbee862a7602013-04-05 10:58:54 -0700103 if (dfs_post_order_ == NULL) {
buzbee0d829482013-10-11 15:24:55 -0700104 dfs_post_order_ = new (arena_) GrowableArray<BasicBlockId>(arena_, GetNumBlocks(),
105 kGrowableArrayDfsPostOrder);
Bill Buzbeea114add2012-05-03 15:00:40 -0700106 } else {
107 /* Just reset the used length on the counter */
buzbee862a7602013-04-05 10:58:54 -0700108 dfs_post_order_->Reset();
Bill Buzbeea114add2012-05-03 15:00:40 -0700109 }
buzbee5b537102012-01-17 17:33:47 -0800110
buzbeee5f01222012-06-14 15:19:35 -0700111 // Reset visited flags from all nodes
buzbeea5abf702013-04-12 14:39:29 -0700112 ClearAllVisitedFlags();
113
buzbeee5f01222012-06-14 15:19:35 -0700114 // Record dfs orders
buzbee311ca162013-02-28 15:56:43 -0800115 RecordDFSOrders(GetEntryBlock());
buzbeee5f01222012-06-14 15:19:35 -0700116
buzbee862a7602013-04-05 10:58:54 -0700117 num_reachable_blocks_ = dfs_order_->Size();
buzbee67bf8852011-08-17 17:51:35 -0700118}
119
120/*
121 * Mark block bit on the per-Dalvik register vector to denote that Dalvik
122 * register idx is defined in BasicBlock bb.
123 */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700124bool MIRGraph::FillDefBlockMatrix(BasicBlock* bb) {
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700125 if (bb->data_flow_info == NULL) {
126 return false;
127 }
buzbee67bf8852011-08-17 17:51:35 -0700128
buzbee862a7602013-04-05 10:58:54 -0700129 ArenaBitVector::Iterator iterator(bb->data_flow_info->def_v);
Bill Buzbeea114add2012-05-03 15:00:40 -0700130 while (true) {
buzbee862a7602013-04-05 10:58:54 -0700131 int idx = iterator.Next();
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700132 if (idx == -1) {
133 break;
134 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700135 /* Block bb defines register idx */
buzbee862a7602013-04-05 10:58:54 -0700136 def_block_matrix_[idx]->SetBit(bb->id);
Bill Buzbeea114add2012-05-03 15:00:40 -0700137 }
138 return true;
buzbee67bf8852011-08-17 17:51:35 -0700139}
140
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700141void MIRGraph::ComputeDefBlockMatrix() {
buzbee311ca162013-02-28 15:56:43 -0800142 int num_registers = cu_->num_dalvik_registers;
buzbeefa57c472012-11-21 12:06:18 -0800143 /* Allocate num_dalvik_registers bit vector pointers */
buzbee311ca162013-02-28 15:56:43 -0800144 def_block_matrix_ = static_cast<ArenaBitVector**>
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700145 (arena_->Alloc(sizeof(ArenaBitVector *) * num_registers,
146 ArenaAllocator::kAllocDFInfo));
Bill Buzbeea114add2012-05-03 15:00:40 -0700147 int i;
buzbee67bf8852011-08-17 17:51:35 -0700148
buzbeefa57c472012-11-21 12:06:18 -0800149 /* Initialize num_register vectors with num_blocks bits each */
150 for (i = 0; i < num_registers; i++) {
buzbee862a7602013-04-05 10:58:54 -0700151 def_block_matrix_[i] =
152 new (arena_) ArenaBitVector(arena_, GetNumBlocks(), false, kBitMapBMatrix);
Bill Buzbeea114add2012-05-03 15:00:40 -0700153 }
buzbee56c71782013-09-05 17:13:19 -0700154 AllNodesIterator iter(this);
buzbee311ca162013-02-28 15:56:43 -0800155 for (BasicBlock* bb = iter.Next(); bb != NULL; bb = iter.Next()) {
156 FindLocalLiveIn(bb);
157 }
buzbee56c71782013-09-05 17:13:19 -0700158 AllNodesIterator iter2(this);
buzbee311ca162013-02-28 15:56:43 -0800159 for (BasicBlock* bb = iter2.Next(); bb != NULL; bb = iter2.Next()) {
160 FillDefBlockMatrix(bb);
161 }
buzbee67bf8852011-08-17 17:51:35 -0700162
Bill Buzbeea114add2012-05-03 15:00:40 -0700163 /*
164 * Also set the incoming parameters as defs in the entry block.
165 * Only need to handle the parameters for the outer method.
166 */
buzbee311ca162013-02-28 15:56:43 -0800167 int num_regs = cu_->num_dalvik_registers;
168 int in_reg = num_regs - cu_->num_ins;
buzbeefa57c472012-11-21 12:06:18 -0800169 for (; in_reg < num_regs; in_reg++) {
buzbee862a7602013-04-05 10:58:54 -0700170 def_block_matrix_[in_reg]->SetBit(GetEntryBlock()->id);
Bill Buzbeea114add2012-05-03 15:00:40 -0700171 }
buzbee67bf8852011-08-17 17:51:35 -0700172}
173
buzbeea5abf702013-04-12 14:39:29 -0700174void MIRGraph::ComputeDomPostOrderTraversal(BasicBlock* bb) {
175 if (dom_post_order_traversal_ == NULL) {
176 // First time - create the array.
177 dom_post_order_traversal_ =
buzbee0d829482013-10-11 15:24:55 -0700178 new (arena_) GrowableArray<BasicBlockId>(arena_, num_reachable_blocks_,
buzbeea5abf702013-04-12 14:39:29 -0700179 kGrowableArrayDomPostOrderTraversal);
180 } else {
181 dom_post_order_traversal_->Reset();
Bill Buzbeea114add2012-05-03 15:00:40 -0700182 }
buzbeea5abf702013-04-12 14:39:29 -0700183 ClearAllVisitedFlags();
184 std::vector<std::pair<BasicBlock*, ArenaBitVector::Iterator*> > work_stack;
185 bb->visited = true;
Brian Carlstrom413e89f2013-10-21 23:53:49 -0700186 work_stack.push_back(std::make_pair(bb, bb->i_dominated->GetIterator()));
buzbeea5abf702013-04-12 14:39:29 -0700187 while (!work_stack.empty()) {
Sebastien Hertz74e256b2013-10-04 10:40:37 +0200188 const std::pair<BasicBlock*, ArenaBitVector::Iterator*>& curr = work_stack.back();
buzbeea5abf702013-04-12 14:39:29 -0700189 BasicBlock* curr_bb = curr.first;
190 ArenaBitVector::Iterator* curr_idom_iter = curr.second;
191 int bb_idx = curr_idom_iter->Next();
192 while ((bb_idx != -1) && (NeedsVisit(GetBasicBlock(bb_idx)) == NULL)) {
193 bb_idx = curr_idom_iter->Next();
194 }
195 if (bb_idx != -1) {
196 BasicBlock* new_bb = GetBasicBlock(bb_idx);
197 new_bb->visited = true;
198 work_stack.push_back(
Brian Carlstrom413e89f2013-10-21 23:53:49 -0700199 std::make_pair(new_bb, new_bb->i_dominated->GetIterator()));
buzbeea5abf702013-04-12 14:39:29 -0700200 } else {
201 // no successor/next
buzbee0d829482013-10-11 15:24:55 -0700202 if (curr_bb->id != NullBasicBlockId) {
203 dom_post_order_traversal_->Insert(curr_bb->id);
204 }
buzbeea5abf702013-04-12 14:39:29 -0700205 work_stack.pop_back();
buzbee67bf8852011-08-17 17:51:35 -0700206
buzbeea5abf702013-04-12 14:39:29 -0700207 /* hacky loop detection */
buzbee0d829482013-10-11 15:24:55 -0700208 if ((curr_bb->taken != NullBasicBlockId) && curr_bb->dominators->IsBitSet(curr_bb->taken)) {
Bill Buzbee0b1191c2013-10-28 22:11:59 +0000209 curr_bb->nesting_depth++;
buzbeea5abf702013-04-12 14:39:29 -0700210 attributes_ |= METHOD_HAS_LOOP;
211 }
212 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700213 }
buzbee67bf8852011-08-17 17:51:35 -0700214}
215
buzbee311ca162013-02-28 15:56:43 -0800216void MIRGraph::CheckForDominanceFrontier(BasicBlock* dom_bb,
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700217 const BasicBlock* succ_bb) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700218 /*
219 * TODO - evaluate whether phi will ever need to be inserted into exit
220 * blocks.
221 */
buzbee0d829482013-10-11 15:24:55 -0700222 if (succ_bb->i_dom != dom_bb->id &&
buzbeefa57c472012-11-21 12:06:18 -0800223 succ_bb->block_type == kDalvikByteCode &&
224 succ_bb->hidden == false) {
buzbee862a7602013-04-05 10:58:54 -0700225 dom_bb->dom_frontier->SetBit(succ_bb->id);
Bill Buzbeea114add2012-05-03 15:00:40 -0700226 }
buzbee67bf8852011-08-17 17:51:35 -0700227}
228
229/* Worker function to compute the dominance frontier */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700230bool MIRGraph::ComputeDominanceFrontier(BasicBlock* bb) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700231 /* Calculate DF_local */
buzbee0d829482013-10-11 15:24:55 -0700232 if (bb->taken != NullBasicBlockId) {
233 CheckForDominanceFrontier(bb, GetBasicBlock(bb->taken));
Bill Buzbeea114add2012-05-03 15:00:40 -0700234 }
buzbee0d829482013-10-11 15:24:55 -0700235 if (bb->fall_through != NullBasicBlockId) {
236 CheckForDominanceFrontier(bb, GetBasicBlock(bb->fall_through));
Bill Buzbeea114add2012-05-03 15:00:40 -0700237 }
buzbee0d829482013-10-11 15:24:55 -0700238 if (bb->successor_block_list_type != kNotUsed) {
239 GrowableArray<SuccessorBlockInfo*>::Iterator iterator(bb->successor_blocks);
Bill Buzbeea114add2012-05-03 15:00:40 -0700240 while (true) {
buzbee862a7602013-04-05 10:58:54 -0700241 SuccessorBlockInfo *successor_block_info = iterator.Next();
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700242 if (successor_block_info == NULL) {
243 break;
244 }
buzbee0d829482013-10-11 15:24:55 -0700245 BasicBlock* succ_bb = GetBasicBlock(successor_block_info->block);
buzbee311ca162013-02-28 15:56:43 -0800246 CheckForDominanceFrontier(bb, succ_bb);
Bill Buzbeea114add2012-05-03 15:00:40 -0700247 }
248 }
buzbee67bf8852011-08-17 17:51:35 -0700249
Bill Buzbeea114add2012-05-03 15:00:40 -0700250 /* Calculate DF_up */
Jean Christophe Beylerf7a82b42014-02-10 22:12:58 -0800251 ArenaBitVector::BasicBlockIterator it(bb->i_dominated, cu_);
252 for (BasicBlock *dominated_bb = it.Next(); dominated_bb != nullptr; dominated_bb = it.Next()) {
253 ArenaBitVector::BasicBlockIterator inner_it(dominated_bb->dom_frontier, cu_);
254 for (BasicBlock *df_up_block = inner_it.Next(); df_up_block != nullptr;
255 df_up_block = inner_it.Next()) {
buzbee311ca162013-02-28 15:56:43 -0800256 CheckForDominanceFrontier(bb, df_up_block);
buzbee67bf8852011-08-17 17:51:35 -0700257 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700258 }
buzbee67bf8852011-08-17 17:51:35 -0700259
Bill Buzbeea114add2012-05-03 15:00:40 -0700260 return true;
buzbee67bf8852011-08-17 17:51:35 -0700261}
262
263/* Worker function for initializing domination-related data structures */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700264void MIRGraph::InitializeDominationInfo(BasicBlock* bb) {
buzbee311ca162013-02-28 15:56:43 -0800265 int num_total_blocks = GetBasicBlockListCount();
buzbee67bf8852011-08-17 17:51:35 -0700266
Brian Carlstromdf629502013-07-17 22:39:56 -0700267 if (bb->dominators == NULL) {
buzbee862a7602013-04-05 10:58:54 -0700268 bb->dominators = new (arena_) ArenaBitVector(arena_, num_total_blocks,
269 false /* expandable */, kBitMapDominators);
270 bb->i_dominated = new (arena_) ArenaBitVector(arena_, num_total_blocks,
271 false /* expandable */, kBitMapIDominated);
272 bb->dom_frontier = new (arena_) ArenaBitVector(arena_, num_total_blocks,
273 false /* expandable */, kBitMapDomFrontier);
Bill Buzbeea114add2012-05-03 15:00:40 -0700274 } else {
buzbee862a7602013-04-05 10:58:54 -0700275 bb->dominators->ClearAllBits();
276 bb->i_dominated->ClearAllBits();
277 bb->dom_frontier->ClearAllBits();
Bill Buzbeea114add2012-05-03 15:00:40 -0700278 }
279 /* Set all bits in the dominator vector */
buzbee862a7602013-04-05 10:58:54 -0700280 bb->dominators->SetInitialBits(num_total_blocks);
buzbee67bf8852011-08-17 17:51:35 -0700281
buzbee862a7602013-04-05 10:58:54 -0700282 return;
buzbee67bf8852011-08-17 17:51:35 -0700283}
284
buzbee5b537102012-01-17 17:33:47 -0800285/*
buzbeefa57c472012-11-21 12:06:18 -0800286 * Walk through the ordered i_dom list until we reach common parent.
287 * Given the ordering of i_dom_list, this common parent represents the
buzbee5b537102012-01-17 17:33:47 -0800288 * last element of the intersection of block1 and block2 dominators.
289 */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700290int MIRGraph::FindCommonParent(int block1, int block2) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700291 while (block1 != block2) {
292 while (block1 < block2) {
buzbee311ca162013-02-28 15:56:43 -0800293 block1 = i_dom_list_[block1];
Bill Buzbeea114add2012-05-03 15:00:40 -0700294 DCHECK_NE(block1, NOTVISITED);
buzbee5b537102012-01-17 17:33:47 -0800295 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700296 while (block2 < block1) {
buzbee311ca162013-02-28 15:56:43 -0800297 block2 = i_dom_list_[block2];
Bill Buzbeea114add2012-05-03 15:00:40 -0700298 DCHECK_NE(block2, NOTVISITED);
299 }
300 }
301 return block1;
buzbee5b537102012-01-17 17:33:47 -0800302}
303
304/* Worker function to compute each block's immediate dominator */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700305bool MIRGraph::ComputeblockIDom(BasicBlock* bb) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700306 /* Special-case entry block */
buzbee0d829482013-10-11 15:24:55 -0700307 if ((bb->id == NullBasicBlockId) || (bb == GetEntryBlock())) {
buzbee5b537102012-01-17 17:33:47 -0800308 return false;
Bill Buzbeea114add2012-05-03 15:00:40 -0700309 }
310
311 /* Iterate through the predecessors */
buzbee0d829482013-10-11 15:24:55 -0700312 GrowableArray<BasicBlockId>::Iterator iter(bb->predecessors);
Bill Buzbeea114add2012-05-03 15:00:40 -0700313
314 /* Find the first processed predecessor */
buzbee862a7602013-04-05 10:58:54 -0700315 int idom = -1;
Bill Buzbeea114add2012-05-03 15:00:40 -0700316 while (true) {
buzbee0d829482013-10-11 15:24:55 -0700317 BasicBlock* pred_bb = GetBasicBlock(iter.Next());
buzbeefa57c472012-11-21 12:06:18 -0800318 CHECK(pred_bb != NULL);
buzbee311ca162013-02-28 15:56:43 -0800319 if (i_dom_list_[pred_bb->dfs_id] != NOTVISITED) {
buzbeefa57c472012-11-21 12:06:18 -0800320 idom = pred_bb->dfs_id;
Bill Buzbeea114add2012-05-03 15:00:40 -0700321 break;
322 }
323 }
324
325 /* Scan the rest of the predecessors */
326 while (true) {
buzbee0d829482013-10-11 15:24:55 -0700327 BasicBlock* pred_bb = GetBasicBlock(iter.Next());
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700328 if (!pred_bb) {
329 break;
330 }
buzbee311ca162013-02-28 15:56:43 -0800331 if (i_dom_list_[pred_bb->dfs_id] == NOTVISITED) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700332 continue;
333 } else {
buzbee311ca162013-02-28 15:56:43 -0800334 idom = FindCommonParent(pred_bb->dfs_id, idom);
Bill Buzbeea114add2012-05-03 15:00:40 -0700335 }
336 }
337
338 DCHECK_NE(idom, NOTVISITED);
339
340 /* Did something change? */
buzbee311ca162013-02-28 15:56:43 -0800341 if (i_dom_list_[bb->dfs_id] != idom) {
342 i_dom_list_[bb->dfs_id] = idom;
Bill Buzbeea114add2012-05-03 15:00:40 -0700343 return true;
344 }
345 return false;
buzbee5b537102012-01-17 17:33:47 -0800346}
347
348/* Worker function to compute each block's domintors */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700349bool MIRGraph::ComputeBlockDominators(BasicBlock* bb) {
buzbee311ca162013-02-28 15:56:43 -0800350 if (bb == GetEntryBlock()) {
buzbee862a7602013-04-05 10:58:54 -0700351 bb->dominators->ClearAllBits();
Bill Buzbeea114add2012-05-03 15:00:40 -0700352 } else {
buzbee0d829482013-10-11 15:24:55 -0700353 bb->dominators->Copy(GetBasicBlock(bb->i_dom)->dominators);
Bill Buzbeea114add2012-05-03 15:00:40 -0700354 }
buzbee862a7602013-04-05 10:58:54 -0700355 bb->dominators->SetBit(bb->id);
Bill Buzbeea114add2012-05-03 15:00:40 -0700356 return false;
buzbee5b537102012-01-17 17:33:47 -0800357}
358
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700359bool MIRGraph::SetDominators(BasicBlock* bb) {
buzbee311ca162013-02-28 15:56:43 -0800360 if (bb != GetEntryBlock()) {
361 int idom_dfs_idx = i_dom_list_[bb->dfs_id];
buzbeefa57c472012-11-21 12:06:18 -0800362 DCHECK_NE(idom_dfs_idx, NOTVISITED);
buzbee862a7602013-04-05 10:58:54 -0700363 int i_dom_idx = dfs_post_order_->Get(idom_dfs_idx);
buzbee311ca162013-02-28 15:56:43 -0800364 BasicBlock* i_dom = GetBasicBlock(i_dom_idx);
buzbee0d829482013-10-11 15:24:55 -0700365 bb->i_dom = i_dom->id;
buzbeefa57c472012-11-21 12:06:18 -0800366 /* Add bb to the i_dominated set of the immediate dominator block */
buzbee862a7602013-04-05 10:58:54 -0700367 i_dom->i_dominated->SetBit(bb->id);
Bill Buzbeea114add2012-05-03 15:00:40 -0700368 }
369 return false;
buzbee5b537102012-01-17 17:33:47 -0800370}
371
buzbee67bf8852011-08-17 17:51:35 -0700372/* Compute dominators, immediate dominator, and dominance fronter */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700373void MIRGraph::ComputeDominators() {
buzbee311ca162013-02-28 15:56:43 -0800374 int num_reachable_blocks = num_reachable_blocks_;
375 int num_total_blocks = GetBasicBlockListCount();
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,
386 ArenaAllocator::kAllocDFInfo));
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
buzbee311ca162013-02-28 15:56:43 -0800407 if (temp_block_v_ == NULL) {
buzbee862a7602013-04-05 10:58:54 -0700408 temp_block_v_ = new (arena_) ArenaBitVector(arena_, num_total_blocks,
409 false /* expandable */, kBitMapTmpBlockV);
Bill Buzbeea114add2012-05-03 15:00:40 -0700410 } else {
buzbee862a7602013-04-05 10:58:54 -0700411 temp_block_v_->ClearAllBits();
Bill Buzbeea114add2012-05-03 15:00:40 -0700412 }
buzbee0d829482013-10-11 15:24:55 -0700413 GetEntryBlock()->i_dom = 0;
Bill Buzbeea114add2012-05-03 15:00:40 -0700414
buzbee56c71782013-09-05 17:13:19 -0700415 PreOrderDfsIterator iter3(this);
buzbee311ca162013-02-28 15:56:43 -0800416 for (BasicBlock* bb = iter3.Next(); bb != NULL; bb = iter3.Next()) {
417 SetDominators(bb);
Bill Buzbeea114add2012-05-03 15:00:40 -0700418 }
buzbee67bf8852011-08-17 17:51:35 -0700419
buzbee56c71782013-09-05 17:13:19 -0700420 ReversePostOrderDfsIterator iter4(this);
buzbee311ca162013-02-28 15:56:43 -0800421 for (BasicBlock* bb = iter4.Next(); bb != NULL; bb = iter4.Next()) {
422 ComputeBlockDominators(bb);
423 }
buzbee5b537102012-01-17 17:33:47 -0800424
buzbeea5abf702013-04-12 14:39:29 -0700425 // Compute the dominance frontier for each block.
buzbee311ca162013-02-28 15:56:43 -0800426 ComputeDomPostOrderTraversal(GetEntryBlock());
buzbee56c71782013-09-05 17:13:19 -0700427 PostOrderDOMIterator iter5(this);
buzbee311ca162013-02-28 15:56:43 -0800428 for (BasicBlock* bb = iter5.Next(); bb != NULL; bb = iter5.Next()) {
429 ComputeDominanceFrontier(bb);
430 }
buzbee67bf8852011-08-17 17:51:35 -0700431}
432
433/*
434 * Perform dest U= src1 ^ ~src2
435 * This is probably not general enough to be placed in BitVector.[ch].
436 */
buzbee311ca162013-02-28 15:56:43 -0800437void MIRGraph::ComputeSuccLineIn(ArenaBitVector* dest, const ArenaBitVector* src1,
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700438 const ArenaBitVector* src2) {
buzbee862a7602013-04-05 10:58:54 -0700439 if (dest->GetStorageSize() != src1->GetStorageSize() ||
440 dest->GetStorageSize() != src2->GetStorageSize() ||
441 dest->IsExpandable() != src1->IsExpandable() ||
442 dest->IsExpandable() != src2->IsExpandable()) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700443 LOG(FATAL) << "Incompatible set properties";
444 }
buzbee67bf8852011-08-17 17:51:35 -0700445
Bill Buzbeea114add2012-05-03 15:00:40 -0700446 unsigned int idx;
buzbee862a7602013-04-05 10:58:54 -0700447 for (idx = 0; idx < dest->GetStorageSize(); idx++) {
448 dest->GetRawStorage()[idx] |= src1->GetRawStorageWord(idx) & ~(src2->GetRawStorageWord(idx));
Bill Buzbeea114add2012-05-03 15:00:40 -0700449 }
buzbee67bf8852011-08-17 17:51:35 -0700450}
451
452/*
453 * Iterate through all successor blocks and propagate up the live-in sets.
454 * The calculated result is used for phi-node pruning - where we only need to
455 * insert a phi node if the variable is live-in to the block.
456 */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700457bool MIRGraph::ComputeBlockLiveIns(BasicBlock* bb) {
buzbee311ca162013-02-28 15:56:43 -0800458 ArenaBitVector* temp_dalvik_register_v = temp_dalvik_register_v_;
buzbee67bf8852011-08-17 17:51:35 -0700459
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700460 if (bb->data_flow_info == NULL) {
461 return false;
462 }
buzbee862a7602013-04-05 10:58:54 -0700463 temp_dalvik_register_v->Copy(bb->data_flow_info->live_in_v);
buzbee0d829482013-10-11 15:24:55 -0700464 BasicBlock* bb_taken = GetBasicBlock(bb->taken);
465 BasicBlock* bb_fall_through = GetBasicBlock(bb->fall_through);
466 if (bb_taken && bb_taken->data_flow_info)
467 ComputeSuccLineIn(temp_dalvik_register_v, bb_taken->data_flow_info->live_in_v,
buzbeefa57c472012-11-21 12:06:18 -0800468 bb->data_flow_info->def_v);
buzbee0d829482013-10-11 15:24:55 -0700469 if (bb_fall_through && bb_fall_through->data_flow_info)
470 ComputeSuccLineIn(temp_dalvik_register_v, bb_fall_through->data_flow_info->live_in_v,
buzbeefa57c472012-11-21 12:06:18 -0800471 bb->data_flow_info->def_v);
buzbee0d829482013-10-11 15:24:55 -0700472 if (bb->successor_block_list_type != kNotUsed) {
473 GrowableArray<SuccessorBlockInfo*>::Iterator iterator(bb->successor_blocks);
Bill Buzbeea114add2012-05-03 15:00:40 -0700474 while (true) {
buzbee862a7602013-04-05 10:58:54 -0700475 SuccessorBlockInfo *successor_block_info = iterator.Next();
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700476 if (successor_block_info == NULL) {
477 break;
478 }
buzbee0d829482013-10-11 15:24:55 -0700479 BasicBlock* succ_bb = GetBasicBlock(successor_block_info->block);
buzbeefa57c472012-11-21 12:06:18 -0800480 if (succ_bb->data_flow_info) {
buzbee311ca162013-02-28 15:56:43 -0800481 ComputeSuccLineIn(temp_dalvik_register_v, succ_bb->data_flow_info->live_in_v,
buzbeefa57c472012-11-21 12:06:18 -0800482 bb->data_flow_info->def_v);
Bill Buzbeea114add2012-05-03 15:00:40 -0700483 }
buzbee67bf8852011-08-17 17:51:35 -0700484 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700485 }
buzbee862a7602013-04-05 10:58:54 -0700486 if (!temp_dalvik_register_v->Equal(bb->data_flow_info->live_in_v)) {
487 bb->data_flow_info->live_in_v->Copy(temp_dalvik_register_v);
Bill Buzbeea114add2012-05-03 15:00:40 -0700488 return true;
489 }
490 return false;
buzbee67bf8852011-08-17 17:51:35 -0700491}
492
493/* Insert phi nodes to for each variable to the dominance frontiers */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700494void MIRGraph::InsertPhiNodes() {
buzbeefa57c472012-11-21 12:06:18 -0800495 int dalvik_reg;
buzbee862a7602013-04-05 10:58:54 -0700496 ArenaBitVector* phi_blocks =
497 new (arena_) ArenaBitVector(arena_, GetNumBlocks(), false, kBitMapPhi);
498 ArenaBitVector* tmp_blocks =
499 new (arena_) ArenaBitVector(arena_, GetNumBlocks(), false, kBitMapTmpBlocks);
500 ArenaBitVector* input_blocks =
501 new (arena_) ArenaBitVector(arena_, GetNumBlocks(), false, kBitMapInputBlocks);
buzbee67bf8852011-08-17 17:51:35 -0700502
buzbee311ca162013-02-28 15:56:43 -0800503 temp_dalvik_register_v_ =
buzbee862a7602013-04-05 10:58:54 -0700504 new (arena_) ArenaBitVector(arena_, cu_->num_dalvik_registers, false, kBitMapRegisterV);
buzbee67bf8852011-08-17 17:51:35 -0700505
buzbee56c71782013-09-05 17:13:19 -0700506 RepeatingPostOrderDfsIterator iter(this);
buzbee311ca162013-02-28 15:56:43 -0800507 bool change = false;
508 for (BasicBlock* bb = iter.Next(false); bb != NULL; bb = iter.Next(change)) {
509 change = ComputeBlockLiveIns(bb);
510 }
buzbee67bf8852011-08-17 17:51:35 -0700511
Bill Buzbeea114add2012-05-03 15:00:40 -0700512 /* Iterate through each Dalvik register */
buzbee311ca162013-02-28 15:56:43 -0800513 for (dalvik_reg = cu_->num_dalvik_registers - 1; dalvik_reg >= 0; dalvik_reg--) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700514 bool change;
buzbee67bf8852011-08-17 17:51:35 -0700515
buzbee862a7602013-04-05 10:58:54 -0700516 input_blocks->Copy(def_block_matrix_[dalvik_reg]);
517 phi_blocks->ClearAllBits();
buzbee67bf8852011-08-17 17:51:35 -0700518
Bill Buzbeea114add2012-05-03 15:00:40 -0700519 /* Calculate the phi blocks for each Dalvik register */
520 do {
521 change = false;
buzbee862a7602013-04-05 10:58:54 -0700522 tmp_blocks->ClearAllBits();
523 ArenaBitVector::Iterator iterator(input_blocks);
buzbee67bf8852011-08-17 17:51:35 -0700524
Bill Buzbeea114add2012-05-03 15:00:40 -0700525 while (true) {
buzbee862a7602013-04-05 10:58:54 -0700526 int idx = iterator.Next();
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700527 if (idx == -1) {
528 break;
buzbee67bf8852011-08-17 17:51:35 -0700529 }
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700530 BasicBlock* def_bb = GetBasicBlock(idx);
Bill Buzbeea114add2012-05-03 15:00:40 -0700531
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700532 /* Merge the dominance frontier to tmp_blocks */
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700533 // TUNING: hot call to Union().
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700534 if (def_bb->dom_frontier != NULL) {
535 tmp_blocks->Union(def_bb->dom_frontier);
536 }
537 }
538 if (!phi_blocks->Equal(tmp_blocks)) {
539 change = true;
540 phi_blocks->Copy(tmp_blocks);
541
542 /*
543 * Iterate through the original blocks plus the new ones in
544 * the dominance frontier.
545 */
546 input_blocks->Copy(phi_blocks);
547 input_blocks->Union(def_block_matrix_[dalvik_reg]);
Bill Buzbeea114add2012-05-03 15:00:40 -0700548 }
549 } while (change);
550
551 /*
buzbeefa57c472012-11-21 12:06:18 -0800552 * Insert a phi node for dalvik_reg in the phi_blocks if the Dalvik
Bill Buzbeea114add2012-05-03 15:00:40 -0700553 * register is in the live-in set.
554 */
buzbee862a7602013-04-05 10:58:54 -0700555 ArenaBitVector::Iterator iterator(phi_blocks);
Bill Buzbeea114add2012-05-03 15:00:40 -0700556 while (true) {
buzbee862a7602013-04-05 10:58:54 -0700557 int idx = iterator.Next();
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700558 if (idx == -1) {
559 break;
560 }
buzbee311ca162013-02-28 15:56:43 -0800561 BasicBlock* phi_bb = GetBasicBlock(idx);
Bill Buzbeea114add2012-05-03 15:00:40 -0700562 /* Variable will be clobbered before being used - no need for phi */
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700563 if (!phi_bb->data_flow_info->live_in_v->IsBitSet(dalvik_reg)) {
564 continue;
565 }
buzbee862a7602013-04-05 10:58:54 -0700566 MIR *phi =
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700567 static_cast<MIR*>(arena_->Alloc(sizeof(MIR), ArenaAllocator::kAllocDFInfo));
buzbeecbd6d442012-11-17 14:11:25 -0800568 phi->dalvikInsn.opcode = static_cast<Instruction::Code>(kMirOpPhi);
buzbeefa57c472012-11-21 12:06:18 -0800569 phi->dalvikInsn.vA = dalvik_reg;
570 phi->offset = phi_bb->start_offset;
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700571 phi->m_unit_index = 0; // Arbitrarily assign all Phi nodes to outermost method.
buzbeefa57c472012-11-21 12:06:18 -0800572 PrependMIR(phi_bb, phi);
buzbee67bf8852011-08-17 17:51:35 -0700573 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700574 }
buzbee67bf8852011-08-17 17:51:35 -0700575}
576
577/*
578 * Worker function to insert phi-operands with latest SSA names from
579 * predecessor blocks
580 */
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700581bool MIRGraph::InsertPhiNodeOperands(BasicBlock* bb) {
Bill Buzbeea114add2012-05-03 15:00:40 -0700582 /* Phi nodes are at the beginning of each block */
buzbee0d829482013-10-11 15:24:55 -0700583 for (MIR* mir = bb->first_mir_insn; mir != NULL; mir = mir->next) {
buzbeecbd6d442012-11-17 14:11:25 -0800584 if (mir->dalvikInsn.opcode != static_cast<Instruction::Code>(kMirOpPhi))
Bill Buzbeea114add2012-05-03 15:00:40 -0700585 return true;
buzbeefa57c472012-11-21 12:06:18 -0800586 int ssa_reg = mir->ssa_rep->defs[0];
587 DCHECK_GE(ssa_reg, 0); // Shouldn't see compiler temps here
buzbee311ca162013-02-28 15:56:43 -0800588 int v_reg = SRegToVReg(ssa_reg);
buzbee67bf8852011-08-17 17:51:35 -0700589
Bill Buzbeea114add2012-05-03 15:00:40 -0700590 /* Iterate through the predecessors */
buzbee0d829482013-10-11 15:24:55 -0700591 GrowableArray<BasicBlockId>::Iterator iter(bb->predecessors);
592 size_t num_uses = bb->predecessors->Size();
593 mir->ssa_rep->num_uses = num_uses;
594 int* uses = static_cast<int*>(arena_->Alloc(sizeof(int) * num_uses,
595 ArenaAllocator::kAllocDFInfo));
596 mir->ssa_rep->uses = uses;
597 mir->ssa_rep->fp_use =
598 static_cast<bool*>(arena_->Alloc(sizeof(bool) * num_uses, ArenaAllocator::kAllocDFInfo));
599 BasicBlockId* incoming =
600 static_cast<BasicBlockId*>(arena_->Alloc(sizeof(BasicBlockId) * num_uses,
601 ArenaAllocator::kAllocDFInfo));
602 mir->meta.phi_incoming = incoming;
603 int idx = 0;
Bill Buzbeea114add2012-05-03 15:00:40 -0700604 while (true) {
buzbee0d829482013-10-11 15:24:55 -0700605 BasicBlock* pred_bb = GetBasicBlock(iter.Next());
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700606 if (!pred_bb) {
607 break;
608 }
buzbeefa57c472012-11-21 12:06:18 -0800609 int ssa_reg = pred_bb->data_flow_info->vreg_to_ssa_map[v_reg];
buzbee0d829482013-10-11 15:24:55 -0700610 uses[idx] = ssa_reg;
611 incoming[idx] = pred_bb->id;
612 idx++;
Bill Buzbeea114add2012-05-03 15:00:40 -0700613 }
614 }
615
616 return true;
buzbee67bf8852011-08-17 17:51:35 -0700617}
618
Brian Carlstrom2ce745c2013-07-17 17:44:30 -0700619void MIRGraph::DoDFSPreOrderSSARename(BasicBlock* block) {
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700620 if (block->visited || block->hidden) {
621 return;
622 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700623 block->visited = true;
buzbeef0cde542011-09-13 14:55:02 -0700624
Bill Buzbeea114add2012-05-03 15:00:40 -0700625 /* Process this block */
buzbee311ca162013-02-28 15:56:43 -0800626 DoSSAConversion(block);
627 int map_size = sizeof(int) * cu_->num_dalvik_registers;
buzbeef0cde542011-09-13 14:55:02 -0700628
Bill Buzbeea114add2012-05-03 15:00:40 -0700629 /* Save SSA map snapshot */
buzbee862a7602013-04-05 10:58:54 -0700630 int* saved_ssa_map =
Mathieu Chartierf6c4b3b2013-08-24 16:11:37 -0700631 static_cast<int*>(arena_->Alloc(map_size, ArenaAllocator::kAllocDalvikToSSAMap));
buzbee311ca162013-02-28 15:56:43 -0800632 memcpy(saved_ssa_map, vreg_to_ssa_map_, map_size);
buzbeef0cde542011-09-13 14:55:02 -0700633
buzbee0d829482013-10-11 15:24:55 -0700634 if (block->fall_through != NullBasicBlockId) {
635 DoDFSPreOrderSSARename(GetBasicBlock(block->fall_through));
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->taken != NullBasicBlockId) {
640 DoDFSPreOrderSSARename(GetBasicBlock(block->taken));
Bill Buzbeea114add2012-05-03 15:00:40 -0700641 /* Restore SSA map snapshot */
buzbee311ca162013-02-28 15:56:43 -0800642 memcpy(vreg_to_ssa_map_, saved_ssa_map, map_size);
Bill Buzbeea114add2012-05-03 15:00:40 -0700643 }
buzbee0d829482013-10-11 15:24:55 -0700644 if (block->successor_block_list_type != kNotUsed) {
645 GrowableArray<SuccessorBlockInfo*>::Iterator iterator(block->successor_blocks);
Bill Buzbeea114add2012-05-03 15:00:40 -0700646 while (true) {
buzbee862a7602013-04-05 10:58:54 -0700647 SuccessorBlockInfo *successor_block_info = iterator.Next();
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700648 if (successor_block_info == NULL) {
649 break;
650 }
buzbee0d829482013-10-11 15:24:55 -0700651 BasicBlock* succ_bb = GetBasicBlock(successor_block_info->block);
buzbee311ca162013-02-28 15:56:43 -0800652 DoDFSPreOrderSSARename(succ_bb);
Bill Buzbeea114add2012-05-03 15:00:40 -0700653 /* Restore SSA map snapshot */
buzbee311ca162013-02-28 15:56:43 -0800654 memcpy(vreg_to_ssa_map_, saved_ssa_map, map_size);
buzbeef0cde542011-09-13 14:55:02 -0700655 }
Bill Buzbeea114add2012-05-03 15:00:40 -0700656 }
buzbee311ca162013-02-28 15:56:43 -0800657 vreg_to_ssa_map_ = saved_ssa_map;
Bill Buzbeea114add2012-05-03 15:00:40 -0700658 return;
buzbeef0cde542011-09-13 14:55:02 -0700659}
660
Elliott Hughes11d1b0c2012-01-23 16:57:47 -0800661} // namespace art