From 40d4b53329d564588a99cb02b0c357fd8f90532a Mon Sep 17 00:00:00 2001 From: Wei Mi Date: Fri, 27 Sep 2019 05:43:31 +0000 Subject: [PATCH] [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 llvm-svn: 373045 --- llvm/include/llvm/Analysis/LoopInfoImpl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/Analysis/LoopInfoImpl.h b/llvm/include/llvm/Analysis/LoopInfoImpl.h index 2f38dde..8b11e84 100644 --- a/llvm/include/llvm/Analysis/LoopInfoImpl.h +++ b/llvm/include/llvm/Analysis/LoopInfoImpl.h @@ -85,9 +85,9 @@ template bool LoopBase::hasDedicatedExits() const { // Each predecessor of each exit block of a normal loop is contained // within the loop. - SmallVector ExitBlocks; - getExitBlocks(ExitBlocks); - for (BlockT *EB : ExitBlocks) + SmallVector UniqueExitBlocks; + getUniqueExitBlocks(UniqueExitBlocks); + for (BlockT *EB : UniqueExitBlocks) for (BlockT *Predecessor : children>(EB)) if (!contains(Predecessor)) return false; -- 2.7.4