[LoopInfo] Remove duplicates in ExitBlocks to reduce the compile time of

hasDedicatedExits.

For the compile time problem described in https://reviews.llvm.org/D67359,
turns out the root cause is there are many duplicates in ExitBlocks so
the algorithm complexity of hasDedicatedExits gets very high. If we remove
the duplicates, the compile time issue is gone.

Thanks to Philip Reames for raising a good question and it leads me to
find the root cause.

Differential Revision: https://reviews.llvm.org/D68107

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373045 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Wei Mi 2019-09-27 05:43:31 +00:00
parent e2acd37dc9
commit 92a8cd19d4

View File

@ -85,9 +85,9 @@ template <class BlockT, class LoopT>
bool LoopBase<BlockT, LoopT>::hasDedicatedExits() const {
// Each predecessor of each exit block of a normal loop is contained
// within the loop.
SmallVector<BlockT *, 4> ExitBlocks;
getExitBlocks(ExitBlocks);
for (BlockT *EB : ExitBlocks)
SmallVector<BlockT *, 4> UniqueExitBlocks;
getUniqueExitBlocks(UniqueExitBlocks);
for (BlockT *EB : UniqueExitBlocks)
for (BlockT *Predecessor : children<Inverse<BlockT *>>(EB))
if (!contains(Predecessor))
return false;