@@ -104,6 +104,9 @@ struct SILGenCleanup : SILModuleTransform {
104
104
void run () override ;
105
105
106
106
bool completeOSSALifetimes (SILFunction *function);
107
+ template <typename Range>
108
+ bool completeLifetimesInRange (Range const &range,
109
+ OSSALifetimeCompletion &completion);
107
110
};
108
111
109
112
bool SILGenCleanup::completeOSSALifetimes (SILFunction *function) {
@@ -120,7 +123,16 @@ bool SILGenCleanup::completeOSSALifetimes(SILFunction *function) {
120
123
getAnalysis<PostOrderAnalysis>()->get (function);
121
124
DeadEndBlocks *deb = getAnalysis<DeadEndBlocksAnalysis>()->get (function);
122
125
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) {
124
136
LLVM_DEBUG (llvm::dbgs ()
125
137
<< " Completing lifetimes in bb" << block->getDebugID () << " \n " );
126
138
for (SILInstruction &inst : reverse (*block)) {
@@ -145,7 +157,6 @@ bool SILGenCleanup::completeOSSALifetimes(SILFunction *function) {
145
157
}
146
158
}
147
159
}
148
- function->verifyOwnership (/* deadEndBlocks=*/ nullptr );
149
160
return changed;
150
161
}
151
162
0 commit comments