Skip to content

[ownership] Add a subclass for all OwnershipForwarding instructions and fix the classof to the various ownership abstract classes so isa/dyn_cast work. #34809

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

Conversation

gottesmm
Copy link
Contributor

I think what was happening here was that we were using one of the superclass
classofs and were getting lucky since in the place I was using this I was
guaranteed to have single value instructions and that is what I wrote as my
first case X ).

I also added more robust checks tieing the older isGuaranteed...* APIs to the
ForwardingOperand API. I also eliminated the notion of Branch being an owned
forwarding instruction. We only used this in one place in the compiler (when
finding owned value introducers), yet we treat a phi as an introducer, so we
would never hit a branch in our search since we would stop at the phi argument.
The bigger picture here is that this means that all "forwarding instructions"
either forward ownership for everything or for everything but owned/unowned.

And for those listening in, I did find one instruction that was from an
ownership forwarding subclass but was not marked as forwarding:
DifferentiableFunctionInst. With this change, we can no longer by mistake have
such errors enter the code base.

@gottesmm gottesmm requested a review from atrick November 18, 2020 20:04
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@gottesmm gottesmm requested a review from meg-gupta November 18, 2020 20:05
@gottesmm
Copy link
Contributor Author

Looks like I broke something when testing locally in SemanticARCOpts... Another land mine.

@gottesmm
Copy link
Contributor Author

Figured it out. The problem was that we were relying on SILArgument being recognized as an owned forwarding value (that is the result of an instruction that forwards owned ownership) due to us erroneously calling br an owned forwarding inst. (Generally we want owned forwarding constructs to suggest a dominating relationship rather than the br which can introduce value phis). We were taking advantage of that check as well for transforming terminators, so we stopped eliminating copies that feed into checked_cast_br/switch_enum diamonds.

…nd fix the classof to the various ownership abstract classes so isa/dyn_cast work.

I think what was happening here was that we were using one of the superclass
classofs and were getting lucky since in the place I was using this I was
guaranteed to have single value instructions and that is what I wrote as my
first case X ).

I also added more robust checks tieing the older isGuaranteed...* APIs to the
ForwardingOperand API. I also eliminated the notion of Branch being an owned
forwarding instruction. We only used this in one place in the compiler (when
finding owned value introducers), yet we treat a phi as an introducer, so we
would never hit a branch in our search since we would stop at the phi argument.
The bigger picture here is that this means that all "forwarding instructions"
either forward ownership for everything or for everything but owned/unowned.

And for those listening in, I did find one instruction that was from an
ownership forwarding subclass but was not marked as forwarding:
DifferentiableFunctionInst. With this change, we can no longer by mistake have
such errors enter the code base.
@gottesmm gottesmm force-pushed the pr-584924e29ff9f53ce445cbfbe808237ac89ac4a9 branch from 42f540b to c35ff33 Compare November 18, 2020 20:35
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test linux platform

2 similar comments
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test linux platform

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test linux platform

@gottesmm
Copy link
Contributor Author

I think I came up with a.way to do this without having a classof assert in every constructor call.

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

Great. A branch does not strictly forward because its use is not within the same borrow scope. I think it's important to be clear and consistent with OSSA terminology and this helps.

@gottesmm gottesmm merged commit 638d5e7 into swiftlang:main Nov 19, 2020
@gottesmm gottesmm deleted the pr-584924e29ff9f53ce445cbfbe808237ac89ac4a9 branch November 19, 2020 06:33
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