Skip to content

Fix DCE of load_borrow when it is derived from another borrow scope #77300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

meg-gupta
Copy link
Contributor

@meg-gupta meg-gupta commented Oct 30, 2024

If a load_borrow was computed from another borrow scope, disable DCE of the parent borrow.
This is because when its reborrow is dead, DCE has to insert end_borrows in predecessor blocks and it cannot yet handle borrow nesting and can run into an issue if the parent borrow's reborrow is adjacent and dead.

Alternatively, we can allow DCE to insert end_borrows inside-out.

Fixes rdar://138663452

@meg-gupta
Copy link
Contributor Author

@swift-ci test

@meg-gupta
Copy link
Contributor Author

@swift-ci test Linux platform

}
}
break;
}
case SILInstructionKind::LoadBorrowInst: {
findGuaranteedPhiDependencies(BorrowedValue(cast<LoadBorrowInst>(&I)));
auto *loadBorrowInst = cast<LoadBorrowInst>(&I);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you avoid this code duplication? Either by extracting it into a helper function or even merging the two switch cases

@meg-gupta meg-gupta force-pushed the dcebug2 branch 2 times, most recently from f2210b3 to b407f2e Compare November 14, 2024 20:07
@meg-gupta
Copy link
Contributor Author

@swift-ci test

@meg-gupta meg-gupta enabled auto-merge November 14, 2024 20:10
@meg-gupta meg-gupta merged commit 34a2618 into swiftlang:main Nov 15, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants