[PATCH] D45971: [LoopInfo] Verify BBMap tracks innermost loops for BBs.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 24 02:13:37 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL330698: [LoopInfo] Verify BBMap tracks innermost loops for BBs. (authored by fhahn, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45971?vs=143648&id=143694#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45971

Files:
  llvm/trunk/include/llvm/Analysis/LoopInfo.h
  llvm/trunk/include/llvm/Analysis/LoopInfoImpl.h


Index: llvm/trunk/include/llvm/Analysis/LoopInfoImpl.h
===================================================================
--- llvm/trunk/include/llvm/Analysis/LoopInfoImpl.h
+++ llvm/trunk/include/llvm/Analysis/LoopInfoImpl.h
@@ -617,6 +617,15 @@
   std::vector<BlockT *> OtherBBs = OtherL->getBlocks();
   assert(compareVectors(BBs, OtherBBs) &&
          "Mismatched basic blocks in the loops!");
+
+  const SmallPtrSetImpl<const BlockT *> &BlocksSet = L->getBlocksSet();
+  const SmallPtrSetImpl<const BlockT *> &OtherBlocksSet = L->getBlocksSet();
+  assert(BlocksSet.size() == OtherBlocksSet.size() &&
+         std::all_of(BlocksSet.begin(), BlocksSet.end(),
+                     [&OtherBlocksSet](const BlockT *BB) {
+                       return OtherBlocksSet.count(BB);
+                     }) &&
+         "Mismatched basic blocks in BlocksSets!");
 }
 #endif
 
@@ -636,6 +645,9 @@
     LoopT *L = Entry.second;
     assert(Loops.count(L) && "orphaned loop");
     assert(L->contains(BB) && "orphaned block");
+    for (LoopT *ChildLoop : *L)
+      assert(!ChildLoop->contains(BB) &&
+             "BBMap should point to the innermost loop containing BB");
   }
 
   // Recompute LoopInfo to verify loops structure.
Index: llvm/trunk/include/llvm/Analysis/LoopInfo.h
===================================================================
--- llvm/trunk/include/llvm/Analysis/LoopInfo.h
+++ llvm/trunk/include/llvm/Analysis/LoopInfo.h
@@ -178,6 +178,12 @@
     return DenseBlockSet;
   }
 
+  /// Return a direct, immutable handle to the blocks set.
+  const SmallPtrSetImpl<const BlockT *> &getBlocksSet() const {
+    assert(!isInvalid() && "Loop not in a valid state!");
+    return DenseBlockSet;
+  }
+
   /// Return true if this loop is no longer valid.  The only valid use of this
   /// helper is "assert(L.isInvalid())" or equivalent, since IsInvalid is set to
   /// true by the destructor.  In other words, if this accessor returns true,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45971.143694.patch
Type: text/x-patch
Size: 1961 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180424/4e5606b4/attachment.bin>


More information about the llvm-commits mailing list