Skip to content

Commit

Permalink
[LoopBase] Strengthen isLoopExiting by requiring that BB must be insi…
Browse files Browse the repository at this point in the history
…de the loop.

Currently isLoopExiting returns true for BBs that are not part of the
loop. To avoid hiding subtle bugs, this patch adds an assertion to make
sure the passed BB is inside the loop

Reviewers: reames, efriedma, hfinkel, arsenm, nhaehnle

Reviewed By: reames

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

llvm-svn: 365077
  • Loading branch information
fhahn committed Jul 3, 2019
1 parent f12b75b commit 78a60c7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion llvm/include/llvm/Analysis/LoopInfo.h
Expand Up @@ -201,9 +201,10 @@ template <class BlockT, class LoopT> class LoopBase {
}

/// True if terminator in the block can branch to another block that is
/// outside of the current loop.
/// outside of the current loop. \p BB must be inside the loop.
bool isLoopExiting(const BlockT *BB) const {
assert(!isInvalid() && "Loop not in a valid state!");
assert(contains(BB) && "Exiting block must be part of the loop");
for (const auto &Succ : children<const BlockT *>(BB)) {
if (!contains(Succ))
return true;
Expand Down

0 comments on commit 78a60c7

Please sign in to comment.