summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineBlockPlacement.cpp
diff options
context:
space:
mode:
authorXin Tong <trent.xin.tong@gmail.com>2017-10-04 21:39:25 +0000
committerXin Tong <trent.xin.tong@gmail.com>2017-10-04 21:39:25 +0000
commitd8d97972de792443f6b336ed6d13cf2e5b65151e (patch)
tree1fe43a4df43f3f541cba05c5dcfbd621706165a5 /llvm/lib/CodeGen/MachineBlockPlacement.cpp
parent899809d5313d83b5e9d0f379fbc7782dd2b76e6a (diff)
downloadbcm5719-llvm-d8d97972de792443f6b336ed6d13cf2e5b65151e.tar.gz
bcm5719-llvm-d8d97972de792443f6b336ed6d13cf2e5b65151e.zip
[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
Diffstat (limited to 'llvm/lib/CodeGen/MachineBlockPlacement.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBlockPlacement.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index f135cf71593..12d8a9a0217 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -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
OpenPOWER on IntegriCloud