Commit Graph

17 Commits

Author SHA1 Message Date
Erik Eckstein
ff15d54c6c Deserializer: fix a crash with global variables and cross-module-optimization
In case of cross-module-optimizations it can happen that a private global variable is changed to public,
but it's declaration is not available in the module file.
2024-07-02 14:03:02 +02:00
Emil Pedersen
299cf2972e [test] Add missing colons for FileCheck 2024-02-26 13:31:04 -08:00
Erik Eckstein
1e6511e7c0 Pass Pipeline: replace the old GlobalOpt with the new InitializeStaticGlobals and ReadOnlyGlobalVariablesPass passes. 2023-05-08 21:23:36 +02:00
Holly Borla
8713d78704 [PrintOptions] Print explicit 'any' in SIL. 2022-08-18 01:15:12 -04: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
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
Erik Eckstein
27e1220a67 CMO: fix handling of static globals with function references
Referenced functions within the initializer of a SILGlobalVariable must be handled like referenced functions in other functions.

Fixes an assert crash when compiling with -cross-module-optimization
2021-10-13 15:22:58 +02:00
Erik Eckstein
c1e1bf2bd6 cross-module-optimization: Don't serialize functions which reference implementationOnly-imported functions
The check for implementationOnly imports was already done for types, but it was missing for functions.
Fixes a crash when implementationOnly-importing a C module.

https://bugs.swift.org/browse/SR-15048
rdar://81701218
2021-08-19 20:27:56 +02:00
Erik Eckstein
e3d636e519 CrossModuleOptimization: fix crash when importing a module as implementationOnly
If a function uses a type imported as implementationOnly (or similar), it cannot be serialized.

I added a new API in ModuleDecl (canBeUsedForCrossModuleOptimization), which performs this check.

rdar://72864719
2021-01-18 13:09:27 +01:00
Mishal Shah
a3cd8bc9e9 [Tests] Codesign the binary before executing the test 2020-08-07 00:26:07 -07:00
Erik Eckstein
a7425c16ff Improvements for cross-module-optimization
* Include small non-generic functions for serializaion
* serialize initializer of global variables: so that global let variables can be constant propagated across modules

rdar://problem/60696510
2020-06-22 16:49:26 +02:00
Erik Eckstein
318f988359 cross-module-optimiations: Fix an compiler crash and a wrong linkage
In case a property is more visible than its container, an assert was triggering in ValueDecl::isUsableFromInline().

rdar://problem/62403317
2020-04-29 13:25:33 +02:00
Erik Eckstein
f03956b30c Cross-module-optimization: Serialize immediately after CrossModuleSerializationSetup
Otherwise it can happen that e.g. specialization runs between CrossModuleSerializationSetup  and serialization, resulting that an inlinable function references a shared function (which doesn't have a public linkage).
The solution is to move serialization right after CrossModuleSerializationSetup. But only do that if cross-module-optimization is enabled (it would be a disruptive change to move serialization in general).
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
Daniel Rodríguez Troitiño
ada8217c0f [windows] Enable symbolic references in PE/COFF.
In order for the cross-module optimization to work, it needs to generate
symbolic references, which were disabled in PE/COFF. This commit enables
them and marks some Reflection tests with XFAIL since
swift-reflection-dump still doesn't handle symbolic references.
2019-12-05 13:42:57 -08: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