mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Cross module optimization
This is a first version of cross module optimization (CMO). The basic idea for CMO is to use the existing library evolution compiler features, but in an automated way. A new SIL module pass "annotates" functions and types with @inlinable and @usableFromInline. This results in functions being serialized into the swiftmodule file and thus available for optimizations in client modules. The annotation is done with a worklist-algorithm, starting from public functions and continuing with entities which are used from already selected functions. A heuristic performs a preselection on which functions to consider - currently just generic functions are selected. The serializer then writes annotated functions (including function bodies) into the swiftmodule file of the compiled module. Client modules are able to de-serialize such functions from their imported modules and use them for optimiations, like generic specialization. The optimization is gated by a new compiler option -cross-module-optimization (also available in the swift driver). By default this option is off. Without turning the option on, this change is (almost) a NFC. rdar://problem/22591518
This commit is contained in:
@@ -62,6 +62,9 @@ public:
|
||||
/// Useful when you want to enable -O LLVM opts but not -O SIL opts.
|
||||
bool DisableSILPerfOptimizations = false;
|
||||
|
||||
/// Controls whether cross module optimization is enabled.
|
||||
bool CrossModuleOptimization = false;
|
||||
|
||||
/// Controls whether or not paranoid verification checks are run.
|
||||
bool VerifyAll = false;
|
||||
|
||||
|
||||
@@ -589,6 +589,10 @@ def Oplayground : Flag<["-"], "Oplayground">, Group<O_Group>,
|
||||
Flags<[HelpHidden, FrontendOption, ModuleInterfaceOption]>,
|
||||
HelpText<"Compile with optimizations appropriate for a playground">;
|
||||
|
||||
def CrossModuleOptimization : Flag<["-"], "cross-module-optimization">,
|
||||
Flags<[HelpHidden, FrontendOption]>,
|
||||
HelpText<"Perform cross-module optimization">;
|
||||
|
||||
def RemoveRuntimeAsserts : Flag<["-"], "remove-runtime-asserts">,
|
||||
Flags<[FrontendOption]>,
|
||||
HelpText<"Remove runtime safety checks.">;
|
||||
|
||||
@@ -64,6 +64,8 @@ PASS(AccessEnforcementSelection, "access-enforcement-selection",
|
||||
"Access Enforcement Selection")
|
||||
PASS(AccessEnforcementWMO, "access-enforcement-wmo",
|
||||
"Access Enforcement Whole Module Optimization")
|
||||
PASS(CrossModuleSerializationSetup, "cross-module-serialization-setup",
|
||||
"Setup serialization flags for cross-module optimization")
|
||||
PASS(AccessSummaryDumper, "access-summary-dump",
|
||||
"Dump Address Parameter Access Summary")
|
||||
PASS(AccessedStorageDumper, "accessed-storage-dump",
|
||||
|
||||
Reference in New Issue
Block a user