Skip to content

Pass -enable-cmo-everything to frontend jobs #1663

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 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sources/SwiftDriver/Jobs/CompileJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ extension Driver {
if Driver.canDoCrossModuleOptimization(parsedOptions: &parsedOptions) &&
// For historical reasons, -cross-module-optimization turns on "aggressive" CMO
// which is different from "default" CMO.
!parsedOptions.hasArgument(.CrossModuleOptimization) {
!parsedOptions.hasArgument(.CrossModuleOptimization) &&
!parsedOptions.hasArgument(.EnableCMOEverything) {
assert(!emitModuleSeparately, "Cannot emit module separately with cross-module-optimization")
commandLine.appendFlag("-enable-default-cmo")
}
Expand Down Expand Up @@ -370,6 +371,7 @@ extension Driver {

try commandLine.appendLast(.trackSystemDependencies, from: &parsedOptions)
try commandLine.appendLast(.CrossModuleOptimization, from: &parsedOptions)
try commandLine.appendLast(.EnableCMOEverything, from: &parsedOptions)
Copy link
Member

Choose a reason for hiding this comment

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

Do we have to handle if any combination of -cross-module-optimization, -enable-default-cmo and -enable-cmo-everything is passed that the more aggressive one wins or does swiftc already handle that?

Copy link
Contributor Author

@tshortli tshortli Jul 15, 2024

Choose a reason for hiding this comment

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

The frontend has logic for choosing the single level of optimization based on the presence of conflicting flags. It works a bit differently than I would expect; I think a more standard way to handle that would be to use whichever of the three flags comes last on the command line, but there is at least a strategy for resolving conflicts.

try commandLine.appendLast(.ExperimentalPerformanceAnnotations, from: &parsedOptions)

try commandLine.appendLast(.runtimeCompatibilityVersion, from: &parsedOptions)
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ extension Driver {
try commandLine.appendLast(.fixitAll, from: &parsedOptions)
try commandLine.appendLast(.warnSwift3ObjcInferenceMinimal, .warnSwift3ObjcInferenceComplete, from: &parsedOptions)
try commandLine.appendLast(.warnImplicitOverrides, from: &parsedOptions)
try commandLine.appendLast(.warnSoftDeprecated, from: &parsedOptions)
try commandLine.appendLast(.typoCorrectionLimit, from: &parsedOptions)
try commandLine.appendLast(.enableAppExtension, from: &parsedOptions)
try commandLine.appendLast(.enableLibraryEvolution, from: &parsedOptions)
Expand Down
Loading