Skip to content

SimplifyBeginBorrow: fix isDestroyed(after:) #70559

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
Dec 20, 2023

Conversation

eeckstein
Copy link
Contributor

@eeckstein eeckstein commented Dec 20, 2023

The previous implementation just checked that a value's only uses besides the begin_borrow were destroys. That's insufficient to say the value is destroyed after the borrow (i.e. that all its destroys are dominated by the borrow). Add the relevant dominance check.

Fixes a compiler crash

rdar://119873930

Thanks @nate-chandler for narrowing down the problem and for the test cases, which I took from #70552

The previous implementation just checked that a value's only uses besides the begin_borrow were destroys. That's insufficient to say the value is destroyed after the borrow (i.e. that all its destroys are dominated by the borrow). Add the relevant dominance check.

Fixes a compiler crash

rdar://119873930
@eeckstein
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@nate-chandler nate-chandler left a comment

Choose a reason for hiding this comment

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

lgtm

}

func replaceAllDestroys(with replacement: Value, _ context: SimplifyContext) {
uses.filterUsers(ofType: DestroyValueInst.self).replaceAll(with: replacement, context)
}
}

private extension Instruction {
func dominates(destroysOf value: Value) -> Bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

For the record. Anyone who sees instruction.dominates will assume it is an implementation of general instruction dominance. An extension of a fundamental type should have an implementation that makes sense wherever that type may be used, regardless of whether the extension is private.

@atrick
Copy link
Contributor

atrick commented Dec 20, 2023

Merging because we need to unblock the toolchain build.

@atrick atrick merged commit a0dc560 into swiftlang:main Dec 20, 2023
@eeckstein eeckstein deleted the fix-simplify-begin-borrow branch December 20, 2023 20:25
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.

3 participants