73
73
BasicBlock& continue_target_block = blocks_.at(continue_id);
74
74
assert(current_block_ &&
75
75
"RegisterLoopMerge must be called when called within a block");
76
current_block_->RegisterStructuralSuccessor(&merge_block);
77
current_block_->RegisterStructuralSuccessor(&continue_target_block);
77
79
current_block_->set_type(kBlockTypeLoop);
78
80
merge_block.set_type(kBlockTypeMerge);
101
103
current_block_->set_type(kBlockTypeSelection);
102
104
merge_block.set_type(kBlockTypeMerge);
103
105
merge_block_header_[&merge_block] = current_block_;
106
current_block_->RegisterStructuralSuccessor(&merge_block);
105
108
AddConstruct({ConstructType::kSelection, current_block(), &merge_block});
254
Function::GetBlocksFunction
255
Function::AugmentedCFGSuccessorsFunctionIncludingHeaderToContinueEdge() const {
256
return [this](const BasicBlock* block) {
257
auto where = loop_header_successors_plus_continue_target_map_.find(block);
258
return where == loop_header_successors_plus_continue_target_map_.end()
259
? AugmentedCFGSuccessorsFunction()(block)
264
257
Function::GetBlocksFunction Function::AugmentedCFGPredecessorsFunction() const {
265
258
return [this](const BasicBlock* block) {
266
259
auto where = augmented_predecessors_map_.find(block);
265
Function::GetBlocksFunction Function::AugmentedStructuralCFGSuccessorsFunction()
267
return [this](const BasicBlock* block) {
268
auto where = augmented_successors_map_.find(block);
269
return where == augmented_successors_map_.end()
270
? block->structural_successors()
275
Function::GetBlocksFunction
276
Function::AugmentedStructuralCFGPredecessorsFunction() const {
277
return [this](const BasicBlock* block) {
278
auto where = augmented_predecessors_map_.find(block);
279
return where == augmented_predecessors_map_.end()
280
? block->structural_predecessors()
272
285
void Function::ComputeAugmentedCFG() {
273
286
// Compute the successors of the pseudo-entry block, and
274
287
// the predecessors of the pseudo exit block.
275
auto succ_func = [](const BasicBlock* b) { return b->successors(); };
276
auto pred_func = [](const BasicBlock* b) { return b->predecessors(); };
288
auto succ_func = [](const BasicBlock* b) {
289
return b->structural_successors();
291
auto pred_func = [](const BasicBlock* b) {
292
return b->structural_predecessors();
277
294
CFA<BasicBlock>::ComputeAugmentedCFG(
278
295
ordered_blocks_, &pseudo_entry_block_, &pseudo_exit_block_,
279
296
&augmented_successors_map_, &augmented_predecessors_map_, succ_func,