Commit Graph

26 Commits

Author SHA1 Message Date
Erik Eckstein
bbcc9f5943 DeadFunctionElimination: keep global variables alive which are referenced from another global
Fixes a compiler crash in case a private global is only reference from another global variable, for example:

```
private var g1 = 27
let g2 = UnsafePointer(&g1)
```

rdar://117189962
2023-10-19 20:29:30 +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
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
ee8cdac501 DeadFunctionElimination: Also eliminate dead global variables.
It makes sense to to this in a single pass, because there might be dead cycles for globals and functions, e.g. if a global references a function in its static initializer and the function references that global.

Another improvement: eliminate dead global-initializers. Before we had an explicit SIL representation of statically initialized globals, we had to keep them alive.

rdar://32956923
2021-02-09 19:56:43 +01:00
Slava Pestov
9ec80df97e SIL: Remove curried SILDeclRefs 2020-03-19 02:20:21 -04:00
Erik Eckstein
39bb14b094 change mangling prefix from $S to $s
This is the final ABI mangling prefix

rdar://problem/38471478
2018-09-19 13:55:11 -07:00
Slava Pestov
1831b5471e SIL: Clean up 'early serialization' a bit
- Clear the 'serialized' flag on witness tables and vtables
  after serialization, not just functions. This fixes SIL
  verifier failures if post-serialization SIL is printed
  out and parsed back in.

- Clear the 'serialized' flag when deserializing functions,
  witness tables and vtables in a module that has already
  been serialized. This fixes SIL verifier failures if
  we deserialize more declarations after serializing SIL.

We were seeing SIL verifier failures on bots that run the
tests with the stdlib built with non-standard flags.

Unfortunately I don't have a reduced test case that would
fail in PR testing without these fixes.

Fixes <rdar://problem/36682929>.
2018-01-21 01:35:13 -08:00
Erik Eckstein
cd3d50a5d9 ABI: Change the mangling prefix from _T0 to $S 2018-01-06 13:55:59 -08:00
Slava Pestov
ea7251bbae SILGen: Don't emit default witness tables unless protocol is resilient 2017-12-10 20:30:47 -08:00
Erik Eckstein
76f281510f Remove @_semantics("optimize.sil.never")
The replacement is @_optimize(none)
2017-11-16 14:11:52 -08:00
Roman Levenstein
74915682cb Update tests after the removal of -sil-serialize-vtables 2017-10-21 19:18:15 -07:00
Roman Levenstein
35a624bb15 Update tests after removing -sil-serialize-witness-tables 2017-10-20 19:45:29 -07:00
Slava Pestov
6bb5b7ebcc SIL: Serialize conformances synthesized by the ClangImporter
The witness table had shared linkage, but we weren't serializing them,
which would cause linking errors if we emitted a reference to such a
witness table from a different module than the one where it was first
defined, as a result of deserializing and optimizing SIL.

This issue was introduced when SIL witness table serialization was
made conditional on the -sil-serialize-witness-tables flag, which is
normally only enabled for the standard library.

When the flag was added, existing tests were updated to pass the
flag, which masked the issue. Remove the flag from existing tests,
ensure that imported witness tables are still [serialized], and add
a new test specifically for the behavior enabled by this flag.
2017-09-15 00:24:52 -07:00
Roman Levenstein
27d1edfcdd Fix affected tests 2017-06-19 20:24:30 -07:00
Slava Pestov
8fe8b89b0f SIL: Terminology change: [fragile] => [serialized]
Also, add a third [serializable] state for functions whose bodies we
*can* serialize, but only do so if they're referenced from another
serialized function.

This will be used for bodies synthesized for imported definitions,
such as init(rawValue:), etc, and various thunks, but for now this
change is NFC.
2017-03-29 16:47:28 -07:00
Erik Eckstein
c4a11f4c92 tests: remove the now unused option -new-mangling-for-tests 2017-03-22 11:28:43 -07:00
Roman Levenstein
a422f8af63 [sil-dead-funciton-elimination] Eliminate unused default methods implementations from default witness tables
We were missing this opportunity, because we forgot to update DeadFunctionElimination after default witness tables were introduced.

rdar://30264699
2017-01-30 11:57:34 -08:00
Roman Levenstein
8ad61d5cd6 Use function signatures for SILDeclRefs in witness_tables, vtables and witness_method instructions.
Textual SIL was sometimes ambiguous when SILDeclRefs were used, because the textual representation of SILDeclRefs was the same for functions that have the same name, but different signatures.
2017-01-27 12:16:14 -08:00
Maxim Moiseev
96dc4817f3 Revert "Use function signatures for SILDeclRefs in witness_tables, vtables and witness_method instructions" 2017-01-26 16:28:57 -08:00
Roman Levenstein
bf2dcbf25e Use function signatures for SILDeclRefs in witness_tables, vtables and witness_method instructions.
Textual SIL was sometimes ambiguous when SILDeclRefs were used, because the textual representation of SILDeclRefs was the same for functions that have the same name, but different signatures.
2017-01-26 14:29:59 -08:00
Erik Eckstein
1d3724666f tests: convert about 400 tests to the new mangling by using the -new-mangling-for-tests option
When the new mangling is enabled permanently, the option can be removed from the RUN command lines again.
2017-01-24 15:27:45 -08:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Slava Pestov
fded0d5bc2 SIL: Mark externally-visible witness tables for fixed-layout types as [fragile]
Also, mark witness thunks for [fragile] witnesses as [fragile].

This allows us to serialize the witness table, as well as any thunks
for witnesses declared @_transparent and @inline(__always).
2016-03-28 14:14:49 -07:00
Xin Tong
7808fb3034 Make dead function elim respect optimize.sil.never. Its possible these functions
can be called from something external of the program, e.g. debugger
2016-02-08 13:35:23 -08:00
Andrew Trick
bd35b4789c Move test/SILOptimizer files to reflect lib/SILOptimizer. 2015-12-11 15:53:22 -08:00