Commit Graph

6 Commits

Author SHA1 Message Date
Erik Eckstein
71df54cc80 CrossModuleSerializationSetup: don't make shared functions usableFromInline
To avoid duplicate-symbol linker errors. Instead make them alwaysEmitIntoClient.
But only do that for thunks to limit the code size impact. Anyway, it's only important for thunks because thunks are generated at SILGen, i.e. before CrossModuleSerializationSetup.
Other shared functions, e.g. specializations are created after CrossModuleSerializationSetup, so we don't have to deal with them.
2019-12-11 18:14:41 +01:00
Erik Eckstein
9b16a3567b Cross-module-optimization: make sure that witness tables, which are used by serialized functions, get public linkage
Fixes an undefined-symbol error.
2019-12-06 09:37:03 +01:00
Erik Eckstein
a7910d7ed4 Cross-module-optimization: fix a use-after-free ASAN crash
rdar://problem/57642102
2019-12-05 14:10:54 +01:00
Erik Eckstein
1b20134d4f Cross-module-optimization: Mark stored class properties as usableFromInline if they are used in a ref_element_addr instruction.
Fixes a wrong linkage for direct field offset variables.
2019-12-04 17:02:56 +01:00
Erik Eckstein
356a388d05 Cross-module-optimization: no need to add AST-attributes to make functions always-emit-into-client.
This is less hacky and possible now, as we de-serialize the linkage from SIL (and not just derive it from the AST attributes).
2019-12-04 09:16:28 +01:00
Erik Eckstein
a5397b434c 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
2019-12-03 14:37:01 +01:00