-
Notifications
You must be signed in to change notification settings - Fork 10.5k
OperandOwnership fixes required for CanonicalOSSA #35248
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
Conversation
02c9792
to
df24d83
Compare
A NonUse operand does not use the value itself, so it ignores ownership and does not require liveness. This is for operands that represent dependence on a type but are not actually passed the value of that type (e.g. they may refer an open_existential). This could be used for other dependence-only operands in the future. A TrivialUse operand has undefined ownership semantics aside from requiring liveness. Therefore it is only legal to pass the use a value with ownership None (a trivial value). Contrast this with things like InstantaneousUse or BitwiseEscape, which just don't care about ownership (i.e. they have no ownership semantics. All of the explicitly listed operations in this category require trivially typed operands. So the meaning is obvious to anyone adding SIL operations and updating OperandOwnership.cpp, without needing to decifer the value ownership kinds.
This is only used for OSSA verification currently, but will be a correctness issue when OSSA canonicalization is enabled.
Anything with a borrow scope in the caller needs to be considered a Borrow of its operand. The end_apply needs to be considered the lifetime-ending use of the borrow.
The begin_apply token represents the borrow scope of all owned and guaranteed call arguments. Although SILToken is (currently) trivially typed, it must have guaranteed ownership so end_apply and abort_apply will be recognized as lifetime-ending uses.
Now that OperandOwnership determines the operand constraints, it doesn't make sense to distinguish between Borrow and NestedBorrow at this level. We want these uses to automatically convert between the nested/non-nested state as the operand's ownership changes. The use does not need to impose any constraint on the ownership of the incoming value. For algorithms that need to distinguish nested borrows, it's still trivial to do so.
It's against the principles of pass design to check the driver mode within the pass. A pass always needs to do the same thing regardless of where it runs in the pass pipeline. It also needs to be possible to test passes in isolation.
Canonicalization should be able to convert a nested borrow to a borrow. In this case, the coroutine was a nested borrow and becomes a borrow.
It is illegal to borrow an unowned value. Unowned values are only allowed to have specific instantaneous uses. In this case, an unchecked conversion is valid because there is an assumption that within a destructor, self is guaranteed.
df24d83
to
07fccd9
Compare
@swift-ci test |
@swift-ci benchmark |
@swift-ci test source compatibility |
Performance: -O
Code size: -OPerformance: -OsizeCode size: -OsizePerformance: -Onone
Code size: -swiftlibsHow to read the dataThe tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.If you see any unexpected regressions, you should consider fixing the Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
Build failed |
Borrowing an unowned value is illegal.
All tests, SCK, benchmarks pass. Rebasing to fix a CHECK line in IRGen/async/builtins. |
07fccd9
to
24fa288
Compare
@swift-ci test |
Build failed |
Build failed |
@swift-ci test |
Build failed |
Back-to-back failures in the same LLDB test that I've seen failing recently in regular CI testing: rdar://72774387 (Swift CI test failure: lldb-api :: lang/swift/optionset/TestSwiftOptionSetType.py; recursive_mutex lock failed) |
@swift-ci test |
@swift-ci smoke test |
@swift-ci smoke test OS X Platform |
@gottesmm these are the fixes that were required by CanonicalOSSA and reviewed here:
#35241
These are mostly the same fixes that I put up a couple weeks ago, but they are simpler, more complete, and I've incorporated review feedback. You may run into the same issues.