-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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
IRGen: Don't hoist metadata for weakly linked types #21223
Conversation
rdar://46438608
@swift-ci Please test |
There was a problem hiding this 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
lib/IRGen/AllocStackHoisting.cpp
Outdated
@@ -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(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@swift-ci Please test |
Build failed |
Build failed |
rdar://46438608