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 {
313313 CanonicalOSSAConsumeInfo consumes;
314314
315315public:
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+
316333 void maybeNotifyMoveOnlyCopy (Operand *use) {
317334 if (!moveOnlyCopyValueNotification)
318335 return ;
Original file line number Diff line number Diff line change @@ -492,9 +492,10 @@ void CanonicalizeOSSALifetime::findOrInsertDestroyInBlock(SILBasicBlock *bb) {
492492 return ;
493493 }
494494 // 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 ())) {
498499 existingDestroy = nullptr ;
499500 } else if (!existingDestroy) {
500501 if (auto *destroy = dyn_cast<DestroyValueInst>(inst)) {
You can’t perform that action at this time.
0 commit comments