]> granicus.if.org Git - llvm/commitdiff
[LoopBase] Strengthen isLoopExiting by requiring that BB must be inside the loop.
authorFlorian Hahn <flo@fhahn.com>
Wed, 3 Jul 2019 20:15:14 +0000 (20:15 +0000)
committerFlorian Hahn <flo@fhahn.com>
Wed, 3 Jul 2019 20:15:14 +0000 (20:15 +0000)
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

include/llvm/Analysis/LoopInfo.h

index 9f12596aeb19ea2d364f449ca90530222d4b6e27..572864925bc8cd70d148a616f140e8364846b7cb 100644 (file)
@@ -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<const BlockT *>(BB)) {
       if (!contains(Succ))
         return true;