Skip to content

[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

Merged
merged 1 commit into from
Jul 31, 2018

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Jul 29, 2018

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.

@CodaFi CodaFi requested review from davidungar and jrose-apple July 29, 2018 23:10
RequestedAction == FrontendOptions::ActionType::EmitSIL;
RequestedAction == FrontendOptions::ActionType::EmitSIL ||
(TrackSystemDeps
&& RequestedAction == FrontendOptions::ActionType::ResolveImports);
Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@jrose-apple
Copy link
Contributor

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?

@CodaFi
Copy link
Contributor Author

CodaFi commented Jul 30, 2018

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.

Copy link
Contributor

@davidungar davidungar left a 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.

RequestedAction == FrontendOptions::ActionType::EmitSIL;
RequestedAction == FrontendOptions::ActionType::EmitSIL ||
(TrackSystemDeps
&& RequestedAction == FrontendOptions::ActionType::ResolveImports);
Copy link
Contributor

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.

@jrose-apple
Copy link
Contributor

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 TrackSystemDeps, then, and not check the action type; as written it'll load it for -resolve-imports but not -typecheck, which doesn't really make sense. And David's right that this needs explaining.

@CodaFi CodaFi force-pushed the unseen-university branch 2 times, most recently from ba1a044 to ef17087 Compare July 30, 2018 17:41
@CodaFi
Copy link
Contributor Author

CodaFi commented Jul 30, 2018

I've updated the patch to always load SwiftOnoneSupport in the presence of -track-system-dependencies.

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

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?

Copy link
Contributor Author

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!

@CodaFi CodaFi force-pushed the unseen-university branch from ef17087 to d1c59f3 Compare July 30, 2018 18:08
// This optimization is disabled by -track-system-dependencies to preserve
// the explicit dependency.
return Invocation.getFrontendOptions().TrackSystemDeps
|| Invocation.getFrontendOptions().isCreatingSIL();
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@CodaFi CodaFi force-pushed the unseen-university branch 3 times, most recently from ff14484 to 8c1634c Compare July 30, 2018 20:53
@CodaFi
Copy link
Contributor Author

CodaFi commented Jul 30, 2018

@swift-ci please smoke test

Copy link
Contributor

@jrose-apple jrose-apple left a 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);
Copy link
Contributor

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

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.

@CodaFi CodaFi force-pushed the unseen-university branch from 8c1634c to cdbb225 Compare July 30, 2018 21:54
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.
@CodaFi CodaFi force-pushed the unseen-university branch from cdbb225 to 0a3731d Compare July 30, 2018 23:40
@CodaFi
Copy link
Contributor Author

CodaFi commented Jul 30, 2018

@swift-ci please smoke test

@CodaFi
Copy link
Contributor Author

CodaFi commented Jul 31, 2018

⛵️

@CodaFi CodaFi merged commit f74d61f into swiftlang:master Jul 31, 2018
@CodaFi CodaFi deleted the unseen-university branch July 31, 2018 01:16
CodaFi added a commit to CodaFi/swift that referenced this pull request Aug 1, 2018
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.
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