File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,11 @@ bool GenericCycle<ContextT>::contains(const GenericCycle *C) const {
4747template <typename ContextT>
4848void GenericCycle<ContextT>::getExitBlocks(
4949 SmallVectorImpl<BlockT *> &TmpStorage) const {
50+ if (!ExitBlocksCache->empty ()) {
51+ TmpStorage = *ExitBlocksCache;
52+ return ;
53+ }
54+
5055 TmpStorage.clear ();
5156
5257 size_t NumExitBlocks = 0 ;
@@ -65,6 +70,7 @@ void GenericCycle<ContextT>::getExitBlocks(
6570
6671 TmpStorage.resize (NumExitBlocks);
6772 }
73+ ExitBlocksCache->append (TmpStorage.begin (), TmpStorage.end ());
6874}
6975
7076template <typename ContextT>
Original file line number Diff line number Diff line change @@ -74,12 +74,16 @@ template <typename ContextT> class GenericCycle {
7474 // / always have the same depth.
7575 unsigned Depth = 0 ;
7676
77+ // / Cache for the results of GetExitBlocks
78+ std::unique_ptr<SmallVector<BlockT *, 4 >> ExitBlocksCache;
79+
7780 void clear () {
7881 Entries.clear ();
7982 Children.clear ();
8083 Blocks.clear ();
8184 Depth = 0 ;
8285 ParentCycle = nullptr ;
86+ ExitBlocksCache->clear ();
8387 }
8488
8589 void appendEntry (BlockT *Block) { Entries.push_back (Block); }
@@ -91,7 +95,8 @@ template <typename ContextT> class GenericCycle {
9195 GenericCycle &operator =(GenericCycle &&Rhs) = delete ;
9296
9397public:
94- GenericCycle () = default ;
98+ GenericCycle ()
99+ : ExitBlocksCache(std::make_unique<SmallVector<BlockT *, 4 >>()){};
95100
96101 // / \brief Whether the cycle is a natural loop.
97102 bool isReducible () const { return Entries.size () == 1 ; }
You can’t perform that action at this time.
0 commit comments