Skip to content

Commit 12cc668

Browse files
committed
[NFC] SGC: Extract range completion.
In preparation for completing lifetimes in multiple ranges (namely post-orders of subgraphs of the function), extract a complete-in-range method.
1 parent 83ef719 commit 12cc668

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/SILOptimizer/Mandatory/SILGenCleanup.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -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

109112
bool 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

Comments
 (0)