Skip to content

Fixes for exotic materializeForSet #15140

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 3 commits into from
Mar 10, 2018

Conversation

slavapestov
Copy link
Contributor

We had a SIL verifier workaround for non-mutating setters, and used to crash if we had both a mutating getter and non-mutating setter.

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

// CHECK-NEXT: [[TEMP2:%.*]] = alloc_stack $A
// SEMANTIC SIL TODO: This is an issue caused by the callback for materializeForSet in the class case taking the value as @inout when it should really take it as @guaranteed.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gottesmm This comment doesn't make sense so I removed it. We cannot use @guaranteed convention for the 'self' parameter of the callback, because the callback for a property of a class type has to be ABI compatible with the callback for a protocol requirement witnessed by the class property. So it always has to be indirect.

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant to say @in_guaranteed here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you put back in the comment with that update.

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 callback takes it as @in_guaranteed now. However the subsequent alloc_stack / store_borrow remains, because we originally had a loaded value.

Copy link
Contributor

Choose a reason for hiding this comment

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

I talked with Slava offline. He said that he fixed the underlying issue (this being inout instead of in_guaranteed). So it makes sense for the comment to go. Thanks Slava!

…-mutating setter

I admit this is an odd corner case that is unlikely to ever
come up in practice.

Fixes <rdar://problem/32860203>.
…eForSet callback of non-mutating setter

We cannot in general use @guaranteed here, otherwise classes will not
be able to conform to protocols with mutable property requirements
(or we could always open-code materializeForSet witness thunks for
classes, but that has its own downsides so its not a clear win).

Fixes <rdar://problem/36867783>.
@slavapestov slavapestov force-pushed the materialize-for-set-fixes branch from eb5a95b to f7dd583 Compare March 10, 2018 11:39
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

Copy link
Contributor

@aschwaighofer aschwaighofer left a comment

Choose a reason for hiding this comment

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

Yay. Thank you!

@@ -964,7 +964,7 @@ MaterializeForSetEmitter::createSetterCallback(SILFunction &F,
}

// The callback gets the address of 'self' at +0.
ManagedValue mSelf = ManagedValue::forLValue(self);
ManagedValue mSelf = ManagedValue::forUnmanaged(self);
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if there is a more explicit API we could use depending on whether self is @inout or @in_guaranteed: forLValue and forBorrowedAddressRValue maybe (though we can have trivial r-values).
Not that this should block this commit.

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test Linux

@slavapestov slavapestov merged commit 760a9a7 into swiftlang:master Mar 10, 2018
@jrose-apple
Copy link
Contributor

Will this fix https://bugs.swift.org/browse/SR-7176 as well or is that something else?

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.

4 participants