Skip to content

IRGen: Make resilient enum's tag indices resilient #15208

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

aschwaighofer
Copy link
Contributor

This allows reordering enum cases resiliently.

rdar://24057946

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@jrose-apple
Copy link
Contributor

Please add a test to validation-test/Evolution that shows this working at run time! :-)

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 2e4ad96

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 2e4ad96

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - b01dca1

@aschwaighofer aschwaighofer force-pushed the resilient_enum_case_tags branch from dc43d78 to 9d8c381 Compare March 20, 2018 20:20
@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 6af7fcc

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 6af7fcc

@aschwaighofer
Copy link
Contributor Author

Hmm, after the rebase everything fails ... must have introduced new code since ...

@@ -6107,6 +6105,15 @@ void IRGenModule::emitEnumDecl(EnumDecl *theEnum) {
}

emitFieldMetadataRecord(theEnum);

if (isResilient(theEnum, ResilienceExpansion::Maximal))
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't you want to return if its not resilient?

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 code below emits the global variables for resilient enum tags. I only want to proceed to this code if we are within the same resilience domain not outside.

Copy link
Contributor

Choose a reason for hiding this comment

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

When are we ever resilient here? Isn’t this the code for emitting an enum definition_? How can you define an enum that’s resilient to yourself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Rethinking that logic should we test if the enum is resilient and only then emit the globals (like you initially suggested)? Assuming, the transition from non-resilient to resilient is not allowed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like so: #15401

@slavapestov
Copy link
Contributor

Can you file a bug to have me or Huon update TBDGen as well? Or you can do it, it's trivial. You just have to emit the link entities when visiting an EnumDecl, and add a test case.

@aschwaighofer
Copy link
Contributor Author

I can take a look

@aschwaighofer
Copy link
Contributor Author

Please test

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 9d8c381

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 9d8c381

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test source compatibility

@aschwaighofer
Copy link
Contributor Author

Successful source compatibility run is here: https://ci.swift.org/view/Pull%20Request/job/swift-PR-source-compat-suite/914/console

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