-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Always link SIL for partial modules in SILGen #32461
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
@hamishknight Thanks! In case you're wondering, I added the flag in case the SIL linking in merge-modules exposed problems. For a long time we didn't link SIL at all in this stage, so we would drop it all on the floor. Removing the flag makes sense since nowadays you will get incorrect semantics with this turned off anyway -- @_alwaysEmitIntoClient functions as well as default arguments must have their SIL preserved since they don't have public entry points. |
@slavapestov Thanks for the background! I was also wondering about whether we could remove the It seems like its use in DeserializeSIL could be replaced with a more general check for whether the function is being deserialized into the same module. Though I'm not sure about its use in SILVerifier, do you recall what case this is handling? No tests seem to fail if it's removed. |
The idea with that option is that when we're merging partial modules, we don't want to deserialize bodies of functions in other modules. While it shouldn't affect correctness, it might impact performance. Perhaps we should add a counter-based test to ensure that we don't do this. I think the use in DeserializeSIL has to stay. We don't know if the function is being deserialized into the same module or not. Normally when I deserialize a function, the linkage changes, for example a public function deserializes as public_external, and public_non_abi deserializes as shared. The distinction is that we wish to make the SIL available for optimization purposes, but we don't actually want IRGen to re-emit these deserialized functions. IRGen knows to skip a public_external function, even if it has a body. The latter should be covered by tests; again, if it isn't, we should add new tests. |
@slavapestov Wouldn't
Right, but for merge modules as far as I can tell we should always preserve the linkage of what we deserialize. So if I understand things correctly, anything that merge modules would trip the SILVerifier for outside of "single function" mode would also be something that an individual partial module could trip it for. Therefore I'm tempted to think we don't need to run the SILVerifier in "single function" mode for merge modules. What do you think?
Sure, I'd be happy to look into adding a test for that :) |
2a5cf98
to
bd8843e
Compare
Let's see if anything breaks @swift-ci please test |
Ah okay, I realise now what you were referring to with regard to merge-modules is the fact that we skip the mandatory linking pass, so we could encounter a |
bd8843e
to
8443435
Compare
8443435
to
e01441c
Compare
Previously we would only link `.sib` partial modules in SILGen, with other kinds of serialized ASTs being linked just before the SILOptimizer if `-sil-merge-partial-modules` was specified. However linking them always seems to be the desired behaviour, so adjust SILGen to link SIL for all serialized AST inputs.
Previously we were linking in all SIL entities if the input was a serialized non-SIB AST, and `-disable-sil-linking` wasn't specified. However none of the tests appear to want this behaviour. Stop calling `SerializedSILLoader::getAll`, and remove the `-disable-sil-linking` option, as this is now the default behaviour.
Its use in deserialization can be replaced with a more general check for whether we're deserializing into the same module. Its use in the SILVerifier is subsumed by the check for whether the SILModule is canonical, which it isn't during merge-modules.
The option now has no additional meaning. Eventually it should be removed, but for now just alias it to `-merge-modules`.
Replace with -merge-modules, which means we can also remove the now redundant `-disable-diagnostic-passes` & `-disable-sil-perf-optzns` options.
e01441c
to
751e681
Compare
Ping @slavapestov @gottesmm |
@swift-ci please test |
Previously we would only link
.sib
partial modules in SILGen, with other kinds of serialized ASTs being linked just before the SILOptimizer if-sil-merge-partial-modules
was specified. However linking always seems to be the desired behaviour, so adjust SILGen to always link SIL for all serialized AST inputs.This allows us to remove some duplicated linking code from the SIL tools and will let us remove the
-sil-merge-partial-modules
frontend flag in favour of-merge-modules
.