From d49711996f94cc73908d03d51938ffaaa40c3da9 Mon Sep 17 00:00:00 2001 From: Andrew Kaylor Date: Thu, 22 Jun 2017 23:27:16 +0000 Subject: Restrict the definition of loop preheader to avoid EH blocks Differential Revision: https://reviews.llvm.org/D34487 llvm-svn: 306070 --- llvm/lib/IR/BasicBlock.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'llvm/lib/IR/BasicBlock.cpp') diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp index 1f8659d4e2c..2b780adf6c6 100644 --- a/llvm/lib/IR/BasicBlock.cpp +++ b/llvm/lib/IR/BasicBlock.cpp @@ -355,6 +355,19 @@ bool BasicBlock::canSplitPredecessors() const { return true; } +bool BasicBlock::isLegalToHoistInto() const { + auto *Term = getTerminator(); + // No terminator means the block is under construction. + if (!Term) + return true; + + // If the block has no successors, there can be no instructions to hoist. + assert(Term->getNumSuccessors() > 0); + + // Instructions should not be hoisted across exception handling boundaries. + return !Term->isExceptional(); +} + /// This splits a basic block into two at the specified /// instruction. Note that all instructions BEFORE the specified iterator stay /// as part of the original basic block, an unconditional branch is added to -- cgit v1.2.3