Skip to content

Commit 6fd25f6

Browse files
committed
[OwnedLifetimeCan] Barriers affect direct destroys
Copies of a lexical lifetime are not lexical. Their destroys can be hoisted over deinit barriers. So when extending lifetimes to deinit barriers, only deal with the direct lifetime, not the copy-extended lifetime.
1 parent a60f05e commit 6fd25f6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/SILOptimizer/Utils/CanonicalizeOSSALifetime.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,20 +285,22 @@ void CanonicalizeOSSALifetime::extendLivenessToDeinitBarriers() {
285285
});
286286
});
287287

288-
ArrayRef<SILInstruction *> ends = {};
289-
SmallVector<SILInstruction *, 8> lexicalEnds;
288+
SmallVector<SILInstruction *, 8> ends;
290289
if (currentLexicalLifetimeEnds.size() > 0) {
291290
visitExtendedUnconsumedBoundary(
292291
currentLexicalLifetimeEnds,
293-
[&lexicalEnds](auto *instruction, auto lifetimeEnding) {
292+
[&ends](auto *instruction, auto lifetimeEnding) {
294293
instruction->visitSubsequentInstructions([&](auto *next) {
295-
lexicalEnds.push_back(next);
294+
ends.push_back(next);
296295
return true;
297296
});
298297
});
299-
ends = lexicalEnds;
300298
} else {
301-
ends = outsideDestroys;
299+
for (auto destroy : destroys) {
300+
if (destroy->getOperand(0) != getCurrentDef())
301+
continue;
302+
ends.push_back(destroy);
303+
}
302304
}
303305

304306
auto *def = getCurrentDef()->getDefiningInstruction();

0 commit comments

Comments
 (0)