Skip to content

IRGen: Public non-resilient types that reference resilient types from the same module must view those types as non-fixed #25751

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

Conversation

aschwaighofer
Copy link
Contributor

Otherwise, we don't emit certain parts of the metadata that is expected
when these types are used outside the module (payload size).

rdar://51422528

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

// is not fixed-size in all resilience domains that have knowledge of
// this enum's layout, we need to constrain our layout optimizations to
// what the runtime can reproduce.
if (!isResilient && !argTI->isFixedSize(layoutScope))
Copy link
Contributor

Choose a reason for hiding this comment

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

I don’t understand why you’re adding the new lowering mode. It sounds like isFixedSize() returns true when it should return false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you lower a resilient type in its local module it ends up as a fixed size type.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right but isFixedSize(ResilienceExpansion::Minimal) is meant to return false if it was fixed size in other resilience domains. It sounds like it’s not being computed correctly in all cases (nested enums?) and we need to fix the root cause instead of papering over it here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I mean “if it was not fixed size in other resilience domains”.

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 enum that we query in the test case (``enum ResilientType```) is not nested. I have to debug again but what I remember from yesterday is that if I get the type info for a resilient enum inside it's own module it returns a fixed size enum which always has fixed size.

I will confirm again that this is what happens.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you try the same example with a resilient struct instead of a resilient enum, do we correctly emit the payload size (and skip layout optimizations) for the non-resilient enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I will look into that. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, only happens with the enum. I will track down where we miss setting the flag.

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome, thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Much simpler now.

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 93e0cefa7be7ea2ec1d53e0ac9e6ebead7115c59

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 93e0cefa7be7ea2ec1d53e0ac9e6ebead7115c59

@aschwaighofer aschwaighofer force-pushed the irgen_resilient_non_resilient_same_module branch from 93e0cef to 6f4c5c4 Compare June 25, 2019 18:58
@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 93e0cefa7be7ea2ec1d53e0ac9e6ebead7115c59

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 93e0cefa7be7ea2ec1d53e0ac9e6ebead7115c59

@@ -5794,7 +5794,9 @@ std::unique_ptr<EnumImplStrategy>
EnumImplStrategy::get(TypeConverter &TC, SILType type, EnumDecl *theEnum) {
unsigned numElements = 0;
TypeInfoKind tik = Loadable;
IsFixedSize_t alwaysFixedSize = IsFixedSize;
IsFixedSize_t alwaysFixedSize =
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer leaving the old line in place and adding a separate 'if' statement to set it to IsNotFixedSize, but that's up to you.

Thanks for figuring out the right fix! Looks like this has been broken ever since I added this code in 2015 🤦‍♂️

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

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

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 6f4c5c4

@slavapestov
Copy link
Contributor

New version looks great, thank you very much!

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 2b52670

@swift-ci
Copy link
Contributor

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

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 3bc3f66

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 3bc3f66

@aschwaighofer
Copy link
Contributor Author

Unrelated error:

/Users/buildnode/jenkins/workspace/swift-PR-osx/branch-master/swift/benchmark/single-source/ObjectiveCBridging.swift:753:43: error: use of unresolved identifier 'string'
07:49:35   let jsonString = "[\(String(reflecting: string))]"

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test OS X platform

@aschwaighofer aschwaighofer merged commit 7328503 into swiftlang:master Jun 26, 2019
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