Skip to content

[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

Merged
merged 2 commits into from
Aug 30, 2021

Conversation

eeckstein
Copy link
Contributor

@eeckstein eeckstein commented Aug 24, 2021

…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
@eeckstein eeckstein requested a review from a team as a code owner August 24, 2021 10:06
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein requested a review from gottesmm August 24, 2021 17:26
@eeckstein eeckstein added the r5.5 label Aug 25, 2021
// 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)
Copy link
Contributor

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.

Copy link
Contributor Author

@eeckstein eeckstein Aug 27, 2021

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.

Copy link
Contributor

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))
Copy link
Contributor

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.

Copy link
Contributor Author

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

@eeckstein eeckstein requested a review from xymus August 27, 2021 13:09
Copy link
Contributor

@xymus xymus left a comment

Choose a reason for hiding this comment

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

This looks good!

@eeckstein eeckstein merged commit 01865c0 into swiftlang:release/5.5 Aug 30, 2021
@eeckstein eeckstein deleted the fix-cmo-5.5 branch August 30, 2021 16:05
@AnthonyLatsis AnthonyLatsis added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.5 labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants