Restrict the definition of loop preheader to avoid EH blocks

Differential Revision: https://reviews.llvm.org/D34487

llvm-svn: 306070
This commit is contained in:
Andrew Kaylor
2017-06-22 23:27:16 +00:00
parent 08b20356c3
commit d49711996f
6 changed files with 73 additions and 2 deletions

View File

@@ -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