[llvm] r365077 - [LoopBase] Strengthen isLoopExiting by requiring that BB must be inside the loop.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 3 13:15:14 PDT 2019


Author: fhahn
Date: Wed Jul  3 13:15:14 2019
New Revision: 365077

URL: http://llvm.org/viewvc/llvm-project?rev=365077&view=rev
Log:
[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

Modified:
    llvm/trunk/include/llvm/Analysis/LoopInfo.h

Modified: llvm/trunk/include/llvm/Analysis/LoopInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopInfo.h?rev=365077&r1=365076&r2=365077&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopInfo.h Wed Jul  3 13:15:14 2019
@@ -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;




More information about the llvm-commits mailing list