Commit Graph

11 Commits

Author SHA1 Message Date
Hamish Knight
0d9f667516 [test] Pass -enable-default-cmo in a couple of tests
CMO is enabled by default in the new driver, add
`-enable-default-cmo` in a couple of places to make
the behavior consistent across both the old and
new driver.
2024-09-22 23:10:40 +01:00
Ellie Shin
a3250e426d Support Package CMO
* Add a new flag -experimental-package-cmo that requires -experimental-allow-non-resilient-access.
* Support serializing package decls for CMO in package if enabled.
* Only applies to default mode CMO.
* Unlike the existing CMO, package CMO can be built with -enable-library-evolution as package
modules are required to be built together in the same project.
* Create hasPublicOrPackageVisibility to opt in for package decls; needed for CMO, SILVerifier,
and other call sites that verify or determine codegen.

Resolves rdar://121976014
2024-03-12 15:00:24 -07:00
Cyndy Ishida
f869bd7e8a [TBDGen] Write tbd-v5 files by default
* Fixup tests to handle new json based output.
* Use llvm-nm & readtapi to verify tbd file outputs.

resolves: rdar://117604275
2023-11-14 08:06:24 -08:00
Erik Eckstein
63808be395 DefinitInitialization: convert begin_access instructions of initializations to a static accesses
In case of `var` initializations, SILGen creates a dynamic begin/end_access pair around the initialization store.
If it's an initialization (and not a re-assign) it's guanranteed that it's an exlusive access and we can convert the access to an `[init] [static]` access.

https://github.com/apple/swift/issues/66496
2023-06-14 07:17:56 +02:00
Erik Eckstein
7bbf66ab5b ReadOnlyGlobalVariables: don't convert external global vars to lets
Because we don't know if external variables will be written

Fixes a miscompile
rdar://109476745
2023-05-19 18:28:22 +02: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
Erik Eckstein
75bc7f621f CrossModuleOptimization: don't serialize functions referencing imported C functions/variables
Imported C functions and variables are not necessarily public in their modules.

rdar://100874714
2022-10-10 18:29:01 +02:00
Erik Eckstein
d93ab2019a CrossModuleOptimization: public global variables must not be serialized if they reference private functions/closures
For example:
```
public static var privateFunctionPointer: (Int) -> (Int) = { $0 }
```

Fixes a verifier crash and/or undefined symbol error

rdar://99493254
2022-09-02 22:17:40 +02:00
Erik Eckstein
a1da35c6cb cross-module-optimization: be more conservative when emitting a TBD file, part 2
This is a follow-up of 1dfb3b1a2a.
We need to be more conservative about types as for functions, because types can also "produce" symbols, like direct field offsets, etc.

rdar://96953318
2022-07-26 14:28:09 +02: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
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