Fixed remaining review comments from #1380

This commit is contained in:
Steven Perron 2018-03-21 12:52:13 -04:00 committed by Steven Perron
parent 2e644e4578
commit dbb35c4260
4 changed files with 12 additions and 25 deletions

View File

@ -154,22 +154,20 @@ BasicBlock* CFG::SplitLoopHeader(ir::BasicBlock* bb) {
[bb](BasicBlock& block_in_func) { return &block_in_func == bb; });
assert(header_it != fn->end());
const std::vector<uint32_t>& pred = label2preds_[bb->id()];
const std::vector<uint32_t>& pred = preds(bb->id());
// Find the back edge
ir::BasicBlock* latch_block = nullptr;
{
Function::iterator latch_block_iter = header_it;
while (++latch_block_iter != fn->end()) {
// If blocks are in the proper order, then the only branch that appears
// after the header is the latch.
if (std::find(pred.begin(), pred.end(), latch_block_iter->id()) !=
pred.end()) {
break;
}
Function::iterator latch_block_iter = header_it;
while (++latch_block_iter != fn->end()) {
// If blocks are in the proper order, then the only branch that appears
// after the header is the latch.
if (std::find(pred.begin(), pred.end(), latch_block_iter->id()) !=
pred.end()) {
break;
}
assert(latch_block_iter != fn->end() && "Could not find the latch.");
latch_block = &*latch_block_iter;
}
assert(latch_block_iter != fn->end() && "Could not find the latch.");
latch_block = &*latch_block_iter;
RemoveSuccessorEdges(bb);
@ -205,7 +203,7 @@ BasicBlock* CFG::SplitLoopHeader(ir::BasicBlock* bb) {
std::vector<uint32_t> preheader_phi_ops;
std::vector<Operand> header_phi_ops;
// Idendify where the original inputs to original OpPhi belong: header or
// Identify where the original inputs to original OpPhi belong: header or
// preheader.
for (uint32_t i = 0; i < phi->NumInOperands(); i += 2) {
uint32_t def_id = phi->GetSingleWordInOperand(i);

View File

@ -121,7 +121,7 @@ class CFG {
// Divides |block| into two basic blocks. The first block will have the same
// id as |block| and will become a preheader for the loop. The other block
// becomes is a new block that will be the new loop header.
// is a new block that will be the new loop header.
//
// Returns a pointer to the new loop header.
BasicBlock* SplitLoopHeader(ir::BasicBlock* bb);

View File

@ -271,15 +271,11 @@ bool operator==(const DefUseManager& lhs, const DefUseManager& rhs) {
if (lhs.id_to_users_ != rhs.id_to_users_) {
for (auto p : lhs.id_to_users_) {
if (rhs.id_to_users_.count(p) == 0) {
std::cerr << p.first->PrettyPrint() << std::endl;
std::cerr << p.second->PrettyPrint() << std::endl;
return false;
}
}
for (auto p : rhs.id_to_users_) {
if (lhs.id_to_users_.count(p) == 0) {
std::cerr << p.first->PrettyPrint() << std::endl;
std::cerr << p.second->PrettyPrint() << std::endl;
return false;
}
}

View File

@ -209,13 +209,6 @@ void BasicBlockSuccessorHelper<BBType>::CreateSuccessorMap(
predecessors_[succ].push_back(&bb);
});
}
/*
for (BasicBlock& bb : f) {
if (predecessors_[&bb].empty()) {
predecessors_[&bb].push_back(const_cast<BasicBlock*>(dummy_start_node));
successors_[dummy_start_node].push_back(&bb);
}
} */
}
}