Skip to content

Add a CanonicalOSSALifetime utility #35241

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 5 commits into from
Jan 6, 2021
Merged

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Dec 30, 2020

Canonicalizing OSSA provably minimizes the number of retains and
releases within the boundaries of that lifetime. This eliminates the
need for ad-hoc optimization of OSSA copies.

This initial implementation only canonicalizes owned values, but
canonicalizing guaranteed values is a simple extension.

This was originally part of the CopyPropagation prototype years
ago. Now OSSA is specified completely enough that it can be turned
into a simple utility instead.

CanonicalOSSALifetime uses PrunedLiveness to find the extended live
range and identify the consumes on the boundary. All other consumes
need their own copy. No other copies are needed.

By running this after other transformations that affect OSSA
lifetimes, we can avoid the need to run pattern-matching optimization
to SemanticARC to recover from suboptimal patterns, which is not
robust, maintainable, or efficient.

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.

Some questions/etc.

@atrick atrick force-pushed the canonical-ossa branch 3 times, most recently from 5fa65c9 to c15d172 Compare January 5, 2021 06:59
@atrick
Copy link
Contributor Author

atrick commented Jan 5, 2021

@swift-ci test

@swift-ci
Copy link
Contributor

swift-ci commented Jan 5, 2021

Build failed
Swift Test OS X Platform
Git Sha - c15d172736e95024cce6e992c3a40e1f20724d93

@atrick
Copy link
Contributor Author

atrick commented Jan 5, 2021

@swift-ci test

@swift-ci
Copy link
Contributor

swift-ci commented Jan 6, 2021

Build failed
Swift Test Linux Platform
Git Sha - c15d172736e95024cce6e992c3a40e1f20724d93

@atrick
Copy link
Contributor Author

atrick commented Jan 6, 2021

@swift-ci test linux platform

@swift-ci
Copy link
Contributor

swift-ci commented Jan 6, 2021

Build failed
Swift Test Linux Platform
Git Sha - c15d172736e95024cce6e992c3a40e1f20724d93

@swift-ci
Copy link
Contributor

swift-ci commented Jan 6, 2021

Build failed
Swift Test OS X Platform
Git Sha - c15d172736e95024cce6e992c3a40e1f20724d93

@atrick
Copy link
Contributor Author

atrick commented Jan 6, 2021

@swift-ci test

atrick added 2 commits January 5, 2021 20:38
Canonicalizing OSSA provably minimizes the number of retains and
releases within the boundaries of that lifetime. This eliminates the
need for ad-hoc optimization of OSSA copies.

This initial implementation only canonicalizes owned values, but
canonicalizing guaranteed values is a simple extension.

This was originally part of the CopyPropagation prototype years
ago. Now OSSA is specified completely enough that it can be turned
into a simple utility instead.

CanonicalOSSALifetime uses PrunedLiveness to find the extended live
range and identify the consumes on the boundary. All other consumes
need their own copy. No other copies are needed.

By running this after other transformations that affect OSSA
lifetimes, we can avoid the need to run pattern-matching optimization
to SemanticARC to recover from suboptimal patterns, which is not
robust, maintainable, or efficient.
MandatoryCopyPropagation must be a separate pass in order to preserve
all debug_value instructions. CopyPropagation cannot preserve
debug_value because, as a rule, debug information cannot affect -O
behavior.
@atrick
Copy link
Contributor Author

atrick commented Jan 6, 2021

@swift-ci test

@swift-ci
Copy link
Contributor

swift-ci commented Jan 6, 2021

Build failed
Swift Test Linux Platform
Git Sha - 791f580bd9827ef8d9cf7affb9b640396742d3c7

@atrick
Copy link
Contributor Author

atrick commented Jan 6, 2021

lldb has broken PR testing again

/home/buildnode/jenkins/workspace/swift-PR-Linux@2/branch-main/llvm-project/lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp:2341:22: error: no member named 'make_scope_exit' in namespace 'llvm'
22:03:08   auto defer = llvm::make_scope_exit([&] {
22:03:08                ~~~~~~^
22:03:08 1 error generated.

atrick added 2 commits January 5, 2021 22:20
If a guaranteed value is not a recognized and handled borrow
introducer, then treat the copy as a separate owned live range.
@atrick
Copy link
Contributor Author

atrick commented Jan 6, 2021

@swift-ci test

@atrick atrick merged commit d6eb325 into swiftlang:main Jan 6, 2021
@atrick atrick deleted the canonical-ossa branch October 19, 2022 00:27
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