-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add a package serialization bit to Module for SIL verifier in Package CMO mode. #72937
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
@swift-ci smoke test |
lib/SIL/Verifier/SILVerifier.cpp
Outdated
// built); this means package serialization was enabled and direct | ||
// access should be allowed. | ||
auto serializedInResilientMode = | ||
expansion == ResilienceExpansion::Minimal && isSerialized; |
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.
The resilience expansion of a ‘serialized’ function is always minimal. (See getResilienceExpansion() in SILFunction.h)
by adding this condition (‘isSerialized()‘) we will by pass the check even in regular resilient mode (no package cmo enabled). I don’t think this is desirable.
Can you restrict this bypass to only when the current module is in the same package?
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.
Updated to check for that as well as whether module was built resiliently when serialized.
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.
Instead of:
auto serializedInResilientModule = M->isResilient() &&
isSerialized &&
D->getModuleContext()->inSamePackage(M);
I think we want to test the scenario where the Decl D is in a module that allows non resilient access from within the package boundary and we are accessing it from within the package boundary via a binary .swiftmodule (build from source). There is two cases:
- within the same module (M == D, module was compiled from source and allows resilient access)
- the function was deserialized and is now in a different module (M != D, D allows non-resilience access, M and D are in the same package and M has bypass resilience and enabled)
I think that would make the check something like:
auto accessingModule = M;
bool byPassResilienceCheck =
(D->getModuleContext()->allowNonResilientAccess() && D == M) || // Same module case
(F.getASTContext().LangOpts.EnableBypassResilienceInPackage && // Different modules case
D->getModuleContext()->inSamePackage(M) &&
D->getModuleContext()->allowNonResilientAccess());
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.
Had to add SerializePackageEnabled bit to Module; the SILOpts.EnableSerializePackage info gets lost during SIL cloning stage of Package CMO, so it needed to be serialized to the binary module. It's added to this SILVerifier check function along with others we discussed.
b51b1fa
to
03ab389
Compare
@swift-ci smoke test |
SILOptions::EnableSerializePackage info is lost. SILVerifier needs this info to determine whether resilience can be bypassed for decls serialized in a resiliently built module when Package CMO optimization enabled. This PR adds SerializePackageEnabled bit to Module format and uses that in SILVerifier. Resolves rdar://126157356
03ab389
to
fbb3382
Compare
@swift-ci smoke test |
@swift-ci smoke 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.
LGTM. Thank you
During Package CMO, SIL cloning happens during which
SILOptions::EnableSerializePackage info is lost.
SILVerifier needs this info to determine whether resilience
can be bypassed for decls serialized in a resiliently
built module when Package CMO optimization enabled.
This PR adds SerializePackageEnabled bit to Module format
and uses that in SILVerifier.
Resolves rdar://126157356