diff options
author | Andrew Kaylor <andrew.kaylor@intel.com> | 2017-06-22 23:27:16 +0000 |
---|---|---|
committer | Andrew Kaylor <andrew.kaylor@intel.com> | 2017-06-22 23:27:16 +0000 |
commit | d49711996f94cc73908d03d51938ffaaa40c3da9 (patch) | |
tree | 746c8477aa8c0030daf60acf094072faa3ba77d7 /llvm/include | |
parent | 08b20356c3f3aa3a7442bd4c2a0d7f3bd294ad8f (diff) | |
download | bcm5719-llvm-d49711996f94cc73908d03d51938ffaaa40c3da9.tar.gz bcm5719-llvm-d49711996f94cc73908d03d51938ffaaa40c3da9.zip |
Restrict the definition of loop preheader to avoid EH blocks
Differential Revision: https://reviews.llvm.org/D34487
llvm-svn: 306070
Diffstat (limited to 'llvm/include')
-rw-r--r-- | llvm/include/llvm/Analysis/LoopInfoImpl.h | 9 | ||||
-rw-r--r-- | llvm/include/llvm/CodeGen/MachineBasicBlock.h | 3 | ||||
-rw-r--r-- | llvm/include/llvm/IR/BasicBlock.h | 3 |
3 files changed, 13 insertions, 2 deletions
diff --git a/llvm/include/llvm/Analysis/LoopInfoImpl.h b/llvm/include/llvm/Analysis/LoopInfoImpl.h index 6ff4335f1ad..372fc8b2174 100644 --- a/llvm/include/llvm/Analysis/LoopInfoImpl.h +++ b/llvm/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); diff --git a/llvm/include/llvm/CodeGen/MachineBasicBlock.h b/llvm/include/llvm/CodeGen/MachineBasicBlock.h index 051908c40df..97a49ce4dc4 100644 --- a/llvm/include/llvm/CodeGen/MachineBasicBlock.h +++ b/llvm/include/llvm/CodeGen/MachineBasicBlock.h @@ -376,6 +376,9 @@ public: /// Indicates if this is the entry block of a cleanup funclet. void setIsCleanupFuncletEntry(bool V = true) { IsCleanupFuncletEntry = V; } + /// Returns true if it is legal to hoist instructions into this block. + bool isLegalToHoistInto() const; + // Code Layout methods. /// Move 'this' block before or after the specified block. This only moves diff --git a/llvm/include/llvm/IR/BasicBlock.h b/llvm/include/llvm/IR/BasicBlock.h index 74ad1930909..7a35afcbafc 100644 --- a/llvm/include/llvm/IR/BasicBlock.h +++ b/llvm/include/llvm/IR/BasicBlock.h @@ -395,6 +395,9 @@ public: static_cast<const BasicBlock *>(this)->getLandingPadInst()); } + /// \brief Return true if it is legal to hoist instructions into this block. + bool isLegalToHoistInto() const; + private: /// \brief Increment the internal refcount of the number of BlockAddresses /// referencing this BasicBlock by \p Amt. |