Skip to content

IRGen: Don't hoist metadata for weakly linked types #21223

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

rdar://46438608

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

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

Thanks for looking at this - I have a few minor suggestions

@@ -57,6 +57,11 @@ static bool isHoistable(AllocStackInst *Inst, irgen::IRGenModule &Mod) {
if (TI.isFixedSize())
return false;

// Don't hoist weakly imported (weakly linked) types.
auto *nominalDecl = SILTy.getASTType()->getNominalOrBoundGenericNominal();
Copy link
Contributor

Choose a reason for hiding this comment

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

What if you have a structural type, eg a function or tuple, containing a weak nominal? I think you need to do a findIf() to walk the type recursively instead

Copy link
Contributor

Choose a reason for hiding this comment

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

(Functions are fixed size, so a tuple or optional is a better example)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks.

@@ -0,0 +1,20 @@
// RUN: %empty-directory(%t)
Copy link
Contributor

Choose a reason for hiding this comment

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

We already have test/IRGen/weak_import_native.swift, can you add your test case there instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -9,25 +9,19 @@ var BackwardDeployStructTest = TestSuite("BackwardDeployStruct")

BackwardDeployStructTest.test("ResilientStruct") {
if getVersion() == 1 {
// FIXME: IRGen inserts the metadata load outside the version check
Copy link
Contributor

Choose a reason for hiding this comment

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

There was a second spot where I had this workaround in this directory, can you grep for it (sorry on my phone right now)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 2f34bdc

@swift-ci
Copy link
Contributor

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

@aschwaighofer aschwaighofer merged commit fe1b75f into swiftlang:master Dec 12, 2018
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