-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Frontend] Track SwiftOnoneSupport as a system dependency #18344
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
lib/Frontend/Frontend.cpp
Outdated
RequestedAction == FrontendOptions::ActionType::EmitSIL; | ||
RequestedAction == FrontendOptions::ActionType::EmitSIL || | ||
(TrackSystemDeps | ||
&& RequestedAction == FrontendOptions::ActionType::ResolveImports); |
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.
Is this even the right condition? Should we always force this load when TrackSystemDeps
is true?
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.
Another option would be to manually insert this dependency into the tracker if TrackSystemDeps
is true but this condition in its original form returns false.
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 problem for me is that the comment on the TrackSystemDeps option doesn't explain enough about the "why". Not your fault, is preexisting. But I cannot tell if this condition is correct from the comments.
This definitely doesn't seem correct. If you only compile optimized builds, you don't depend on SwiftOnoneSupport. Are implicit imports just not being recorded at all? |
This conditional occurs after the check for Onone builds. We’re currently specifically not loading SwiftOnoneSupport unless it returns true. The rest of the implicit dependencies are loaded and, therefore, tracked. |
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.
Looks reasonable, but I have no idea if it's right or not.
lib/Frontend/Frontend.cpp
Outdated
RequestedAction == FrontendOptions::ActionType::EmitSIL; | ||
RequestedAction == FrontendOptions::ActionType::EmitSIL || | ||
(TrackSystemDeps | ||
&& RequestedAction == FrontendOptions::ActionType::ResolveImports); |
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 problem for me is that the comment on the TrackSystemDeps option doesn't explain enough about the "why". Not your fault, is preexisting. But I cannot tell if this condition is correct from the comments.
Ah, I get it now. This is a minor optimization to speed up compile time if we're not going to get to SIL optimization. I think you should just make the condition be |
ba1a044
to
ef17087
Compare
I've updated the patch to always load SwiftOnoneSupport in the presence of -track-system-dependencies. |
lib/Frontend/Frontend.cpp
Outdated
@@ -421,7 +427,8 @@ shouldImplicityImportSwiftOnoneSupportModule(CompilerInvocation &Invocation) { | |||
return false; | |||
|
|||
if (shouldImportSwiftOnoneModuleIfNoneOrImplicitOptimization( | |||
Invocation.getFrontendOptions().RequestedAction)) { | |||
Invocation.getFrontendOptions().RequestedAction, | |||
Invocation.getFrontendOptions().TrackSystemDeps)) { | |||
return true; | |||
} | |||
return Invocation.getFrontendOptions().isCreatingSIL(); |
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 bit here's still going to trip you up, yeah? Actually, isn't this basically the same as what shouldImportSwiftOnoneModuleIfNoneOrImplicitOptimization
is doing?
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.
Oh, right. Meant to collapse these!
ef17087
to
d1c59f3
Compare
lib/Frontend/Frontend.cpp
Outdated
// This optimization is disabled by -track-system-dependencies to preserve | ||
// the explicit dependency. | ||
return Invocation.getFrontendOptions().TrackSystemDeps | ||
|| Invocation.getFrontendOptions().isCreatingSIL(); |
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.
Strictly speaking you've turned on imports for SILGen too. Then again, the old logic would have missed EmitSIB and all the various IR-based options, so this is probably more future-proof. Still, it might slow down the tests; it may be worth special-casing SILGen to not do the import.
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.
Hm, this is the only use of this accessor. I'll make it stricter.
ff14484
to
8c1634c
Compare
@swift-ci please 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.
Looks good, only small comments.
@@ -310,6 +308,7 @@ class FrontendOptions { | |||
static bool canActionEmitInterface(ActionType); | |||
|
|||
public: | |||
static bool doesActionNeedSILOptimizer(ActionType); |
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.
Bikeshedding: I don't like this name because it's not the optimizer itself that's interesting. doesActionRunSILPasses
, maybe?
case ActionType::EmitSIL: | ||
case ActionType::EmitModuleOnly: | ||
case ActionType::MergeModules: | ||
case ActionType::EmitSIBGen: |
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.
If we're going to change behavior anyway, we may as well pull EmitSIBGen out of this list.
8c1634c
to
cdbb225
Compare
SwiftOnoneSupport is an implicit dependency of no-opt builds that is usually only loaded when frontend actions that emit optimization-sensitive outputs are run. Force the implicit dependency to be explicit when -track-system-dependencies is used in concert with frontend actions that requires SIL passes be run.
cdbb225
to
0a3731d
Compare
@swift-ci please smoke test |
⛵️ |
Continuing work from swiftlang#18344, be more conservative about when we load SwiftOnoneSupport. Specifically, -emit-silgen and -emit-sibgen, despite not going through the SIL Optimizer, may silently introduce dependencies on SwiftOnoneSupport. Because we want to support the ability to posthumously compile SILGen and SIBGen'd files with these implicit dependencies, and because SIL is not yet capable of expressing the dependency itself, we must always assume we need to load SwiftOnoneSupport.
SwiftOnoneSupport is an implicit dependency of no-opt builds that is usually only loaded when frontend actions that emit optimization-sensitive outputs are run.
Force the implicit dependency to be explicit when -track-system-dependencies is used.