DeadObjectElimination: handle OSSA instructions when analyzing class destructors

Handle typical patterns which are generated by SILGen.
This commit is contained in:
Erik Eckstein
2024-12-24 11:56:34 +01:00
parent 55189bae8e
commit 41dd3dc453
3 changed files with 43 additions and 0 deletions

View File

@@ -204,6 +204,10 @@ static DestructorEffects doesDestructorHaveSideEffects(AllocRefInstBase *ARI) {
continue;
}
if (isa<BeginBorrowInst>(I) || isa<EndBorrowInst>(I) || isa<EndLifetimeInst>(I)) {
continue;
}
// dealloc_ref on self can be ignored, but dealloc_ref on anything else
// cannot be eliminated.
if (auto *DeallocRef = dyn_cast<DeallocRefInst>(&I)) {