summaryrefslogtreecommitdiff
path: root/include/llvm/Analysis/LoopInfoImpl.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-06-26 20:32:52 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-06-26 20:32:52 +0000
commit08bbd35a80bf7765fe0d3043f9eb5a2f2786b649 (patch)
tree80108f0f128657f8623f8f66ad9735b4d88e7b47 /include/llvm/Analysis/LoopInfoImpl.h
parent7c7aba6e5fef47a01a136be655b0a92cfd7090f6 (diff)
Diffstat (limited to 'include/llvm/Analysis/LoopInfoImpl.h')
-rw-r--r--include/llvm/Analysis/LoopInfoImpl.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/include/llvm/Analysis/LoopInfoImpl.h b/include/llvm/Analysis/LoopInfoImpl.h
index 6ff4335f1ad5..372fc8b21745 100644
--- a/include/llvm/Analysis/LoopInfoImpl.h
+++ b/include/llvm/Analysis/LoopInfoImpl.h
@@ -91,8 +91,9 @@ getExitEdges(SmallVectorImpl<Edge> &ExitEdges) const {
/// getLoopPreheader - If there is a preheader for this loop, return it. A
/// loop has a preheader if there is only one edge to the header of the loop
-/// from outside of the loop. If this is the case, the block branching to the
-/// header of the loop is the preheader node.
+/// from outside of the loop and it is legal to hoist instructions into the
+/// predecessor. If this is the case, the block branching to the header of the
+/// loop is the preheader node.
///
/// This method returns null if there is no preheader for the loop.
///
@@ -102,6 +103,10 @@ BlockT *LoopBase<BlockT, LoopT>::getLoopPreheader() const {
BlockT *Out = getLoopPredecessor();
if (!Out) return nullptr;
+ // Make sure we are allowed to hoist instructions into the predecessor.
+ if (!Out->isLegalToHoistInto())
+ return nullptr;
+
// Make sure there is only one exit out of the preheader.
typedef GraphTraits<BlockT*> BlockTraits;
typename BlockTraits::ChildIteratorType SI = BlockTraits::child_begin(Out);