Skip to content

Fix BorrowingOperand more. #38183

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
Jul 1, 2021
Merged

Fix BorrowingOperand more. #38183

merged 1 commit into from
Jul 1, 2021

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Jun 30, 2021

Don't allow an owned call argument to be considered a valid BorrowingOperand.

More generally, make sure there is a perfect equivalence between valid
BorrowingOperand and the corresponding OperandOwnership kind.

Don't allow an owned call argument to be considered a valid BorrowingOperand.

More generally, make sure there is a perfect equivalence between valid
BorrowingOperand and the corresponding OperandOwnership kind.
@atrick atrick requested review from gottesmm and meg-gupta June 30, 2021 22:39
@atrick
Copy link
Contributor Author

atrick commented Jun 30, 2021

@swift-ci test

}
assert(kind != BorrowingOperandKind::Invalid && "missing case");
Copy link
Contributor

Choose a reason for hiding this comment

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

With this can we now eliminate other kinds in BorrowingOperandKind: BeginApply, TryApply etc ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@meg-gupta A guaranteed apply argument is still considered a "Borrow" here. I think BorrowingOperand is useful for BeginApply because that's a scoped instruction, so it's important to call visitScopeEndingUses in that case.

I think it is a problem that BorrowingOperand is valid for Apply/TryApply/Yield, but visitScopeEndingUses does nothing there. That will lead to bugs where we miss the use completely. I'll see if it's easy to fix that in this PR too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, it looks like we're always careful before calling visitScopeEndUses to also visit the instruction that begins the scope too. So the behavior doesn't need to be changed, but I can add a comment in the next PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM

@swift-ci
Copy link
Contributor

swift-ci commented Jul 1, 2021

Build failed
Swift Test Linux Platform
Git Sha - 573df89

@atrick
Copy link
Contributor Author

atrick commented Jul 1, 2021

@swift-ci smoke test linux

@atrick atrick merged commit 00595c0 into swiftlang:main Jul 1, 2021
@atrick atrick deleted the fix-borrow-call branch July 13, 2021 17:32
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