Commit Graph

1451 Commits

Author SHA1 Message Date
Nate Chandler
1961be8845 Renamed flag to -enable-lexical-lifetimes.
Previously, both swift-frontend and sil-opt put lexical lifetimes behind
a flag named -enable-experimental-lexical-lifetimes.  That's redundant.
Here, the experimental portion of the name is dropped.
2021-12-03 17:40:37 -08:00
Xi Ge
b8a2d0752f Merge pull request #40379 from apple/revert-40368-revert-40357-obfuscate-searialized-paths
Re-apply "serialization: obfuscate the serialized search paths"
2021-12-02 19:21:04 -08:00
Holly Borla
47b375fb3f Merge pull request #40361 from hborla/enable-structural-opaque-types
[SE-0328] Enable structural opaque result types.
2021-12-02 15:00:18 -08:00
Xi Ge
6377c3a742 Revert "Revert "serialization: obfuscate the serialized search paths"" 2021-12-02 13:21:04 -08:00
Saleem Abdulrasool
11d5d6d4ca Revert "serialization: obfuscate the serialized search paths" 2021-12-02 08:18:23 -08:00
Xi Ge
0047d81f9a serialization: obfuscate the serialized search paths
We noticed some Swift clients rely on the serialized search paths in the module to
find dependencies and droping these paths altogether can lead to build failures like
rdar://85840921.

This change teaches the serialization to obfuscate the search paths and the deserialization
to recover them. This allows clients to keep accessing these paths without exposing
them when shipping the module to other users.
2021-12-01 11:47:41 -08:00
Holly Borla
9196c9ad41 [FrontendOptions] Enable structural opaque result types and remove
the -enable-experimental-structural-opaque-types frontend flag.
2021-11-30 15:41:23 -08:00
Kuba (Brecka) Mracek
c89eca6c34 Enforce consistent usage of -experimental-hermetic-seat-at-link flag (#39986)
We've recently added the -experimental-hermetic-seal-at-link compiler flag,
which turns on aggressive dead-stripping optimizations and assumes that library
code can be optimized against client code because all users of the library
code/types are present at link/LTO time. This means that any module that's
built with -experimental-hermetic-seal-at-link requires all clients of this
module to also use -experimental-hermetic-seal-at-link. This PR enforces that
by storing a bit in the serialized module, and checking the bit when importing
modules.
2021-11-30 10:44:58 -08:00
Slava Pestov
163293e6f9 RequirementMachine: Split up -requirement-machine-generic-signatures flag into -requirement-machine-{abstract,inferred}-signatures 2021-11-19 17:06:00 -05:00
Richard Wei
65bffd7ad7 Add _MatchingEngine and _StringProcessing modules.
These modules are part of the experimental declarative string processing feature. If accepted to the Standard Library, _StringProcessing will be available via implicit import just like _Concurrency, though _MatchingEngine will still be hidden as an implementation detail.

`_MatchingEngine` will contain the general-purpose pattern matching engine ISA, bytecode, and executor. `_StringProcessing` will contain regular expression and pattern matching APIs whose implementation depends on the matching engine..

Also consolidates frontend flag `-enable-experimental-regex` as `-enable-experimental-string-processing`.

Resolves rdar://85478647.
2021-11-19 09:27:33 -08:00
Michael Gottesman
3eba144b83 Merge pull request #40189 from gottesmm/pr-aeffd0309402b8c9a744770c71ce40ca6f0459ff
[move-operator] Specify if LexicalLifetimes is enabled using an enum instead of a bool.
2021-11-15 16:47:38 -08:00
Kuba (Brecka) Mracek
66bd5e6a39 Add ASTMangler.AllowStandardSubstitutions to allow using a stripped-down libswiftCore (#40009) 2021-11-15 15:40:35 -08:00
Michael Gottesman
72eb5e2eec [move-operator] Specify if LexicalLifetimes is enabled using an enum instead of a bool.
The reason why I am doing this is that we are going to be enabling lexical
lifetimes early in the pipeline so that I can use it for the move operator's
diagnostics.

To make it easy for passes to know whether or not they should support lexical
lifetimes, I included a query on SILOptions called
supportsLexicalLifetimes. This will return true if the pass (given the passed in
option) should insert the lexical lifetime flag. This ensures that passes that
run in both pipelines (e.x.: AllocBoxToStack) know whether or not to set the
lexical lifetime flag without having to locally reason about it.

This is just chopping off layers of a larger patch I am upstreaming.

NOTE: This is technically NFC since it leaves the default alone of not inserting
lexical lifetimes at all.
2021-11-15 13:47:22 -08:00
Michael Ilseman
2740e2707c Experimental Regex Strawperson (use Swift in the parser) (#40117)
[regex] Use Swift in the parser

Add in a strawperson use of Swift by the parser, for
future regex support.
2021-11-14 07:11:47 -07:00
Slava Pestov
d0a8abb533 RequirementMachine: Add -requirement-machine-generic-signatures flag
Just as with the others, this has three values: on, off, and verify.
Not hooked up for now.
2021-11-12 00:32:43 -05:00
Saleem Abdulrasool
af772d50fc Merge pull request #39998 from compnerd/async-inheritance
IRGen: initial pass to support `async` inheritance on Windows
2021-11-01 19:59:04 -07:00
Kuba (Brecka) Mracek
d682049d25 Under VFE/WME, disable mangled accessors and disable LLVM MergeFunctions (#39969) 2021-11-01 15:34:53 -07:00
冀卓疌
af7bee8430 Merge pull request #39853 from rjmansfield/main
Fix various typos and missing whitespace.
2021-11-02 03:05:47 +08:00
Saleem Abdulrasool
68bc33fed3 IRGen: initial pass to support async inheritance on Windows
With PE/COFF, one cannot reference a data symbol directly across the
binary module boundary.  Instead, the reference must be indirected
through the Import Address Table (IAT) to allow for position
independence.

When generating a reference to a AsyncFunctionPointer ({i8*, i32}), we
tag the pointer as being indirected by tagging bit 1 (with the
assumption that native alignment will ensure 4/8 byte alignment, freeing
the bottom 2 bits at least for bit-packing).  We tweak the
v-table/witness table emission such that all references to the
AsyncFunctionPointer are replaced with the linker synthetic import
symbol with the bit packing:

~~~
.quad __imp_$s1L1CC1yyYaKFTu+1
~~~

rather than

~~~
.quad $s1L1CC1yyYaKFTu
~~~

Upon access of the async function pointer reference, we open-code the
check for the following:

~~~
pointer = (pointer & 1) ? *(void **)(pointer & ~1) : pointer;
~~~

Thanks to @DougGregor for the discussion and the suggestion for the
pointer tagging.  Thanks to @aschwaighofer for pointers to the code that
I had missed.  Also, thanks to @SeanROlszewski for the original code
sample that led to the reduced test case.

Fixes: SR-15399
2021-11-01 11:23:51 -07:00
QuietMisdreavus
dd88e0dda6 Merge pull request #39865 from apple/QuietMisdreavus/private-swiftc-symbols
[Driver][SymbolGraph] add new flag -symbol-graph-minimum-access-level

rdar://79099869
2021-10-29 13:01:22 -06:00
Erik Eckstein
4e6c5434f3 driver/frontend: Add an -experimental-performance-annotations option to enable performance annotations 2021-10-28 18:43:14 +02:00
Michael Gottesman
60f3d61031 Merge pull request #39943 from gottesmm/pr-65ca66f5402c00e0f0fa0608409ef1c732d1fd2b
[moveOnly] Add a skeleton _move function
2021-10-28 02:23:56 -07:00
Michael Gottesman
44bd180d85 [moveOnly] Add a frontend flag -enable-experimental-move-only to control usage of move only features.
These include _move and @_noImplicitCopy. I still need to wire up the parsing of
those behind this feature.

The reason that I am adding this now is that I am going to now need to make some
changes behind a feature flag and I have not yet needed to add one. The specific
reason I needed to add one here is to ensure that I properly guard inside _move
the call to Builtin.move so as to prevent a "cond_fail" incident.

P.S.: This work depends on experimental lexical lifetimes being enabled as well,
so I did that at the same time in this PR.
2021-10-27 18:45:33 -07:00
Doug Gregor
f0cd714161 Rework the watchOS concurrency back-deployment async frame pointer.
Introduce a few changes to the logic for watchOS concurrency
back-deployment with respect to the async frame pointer.

* Only apply the change to watchOS device targets, not simulator targets
* Only introduce the override when no specific
  `-swift-async-frame-pointer=<value>` option is provided on the
command line
* Only override the default when deploying to watchOS < 8, and
* Use "never" for the default rather than "always".

This represents a different but safer trade-off than before. Setting
the async bit in the frame pointer can cause older APIs (such as
backtrace APIs in the OS) to crash when they encounter such frame
pointers. So, with this change we never set the bit when back-deploying
for watchOS device, to avoid said crashes.

The trade-off here is that a back-deployed watchOS app will never have
the async frame pointer bit set, so async backtraces will be
unavailable even when running on watchOS 8 or newer.
2021-10-27 12:04:20 -07:00
Doug Gregor
4aca32c0a4 Disable the definition and use of swift_async_extendedFramePointerFlags on watchOS
The asm definition of `swift_async_extendedFramePointerFlags` prevents
the use of bitcode with the back-deployment libraries, so remove the
definition and use of this symbol from watchOS binaries entirely.
Instead, always force the async frame bit to be set. This trades off
backtraces on older OS's for debuggability of newer ones. If it causes
problems, it can be disabled via the option
`-swift-async-frame-pointer=never`.

Fixes rdar://84687579.
2021-10-26 22:26:37 -07:00
Victoria Mitchell
6b5d884042 add new flag -symbol-graph-minimum-access-level 2021-10-21 17:07:41 -06:00
Kuba (Brecka) Mracek
b413a0f4dd Add Builtin.ifdef_<FLAGNAME> as a facility to peek at -D flag that client code is building with (#39797) 2021-10-21 15:36:47 -07:00
Ryan Mansfield
3fc77627a7 Fix various typos and missing whitespace. 2021-10-21 09:05:27 -07:00
Nate Chandler
23a9a1d4c9 Moved lexical lifetime flag to SILOptions.
Previously, the flag was a LangOptioins.  That didn't make much sense because
this isn't really a user-facing behavior.  More importantly, as a member
of that type type it couldn't be accessed when setting up pass
pipelines.  Here, the flag is moved to SILOptions.
2021-10-13 13:47:44 -07:00
Slava Pestov
5fd48a08a1 Merge pull request #39629 from slavapestov/rqm-protocol-signatures
RequirementMachine: Wire up protocol requirement signature minimization
2021-10-09 22:30:05 -04:00
Slava Pestov
0e21d85325 RequirementMachine: Add -requirement-machine-protocol-signatures= flag
There are three settings, on, off and verify. Not hooked up quite yet.
2021-10-09 19:11:14 -04:00
Pavel Yaskevich
790b5499b9 Merge pull request #38577 from xedin/multi-statement-closure-type-checking
[TypeChecker] Incremental multi-statement closure type-checking (disabled by default)
2021-10-09 11:49:13 -07:00
Doug Gregor
e845af8fc2 Merge pull request #39550 from DougGregor/require-explicit-sendable
Add `-require-explicit-sendable` to warn about non-Sendable public types
2021-10-08 16:13:06 -07:00
Pavel Yaskevich
a1c0823f46 [AST] Add a flag to guard exprimental multi-statement closures feature 2021-10-08 10:08:00 -07:00
Alexis Laferrière
a34953ece9 [Sema] Intro flag to limit availability checks to the API
Intro the frontend flag `-check-api-availability-only` that limits
availability checking to the API and SPI. This mode doesn't check the
availability of non-inlinable function bodies and of non-ABI-public decl
signatures.

This mode goal is to check all that is printed in the swiftinterface
file. It should be used in place of the wider
`-disable-availability-checking` when generating an interface for
platforms with no binaries.

rdar://81679692
2021-10-07 17:14:55 -07:00
Doug Gregor
bc4ae04f1f Add -require-explicit-sendable to warn about non-Sendable public types
Introduce a compiler flag that warnings about any public types defined in
a module that are neither explicitly `Sendable` nor explicitly
non-`Sendable` (the latter of which has no spelling currently), which
is intended to help with auditing a module for Sendable conformances.
2021-10-06 12:30:57 -07:00
Meghana Gupta
f458d9b490 Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag (#39516)
* Fix unnecessary one-time recompile of stdlib with -enable-ossa-flag

This includes a bit in the module format to represent if the module was
compiled with -enable-ossa-modules flag. When compiling a client module
with -enable-ossa-modules flag, all dependent modules are checked for this bit,
if not on, recompilation is triggered with -enable-ossa-modules.

* Updated tests
2021-10-04 18:46:40 -07:00
Kuba (Brecka) Mracek
d6bc48acde Merge pull request #39313 from kubamracek/conditional
Implement conditional stripping of type descriptors, protocols and protocol conformances via !llvm.used.conditional
2021-10-01 09:18:41 -07:00
Kuba (Brecka) Mracek
e405a9fae8 Extend LLVM IR WME to use thunks for cross-module witness method calls. (#39528)
This enables optimizing / dead-stripping of witness methods across modules at
LTO time.

- Under -internalize-at-link, restrict visibility of wtables to linkage unit.
- Emit thunks for cross-module wcalls when WME is enabled.
- Use thunks for wcalls across modules when WME is enabled.
- Adjust TBDGen to account for witness method thunks when WME is enabled.
- Add an IR test to check that thunks are used when doing cross-module calls.
- Add an end-to-end test case for cross-module WME.
2021-10-01 07:09:50 -07:00
Kuba Mracek
2dfd232d90 Implement conditional stripping of type descriptors, protocols and protocol conformances via !llvm.used.conditional
A new LLVM IR affordance that allows expressing conditions under which globals
can be removed/dropped (even when marked with @llvm.used) is being discussed at:

- <https://reviews.llvm.org/D104496>
- <https://lists.llvm.org/pipermail/llvm-dev/2021-September/152656.html>

This is a preliminary implementation that marks runtime lookup records (namely
protocol records, type descriptors records and protocol conformance records)
with the !llvm.used.conditional descriptors. That allows link-time / LTO-time
removal of these records (by GlobalDCE) based on whether they're actually used
within the linkage unit. Effectively, this allows libraries that have a limited
and known set of clients, to be optimized against the client at LTO time, and
significantly reduce the code size of that library.

Parts of the implementation:
- New -conditional-runtime-records frontend flag to enable using !llvm.used.conditional
- IRGen code that emits these records can now emit these either as a single contiguous
  array (asContiguousArray = true, the old way), which is used for JIT mode, or
  as indivial globals (asContiguousArray = false), which is necessary for the
  !llvm.used.conditional stripping to work.
- When records are emitted as individual globals, they have new names of
  "\01l_protocol_" + mangled name of the protocol descriptor, and similarly for
  other records.
- Fixed existing tests to account for individual records instead of a single array
- Added an IR level test, and an end-to-end execution test to demonstrate that
  the !llvm.used.conditional-based stripping actually works.
2021-09-29 13:15:02 -07:00
Rintaro Ishizaki
fa04717bf5 Merge pull request #39395 from rintaro/sourcekit-completion-inits
[CodeCompletion] Remove two completion options from LangOptions
2021-09-29 09:52:51 -07:00
Xi Ge
a4b4b1fa65 ClangImporter: don't import clang SPI attributes by default 2021-09-28 10:46:27 -07:00
Egor Zhdan
e1c4ea50c8 Merge pull request #37806 from egorzhdan/clang-executable-path-reapply
ClangImporter: run Clang with a proper executable path (pt 2)
2021-09-24 21:46:03 +03:00
Rintaro Ishizaki
afc24dfd4b [CodeCompletion] Remove two completion options from LangOptions
"add inits to toplevel" and "call pattern heuristics" are only used in
code completion. Move them from LangOptions to CodeCompletionContext so
that they don't affect compiler arguments.
2021-09-22 16:49:50 -07:00
Gwen Mittertreiner
b6cff0b844 Add a Flag to Force Type Layouts for Structs
Added ForceStructTypeLayouts. When enabled, IRGen will lower structs using the
aligned group of TypeLayout rather than using TypeInfos. This potentially leads
to a size increase as TypeInfos currently produce better code than the
TypeLayout route.
2021-09-21 22:21:15 -07:00
Kuba (Brecka) Mracek
9fb54e95ae Add -internalize-at-link flag to allow dead stripping and VFE across modules at link time (#39214)
- Under -internalize-at-link, stop unconditionally marking all globals as used.
- Under -internalize-at-link, restrict visibility of vtables to linkage unit.
- Emit virtual method thunks for cross-module vcalls when VFE is enabled.
- Use thunks for vcalls across modules when VFE is enabled.
- Adjust TBDGen to account for virtual method thunks when VFE is enabled.
- Add an end-to-end test case for cross-module VFE.
2021-09-21 12:26:52 -07:00
Kuba (Brecka) Mracek
46eb8d5db5 Implement LLVM IR Witness Method Elimination for Swift witness tables. (#39287)
- Witness method calls are done via @llvm.type.checked.load instrinsic call with a type identifier
- Type id of a witness method is the requirement's mangled name
- Witness tables get !type markers that list offsets and type ids of all methods in the wtable
- Added -enable-llvm-wme to enable Witness Method Elimination
- Added IR test and execution test
2021-09-21 06:57:44 -07:00
nate-chandler
67aab4245d Merge pull request #39303 from nate-chandler/lexical_lifetimes/respell_defined_as_lexical
[SIL] Changed spelling of lifetime flags.
2021-09-16 13:30:51 -07:00
Arnold Schwaighofer
a1a9dd16ce Change the logic to exclude extended frame info on all platforms but darwin 2021-09-14 12:48:27 -07:00
Arnold Schwaighofer
2381233ac1 Add flag -swift-async-framepointer=auto,never,always to
control swift extended frame information emission

On linux we default to disable the extended frame info (since the system
libraries don't support it).

On darwin the default is to automatically choose based on the deployment target.

The Concurrency library explicitly forces extended frame information and the
back deployment library explicitly disables it.
2021-09-14 12:47:16 -07:00