-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[5.5] Fix two cross-module-optimization bugs #39018
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
…eclaration is created This makes sure that all analysis will get the `notifyAddedOrModifiedFunction` notifications. This fixes a crash in CallerAnalysis, which relies that it's notified for all newly created functions. This is related to following bug reports for cross-module-optimization: https://bugs.swift.org/browse/SR-15048 rdar://81701218 Although I believe that there are more bugs involved which need to be fixed. Unfortunately I don't have a test case for this fix.
…implementationOnly-imported functions The check for implementationOnly imports was already done for types, but it was missing for functions. Fixes a crash when implementationOnly-importing a C module. https://bugs.swift.org/browse/SR-15048 rdar://81701218
@swift-ci test |
// The function is not really de-serialized, but it's important to call | ||
// `didDeserialize` on every new function. Otherwise some Analysis might miss | ||
// `notifyAddedOrModifiedFunction` notifications. | ||
if (Callback) |
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.
Why is this not in the builder itself? A user should not have to worry about this sort of thing.
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.
That's how you implemented it 😊
It follows the other patterns in the deserializer.
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.
Ok. I'll take that. More than 2 weeks = p. That being said, we should consider adding it into the Builder (not in this commit though). I think in the SILOptFunctionBuilder I did this and maybe just didn't get around to doing this with this specific builder.
@@ -2196,7 +2197,7 @@ canBeUsedForCrossModuleOptimization(NominalTypeDecl *nominal) const { | |||
|
|||
auto &imports = getASTContext().getImportCache(); | |||
for (auto &desc : results) { | |||
if (imports.isImportedBy(moduleOfNominal, desc.importedModule)) | |||
if (imports.isImportedBy(moduleOfCtxt, desc.importedModule)) |
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.
This looks reasonable to me. But I would like someone who understands the import cache to also look at this. I just don't know how it works.
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.
I added @xymus who also reviewed the original code
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.
This looks good!
This is a cherry-pick of two fixes related to cross-module-optimization:
Deserializer: call the deserialization callback when a new function declaration is created #38926
cross-module-optimization: Don't serialize functions which reference implementationOnly-imported functions #38951
https://bugs.swift.org/browse/SR-15048
rdar://81701218