Skip to content

OpaqueArchetypeSpecializer: inlinable functions are now in this module #27856

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

Conversation

jrose-apple
Copy link
Contributor

...not the one they came from. This is important when specializing an inlinable function that takes an opaque type as a generic argument: that opaque type should still be considered opaque even if it came from the same module as the inlinable function.

rdar://problem/56410009. Fixes a regression introduced in #27666.

...not the one they came from. This is important when specializing an
inlinable function that takes an opaque type as a generic argument:
that opaque type should still be considered opaque even if it came
from the same module as the inlinable function.

rdar://problem/56410009
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test source compatibility

@jrose-apple
Copy link
Contributor Author

jrose-apple commented Oct 24, 2019

This fixes the issue but I need you reviewers to tell me whether it is the right fix. (Otherwise, please take the bug from me; I've done all I can do!)

dc = inFunction->getModule().getSwiftModule();
auto *currentModule = inFunction->getModule().getSwiftModule();
if (!dc || !dc->isChildContextOf(currentModule))
dc = currentModule;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it not be correct to always use currentModule here? I think the SILFunction's dc is only meant for debugging.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it would be correct. The intention of using the current functions current decl context is to be able to optimize the case when you have private declarations in the same sourc file.

Along the way of this micro optimization I introduced the bug that Jordan is fixing here :( .

Copy link
Contributor

@aschwaighofer aschwaighofer left a comment

Choose a reason for hiding this comment

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

Thanks. Yes if we inline a function the current context from which we gather accessibility is no longer the decl context of the inlined function. 🤦‍♂

@jrose-apple
Copy link
Contributor Author

Are we likely to have further issues where we use the DC of a SIL function? Should we consider not serializing that information?

…no, wait, I guess we use it to identify things that came from Clang…

@jrose-apple
Copy link
Contributor Author

The source compat failure is a single project failing to clone rather than something this commit changed, so I'm going to merge anyway.

@jrose-apple jrose-apple merged commit 3c225d3 into swiftlang:master Oct 24, 2019
@jrose-apple jrose-apple deleted the where-do-you-come-from-cottoneye-joe branch October 24, 2019 18:05
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