Skip to content

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

Merged
merged 12 commits into from
Jan 4, 2021

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Jan 2, 2021

@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.

@atrick atrick force-pushed the fix-operandownership branch from 02c9792 to df24d83 Compare January 2, 2021 02:31
atrick added 10 commits January 1, 2021 19:22
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.
@atrick atrick requested a review from gottesmm January 2, 2021 03:22
@atrick atrick force-pushed the fix-operandownership branch from df24d83 to 07fccd9 Compare January 2, 2021 03:23
@atrick
Copy link
Contributor Author

atrick commented Jan 2, 2021

@swift-ci test

@atrick
Copy link
Contributor Author

atrick commented Jan 2, 2021

@swift-ci benchmark

@atrick
Copy link
Contributor Author

atrick commented Jan 2, 2021

@swift-ci test source compatibility

@swift-ci
Copy link
Contributor

swift-ci commented Jan 2, 2021

Performance: -O

Regression OLD NEW DELTA RATIO
FlattenListFlatMap 3997 5542 +38.7% 0.72x (?)
Data.append.Sequence.809B.Count.RE.I 105 116 +10.5% 0.91x (?)
String.data.LargeUnicode 119 128 +7.6% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
UTF8Decode_InitFromBytes_ascii_as_ascii 500 456 -8.8% 1.10x (?)

Code size: -O

Performance: -Osize

Code size: -Osize

Performance: -Onone

Improvement OLD NEW DELTA RATIO
SevenBoom 2137 1803 -15.6% 1.19x (?)

Code size: -swiftlibs

How to read the data The 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
regressions before you merge the PR.

Noise: Sometimes the performance results (not code size!) contain false
alarms. Unexpected regressions which are marked with '(?)' are probably noise.
If you see regressions which you cannot explain you can try to run the
benchmarks again. If regressions still show up, please consult with the
performance team (@eeckstein).

Hardware Overview
  Model Name: Mac Pro
  Model Identifier: MacPro6,1
  Processor Name: 12-Core Intel Xeon E5
  Processor Speed: 2.7 GHz
  Number of Processors: 1
  Total Number of Cores: 12
  L2 Cache (per Core): 256 KB
  L3 Cache: 30 MB
  Memory: 64 GB

@swift-ci
Copy link
Contributor

swift-ci commented Jan 2, 2021

Build failed
Swift Test OS X Platform
Git Sha - 07fccd9478c7172b49d167f8ad993c6c7a4a3ded

@atrick
Copy link
Contributor Author

atrick commented Jan 3, 2021

All tests, SCK, benchmarks pass. Rebasing to fix a CHECK line in IRGen/async/builtins.

@atrick atrick force-pushed the fix-operandownership branch from 07fccd9 to 24fa288 Compare January 3, 2021 03:30
@atrick
Copy link
Contributor Author

atrick commented Jan 3, 2021

@swift-ci test

@swift-ci
Copy link
Contributor

swift-ci commented Jan 3, 2021

Build failed
Swift Test Linux Platform
Git Sha - 24fa288

@swift-ci
Copy link
Contributor

swift-ci commented Jan 3, 2021

Build failed
Swift Test OS X Platform
Git Sha - 24fa288

@atrick
Copy link
Contributor Author

atrick commented Jan 3, 2021

@swift-ci test

@swift-ci
Copy link
Contributor

swift-ci commented Jan 3, 2021

Build failed
Swift Test OS X Platform
Git Sha - 24fa288

@atrick
Copy link
Contributor Author

atrick commented Jan 3, 2021

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)

@atrick
Copy link
Contributor Author

atrick commented Jan 4, 2021

@swift-ci test

@atrick
Copy link
Contributor Author

atrick commented Jan 4, 2021

@swift-ci smoke test

@atrick
Copy link
Contributor Author

atrick commented Jan 4, 2021

@swift-ci smoke test OS X Platform

@atrick atrick merged commit 3a1c8fd into swiftlang:main Jan 4, 2021
@atrick atrick deleted the fix-operandownership branch October 19, 2022 00:28
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.

2 participants