Skip to content

OSSA: Rewrite address cloning code to fix issues and fix an infinite loop in the ownership verifier. #36152

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 4 commits into from
Feb 26, 2021

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Feb 25, 2021

4 commits...

Fix an infinite loop in the OSSA verifier exposed by the new mark_dependence test cases.

Generalize the AccessUseDefChainCloner in MemAccessUtils. It was
always meant to work this way, just needed a client.

Add a new API AccessUseDefChainCloner::canCloneUseDefChain().

Add a bailout for begin_borrow and mark_dependence. Those
projections may appear on an access path, but they can't be
individually cloned without compensating.

Delete InteriorPointerAddressRebaseUseDefChainCloner.

Add a check in OwnershipRAUWHelper for canCloneUseDefChain.

Add test cases for begin_borrow and mark_dependence.

This was an obvious thinko that must not have been hit yet in practice.
So I can test interesting ownership RAUW cases.
Very long unreadable names are not a substitute for describing a test.
Generalize the AccessUseDefChainCloner in MemAccessUtils. It was
always meant to work this way, just needed a client.

Add a new API AccessUseDefChainCloner::canCloneUseDefChain().

Add a bailout for begin_borrow and mark_dependence. Those
projections may appear on an access path, but they can't be
individually cloned without compensating.

Delete InteriorPointerAddressRebaseUseDefChainCloner.

Add a check in OwnershipRAUWHelper for canCloneUseDefChain.

Add test cases for begin_borrow and mark_dependence.
@atrick
Copy link
Contributor Author

atrick commented Feb 25, 2021

@swift-ci test

@atrick
Copy link
Contributor Author

atrick commented Feb 25, 2021

@swift-ci test source compatibility

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 66752e9

@atrick
Copy link
Contributor Author

atrick commented Feb 25, 2021

An unrelated lldb test failed on macos.

@atrick
Copy link
Contributor Author

atrick commented Feb 25, 2021

@swift-ci smoke test macos

@atrick
Copy link
Contributor Author

atrick commented Feb 25, 2021

@swift-ci test macOS

Copy link
Contributor

@gottesmm gottesmm left a comment

Choose a reason for hiding this comment

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

A few comment mixups that I think would make it clearer. Can you do them in a follow on commit?

/// Clone all projections and casts on the access use-def chain until either the
/// specified predicate is true or the access base is reached.
/// Clone all projections and casts on the access use-def chain until the
/// checkBase predicate returns a valid base.
Copy link
Contributor

Choose a reason for hiding this comment

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

In a subsequent commit, can you describe the function signature of checkBase here and specify what it means to return a "valid" base. Without that I don't know what that means. I would maybe do something like this:

Clone all projections and cases on the access use-def chain until the checkBase predicate returns a valid SILValue as a base.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The next line below says "See comments on the cloneUseDefChain() API."

/// This will not clone ref_element_addr or ref_tail_addr because those aren't
/// part of the access chain.
///
/// CheckBase is a unary predicate that takes the next source address and either
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the comment on CheckBase that I wanted above. Maybe add a note above to point here for more information about CheckBase?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had all these comments duplicated, decided the was a bad idea, so added See comments on the cloneUseDefChain() API.

@@ -768,7 +768,7 @@ bool InteriorPointerOperand::findTransitiveUsesForAddress(
}

// If we are the value use, look through it.
llvm::copy(mdi->getValue()->getUses(), std::back_inserter(worklist));
llvm::copy(mdi->getUses(), std::back_inserter(worklist));
Copy link
Contributor

Choose a reason for hiding this comment

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

I am guessing this was the infinite loop? Such a thinko = /.

@atrick atrick merged commit 7880a2f into swiftlang:main Feb 26, 2021
@atrick atrick deleted the fix-rauwclone branch October 18, 2022 23:57
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