[MachineBlockPlacement] Make sure PreferredLoopExit is cleared everytime new loop is processed

Summary: Rotate on exit that actually exits the current loop.

Reviewers: davidxl, danielcdh, iteratee, chandlerc

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D38563

llvm-svn: 314937
This commit is contained in:
Xin Tong 2017-10-04 21:39:25 +00:00
parent 899809d531
commit d8d97972de
1 changed files with 10 additions and 0 deletions

View File

@ -2233,9 +2233,19 @@ void MachineBlockPlacement::buildLoopChains(const MachineLoop &L) {
// If we selected just the header for the loop top, look for a potentially
// profitable exit block in the event that rotating the loop can eliminate
// branches by placing an exit edge at the bottom.
//
// Loops are processed innermost to uttermost, make sure we clear
// PreferredLoopExit before processing a new loop.
PreferredLoopExit = nullptr;
if (!RotateLoopWithProfile && LoopTop == L.getHeader())
PreferredLoopExit = findBestLoopExit(L, LoopBlockSet);
// Make sure PreferredLoopExit actually exits the current loop.
if (PreferredLoopExit) {
assert(L.isLoopExiting(PreferredLoopExit) &&
"not an exiting block of current loop");
}
BlockChain &LoopChain = *BlockToChain[LoopTop];
// FIXME: This is a really lame way of walking the chains in the loop: we