@@ -104,6 +104,9 @@ struct SILGenCleanup : SILModuleTransform {
104104 void run () override ;
105105
106106 bool completeOSSALifetimes (SILFunction *function);
107+ template <typename Range>
108+ bool completeLifetimesInRange (Range const &range,
109+ OSSALifetimeCompletion &completion);
107110};
108111
109112bool SILGenCleanup::completeOSSALifetimes (SILFunction *function) {
@@ -120,7 +123,16 @@ bool SILGenCleanup::completeOSSALifetimes(SILFunction *function) {
120123 getAnalysis<PostOrderAnalysis>()->get (function);
121124 DeadEndBlocks *deb = getAnalysis<DeadEndBlocksAnalysis>()->get (function);
122125 OSSALifetimeCompletion completion (function, /* DomInfo*/ nullptr , *deb);
123- for (auto *block : postOrder->getPostOrder ()) {
126+ changed |= completeLifetimesInRange (postOrder->getPostOrder (), completion);
127+ function->verifyOwnership (/* deadEndBlocks=*/ nullptr );
128+ return changed;
129+ }
130+
131+ template <typename Range>
132+ bool SILGenCleanup::completeLifetimesInRange (
133+ Range const &range, OSSALifetimeCompletion &completion) {
134+ bool changed = false ;
135+ for (auto *block : range) {
124136 LLVM_DEBUG (llvm::dbgs ()
125137 << " Completing lifetimes in bb" << block->getDebugID () << " \n " );
126138 for (SILInstruction &inst : reverse (*block)) {
@@ -145,7 +157,6 @@ bool SILGenCleanup::completeOSSALifetimes(SILFunction *function) {
145157 }
146158 }
147159 }
148- function->verifyOwnership (/* deadEndBlocks=*/ nullptr );
149160 return changed;
150161}
151162
0 commit comments