From: Florian Hahn Date: Wed, 3 Jul 2019 20:15:14 +0000 (+0000) Subject: [LoopBase] Strengthen isLoopExiting by requiring that BB must be inside the loop. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=895cff4555666d0038616683a55b8b3e70f0c726;p=llvm [LoopBase] Strengthen isLoopExiting by requiring that BB must be inside 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365077 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 9f12596aeb1..572864925bc 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -201,9 +201,10 @@ public: } /// 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(BB)) { if (!contains(Succ)) return true;