Commit Graph

60 Commits

Author SHA1 Message Date
Arnold Schwaighofer
69471700b0 CrossModuleOptimization: Don't serialize pre-specialized public entry points
We should continue to use the public pre-specialized entry point from another module. But not block other uses of generic specializations.
2022-05-05 08:01:09 -07:00
Erik Eckstein
abb2da88e6 Add a flag -enable-default-cmo to enable default cross-module-optimization.
So far, the swift-frontend decided by itself if CMO can be enabled. This caused problems when used with an old driver, which doesn't consider CMO.
Now, the driver decides when to use default CMO by passing this flag to swift-frontend.
2022-04-29 18:22:55 +02:00
Erik Eckstein
45acb912a9 Revert "Add a mechanism to let cross-module-optimization add additional TBD symbols."
This reverts commit c55f040308.

It's not needed anymore because CMO does not introduce public symbols when a TBD file is emitted.
2022-04-29 18:22:55 +02:00
Erik Eckstein
6a020f8f15 Stabilize and simplify SIL linkage and serialization
The main point of this change is to make sure that a shared function always has a body: both, in the optimizer pipeline and in the swiftmodule file.
This is important because the compiler always needs to emit code for a shared function. Shared functions cannot be referenced from outside the module.
In several corner cases we missed to maintain this invariant which resulted in unresolved-symbol linker errors.

As side-effect of this change we can drop the shared_external SIL linkage and the IsSerializable flag, which simplifies the serialization and linkage concept.
2022-03-09 15:28:05 +01:00
Erik Eckstein
1dfb3b1a2a cross-module-optimization: be more conservative when emitting a TBD file.
If we are emitting a TBD file, the TBD file only contains public symbols of this module.
But not public symbols of imported modules which are statically linked to the current binary.
This prevents referencing public symbols from other modules which could (potentially) linked statically.
Unfortunately there is no way to find out if another module is linked statically or dynamically, so we have to be conservative.

Fixes an unresolved-symbol linker error.
rdar://89364148
2022-03-03 11:42:07 +01:00
Erik Eckstein
80a22e332f cross-module-optimization: be more conservative with references to non-public functions
We need to make serializing shared functions more robust. Until then, be more conservative with non-public functions.
2022-02-11 15:53:47 +01:00
Erik Eckstein
8c52853b9e cross-module-optimization: fix a problem with global variables
don't make public external globals non-external
2022-02-11 15:53:47 +01:00
Erik Eckstein
5bc1633883 cross-module-optimization: don't make imported type declarations usable-from-inline.
Fixes unresolved-symbol linker errors.

rdar://87930768
2022-02-02 19:29:29 +01:00
Erik Eckstein
6ee19f0bea Do conservative cross-module-optimization by default
The "regular" CMO is done with the option `-cross-module-optimization`. It's good for performance but can increase code size.
Now, which this change CMO is also done if the option is not given, but in a very conservative way. Only very small functions are serialized and not additional type metadata is kept alive.

rdar://70082202
2022-01-12 12:43:53 +01:00
Erik Eckstein
408cf02bc8 rework cross-module-optimization
* rename the CrossModuleSerializationSetup pass to simply CrossModuleOptimization
* remove the CMO specific serializer pass. Instead run the CrossModuleSerializationSetup pass directly before the standard serializer pass.
* correctly handle shared functions (e.g. specializations)
* refactoring
2021-12-20 11:33:02 +01:00