summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
diff options
context:
space:
mode:
authorAnna Thomas <anna@azul.com>2017-05-03 17:43:59 +0000
committerAnna Thomas <anna@azul.com>2017-05-03 17:43:59 +0000
commitac0ec2240b9aa3aa4212db3bb3eac57c2a49d600 (patch)
treeb6a4ab2a135dd8a360a8e4a9bb537955732a0a98 /llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
parent9232eb4cceac9ea878d39e84d52473132fe336aa (diff)
downloadbcm5719-llvm-ac0ec2240b9aa3aa4212db3bb3eac57c2a49d600.tar.gz
bcm5719-llvm-ac0ec2240b9aa3aa4212db3bb3eac57c2a49d600.zip
[RuntimeLoopUnroller] Add assert that we dont unroll non-rotated loops
Summary: Cloning basic blocks in the loop for runtime loop unroller depends on loop being in rotated form (i.e. loop latch target is the exit block). Assert that this is true, so that callers of runtime loop unroller pass in canonical loops. The single caller of this function has that check recently added: https://reviews.llvm.org/rL301239 Reviewers: davide Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32801 llvm-svn: 302058
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
index 85db734fb18..305b87ea287 100644
--- a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
@@ -512,6 +512,13 @@ bool llvm::UnrollRuntimeLoopRemainder(Loop *L, unsigned Count,
BasicBlock *Latch = L->getLoopLatch();
+ // Cloning the loop basic blocks (`CloneLoopBlocks`) requires that one of the
+ // targets of the Latch be the single exit block out of the loop. This needs
+ // to be guaranteed by the callers of UnrollRuntimeLoopRemainder.
+ BranchInst *LatchBR = cast<BranchInst>(Latch->getTerminator());
+ assert(LatchBR->getSuccessor(0) == Exit ||
+ LatchBR->getSuccessor(1) == Exit && "loop latch successor should be "
+ "exit block!");
// Loop structure is the following:
//
// PreHeader
OpenPOWER on IntegriCloud