Skip to content

Remove a stale UnenforcedAccess marker from SILGenPattern. #22452

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 1 commit into from
Feb 14, 2019
Merged

Remove a stale UnenforcedAccess marker from SILGenPattern. #22452

merged 1 commit into from
Feb 14, 2019

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Feb 7, 2019

Remove a stale UnenforcedAccess marker from SILGenPattern.

NFC unless -enable-verify-exclusivity is on.

Boxed (indirect) enum loads are not formal accesses so they should not
have access markers. For a while, we used UnenforcedAccess in this
case to signal to the verifier that this is actually a safe load. But
that isn't needed. The verifier just ignores loads from unidentified
storage instead.

There are two code paths that had this UnenforcedAccess marker. One
was cleaned up, and the other was not. So finish the cleanup and add a
unit test for both SILGen code paths.

@atrick
Copy link
Contributor Author

atrick commented Feb 7, 2019

@swift-ci test.

// The boxed value may be shared, so we need to load the value at +0
// to make sure that we copy if we try to use it outside of the switch
// statement itself.
boxedValue = SGF.B.createLoadBorrow(loc, boxedValue);
boxedValue = SGF.B.createLoadBorrow(loc, accessAddress);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need to check here like in the other place if the scope closes immediately (in which case you use a copy, no?)

@swift-ci
Copy link
Contributor

swift-ci commented Feb 7, 2019

Build failed
Swift Test OS X Platform
Git Sha - efad9dc9aeb7b069940972ba4e7954d2d5e01f61

@swift-ci
Copy link
Contributor

swift-ci commented Feb 7, 2019

Build failed
Swift Test Linux Platform
Git Sha - efad9dc9aeb7b069940972ba4e7954d2d5e01f61

@atrick atrick changed the title Add an UnenforcedAccess marker to SILGenPattern. Remove an stale UnenforcedAccess marker from SILGenPattern. Feb 14, 2019
NFC unless -enable-verify-exclusivity is on.

Boxed (indirect) enum loads are not formal accesses so they should not
have access markers. For a while, we used UnenforcedAccess in this
case to signal to the verifier that this is actually a safe load. But
that isn't needed. The verifier just ignores loads from unidentified
storage instead.

There are two code paths that had this UnenforcedAccess marker. One
was cleaned up, and the other was not. So finish the cleanup and add a
unit test for both SILGen code paths.
@atrick atrick changed the title Remove an stale UnenforcedAccess marker from SILGenPattern. Remove a stale UnenforcedAccess marker from SILGenPattern. Feb 14, 2019
@atrick
Copy link
Contributor Author

atrick commented Feb 14, 2019

@swift-ci please test

@atrick
Copy link
Contributor Author

atrick commented Feb 14, 2019

@gottesmm Revisiting this old PR. Should be a quick review, no hurry.

@@ -385,6 +385,31 @@ enum IntEnum {
// CHECK: load [trivial] [[PROJ]] : $*Int
// CHECK-LABEL: } // end sil function '$s20access_marker_verify7IntEnumO8getValueSivg'

// Also test SILGenPattern for address-only enums with indirect loadable payloads.
enum IntTEnum<T> {
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 also add a test case for:

indirect enum

That is missing in the code-coverage.

@@ -2151,37 +2146,20 @@ void PatternMatchEmission::emitEnumElementDispatch(

// If the payload is boxed, project it.
if (elt->isIndirect() || elt->getParentEnum()->isIndirect()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Notice how here we check for getParentEnum().isIndirect. That is the case to check.

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 that is the test case that I added.

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - f3f5848

@atrick
Copy link
Contributor Author

atrick commented Feb 14, 2019

@swift-ci test linux platform.

@atrick atrick merged commit c8428f0 into swiftlang:master Feb 14, 2019
@atrick atrick deleted the add-silgen-unenforced-access branch February 22, 2019 17:05
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