File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
include/swift/SILOptimizer/Utils Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -313,6 +313,23 @@ class CanonicalizeOSSALifetime {
313
313
CanonicalOSSAConsumeInfo consumes;
314
314
315
315
public:
316
+ // / When rewriting destroys, is this an instruction which destroys should not
317
+ // / be hoisted over to avoid churn and infinite looping.
318
+ static bool ignoredByDestroyHoisting (SILInstructionKind kind) {
319
+ switch (kind) {
320
+ case SILInstructionKind::DestroyValueInst:
321
+ case SILInstructionKind::CopyValueInst:
322
+ case SILInstructionKind::BeginBorrowInst:
323
+ case SILInstructionKind::EndBorrowInst:
324
+ case SILInstructionKind::FunctionRefInst:
325
+ case SILInstructionKind::EnumInst:
326
+ case SILInstructionKind::StructInst:
327
+ return true ;
328
+ default :
329
+ return false ;
330
+ }
331
+ }
332
+
316
333
void maybeNotifyMoveOnlyCopy (Operand *use) {
317
334
if (!moveOnlyCopyValueNotification)
318
335
return ;
Original file line number Diff line number Diff line change @@ -492,9 +492,10 @@ void CanonicalizeOSSALifetime::findOrInsertDestroyInBlock(SILBasicBlock *bb) {
492
492
return ;
493
493
}
494
494
// This is not a potential last user. Keep scanning.
495
- // Allow lifetimes to be artificially extended up to the next call. The goal
496
- // is to prevent repeated destroy rewriting without inhibiting optimization.
497
- if (ApplySite::isa (inst)) {
495
+ // Allow lifetimes to be artificially extended up to the next non-ignored
496
+ // instruction. The goal is to prevent repeated destroy rewriting without
497
+ // inhibiting optimization.
498
+ if (!ignoredByDestroyHoisting (inst->getKind ())) {
498
499
existingDestroy = nullptr ;
499
500
} else if (!existingDestroy) {
500
501
if (auto *destroy = dyn_cast<DestroyValueInst>(inst)) {
You can’t perform that action at this time.
0 commit comments