diff options
| author | Florian Hahn <florian.hahn@arm.com> | 2018-04-24 09:10:05 +0000 |
|---|---|---|
| committer | Florian Hahn <florian.hahn@arm.com> | 2018-04-24 09:10:05 +0000 |
| commit | f3561ffa878720c0cb8bc022a2d0d3a70aacb004 (patch) | |
| tree | e71eed3fb44a87af6be1112bd435e9c2155ed9de | |
| parent | eb1053f9d3679111c3261fc33a82b6e0a7001c72 (diff) | |
| download | bcm5719-llvm-f3561ffa878720c0cb8bc022a2d0d3a70aacb004.tar.gz bcm5719-llvm-f3561ffa878720c0cb8bc022a2d0d3a70aacb004.zip | |
[LoopInfo] Verify BBMap tracks innermost loops for BBs.
By checking that none of the child loops contain a BB we make sure BBMap
contains the innermost loop defining BB. This invariant was violated in
LoopInterchange and got caught by this assertion.
Reviewers: chandlerc, mzolotukhin, sanjoy, mehdi_amini, efriedma
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D45971
llvm-svn: 330698
| -rw-r--r-- | llvm/include/llvm/Analysis/LoopInfo.h | 6 | ||||
| -rw-r--r-- | llvm/include/llvm/Analysis/LoopInfoImpl.h | 12 |
2 files changed, 18 insertions, 0 deletions
diff --git a/llvm/include/llvm/Analysis/LoopInfo.h b/llvm/include/llvm/Analysis/LoopInfo.h index 49f40f70188..e01f9a9f45d 100644 --- a/llvm/include/llvm/Analysis/LoopInfo.h +++ b/llvm/include/llvm/Analysis/LoopInfo.h @@ -178,6 +178,12 @@ public: 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, diff --git a/llvm/include/llvm/Analysis/LoopInfoImpl.h b/llvm/include/llvm/Analysis/LoopInfoImpl.h index 91b986455ec..e2620459107 100644 --- a/llvm/include/llvm/Analysis/LoopInfoImpl.h +++ b/llvm/include/llvm/Analysis/LoopInfoImpl.h @@ -617,6 +617,15 @@ static void compareLoops(const LoopT *L, const LoopT *OtherL, 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 @@ void LoopInfoBase<BlockT, LoopT>::verify( 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. |

