Commit Graph

1485 Commits

Author SHA1 Message Date
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
Alexis Laferrière
2cd0d5e1d3 Merge pull request #37768 from xymus/swiftmodule-sdk
[Serialization] Restrict loading swiftmodule files to the SDK that built them
2021-09-14 08:53:49 -07:00
Nate Chandler
f833b68d3b [SIL] Changed spelling of lifetime flags.
Changed the frontend flag to -enable-experimental-lexical-lifetimes from
-enable-experimental-defined-lifetimes.

Changed the attribute on begin_borrow from [defined] to [lexical].
2021-09-14 08:49:30 -07:00
nate-chandler
e68b6a7f83 Merge pull request #39283 from nate-chandler/lexical_lifetimes/let/initial
[SILGen] Added [defined] lifetimes for lets behind flag.
2021-09-14 08:47:35 -07:00
Kuba (Brecka) Mracek
5412ed1936 Implement LLVM IR Virtual Function Elimination for Swift classes. (#39128)
- Virtual calls are done via a @llvm.type.checked.load instrinsic call with a type identifier
- Type identifier of a vfunc is the base method's mangling
- Type descriptors and class metadata get !type markers that list offsets and type identifiers of all vfuncs
- The -enable-llvm-vfe frontend flag enables VFE
- Two added tests verify the behavior on IR and by executing a program
2021-09-14 06:59:07 -07:00
Alexis Laferrière
c38d1773d2 [Serialization] Restrict loading swiftmodule files to the builder's SDK
Serialize the canonical name of the SDK used when building a swiftmodule
file and use it to ensure that the swiftmodule file is loaded only with
the same SDK. The SDK name must be passed down from the frontend.

This will report unsupported configurations like:

- Installing roots between incompatible SDKs without deleting the
swiftmodule files.
- Having multiple targets in the same project using different SDKs.
- Loading a swiftmodule created with a newer SDK (and stdlib) with an
older SDK.

All of these lead to hard to investigate deserialization failures and
this change should detect them early, before reaching a deserialization
failure.

rdar://78048939
2021-09-13 16:44:08 -07:00
Nate Chandler
d002471784 Added -enable-experimental-defined-lifetimes.
The new flag will guard work on the experimental implementation of
tracking lexical lifetimes in SIL.
2021-09-13 11:06:22 -07:00
Arnold Schwaighofer
ed6d1f49ff Don't optionally enable arm64_32 GlobalISel 2021-09-07 07:47:44 -07:00
Doug Gregor
a6c88ee52c Disable availability checking when type-checking the _Concurrency interface
Swift 5.5 didn't support back deployment of concurrency features, so a
Swift 5.5 compiler processing the _Concurrency .swiftinterface will
produce errors for each `async` function and actor with pre-macOS
12/iOS 15 availability. Emit `-disable-availability-checking` into the
generated `.swiftinterface` files to allow Swift 5.5 to continue to
build them.

Finishes rdar://82602353.
2021-09-02 12:56:20 -07:00
Arnold Schwaighofer
a864d4ed04 Don't enable GlobalISel on arm64e
It is not well supported

rdar://82082527
2021-08-30 13:06:49 -07:00
Doug Gregor
599974367e Enable concurrency back-deployment in the compiler by default.
Remove the option that explicitly enables concurrency back-deployment,
and instead always enable its support in the compiler. Remove the use
of the extraneous CMake option as well.
2021-08-28 22:43:41 -07:00
Doug Gregor
9d4ce58ed6 Merge pull request #38930 from DougGregor/concurrency-compatibility-library
[concurrency] Implement a compatibility .a library for Concurrency.
2021-08-28 22:40:37 -07:00
Doug Gregor
76c4ac8263 Add a temporary flag to stage in back-deployment of concurrency.
Add a frontend-only flag `-enable-experimental-back-deploy-concurrency`
to be used to stage in the back deployment of concurrency. At present,
all it does is lower the availability minimums for use of concurrency
features.
2021-08-23 12:55:58 -07:00
Slava Pestov
399a600e32 RequirementMachine: Add -debug-requirement-machine= flag to control debug output 2021-08-20 01:29:22 -04:00
Slava Pestov
fe2f42bc72 RequirementMachine: Rename -debug-requirement-machine flag to -dump-requirement-machine 2021-08-19 22:14:58 -04:00
Hamish Knight
7fd4406e0c Merge pull request #38915 from hamishknight/refactor-evaluate-print-loop
[test] Use %refactor-check-compiles in more places
2021-08-19 13:21:08 +01:00
Michael Gottesman
1bc94bfa6a [concurrency] Implement a compatibility .a library for Concurrency.
In a back deployment scenario, this will provide a place where one could provide
function implementations that are not available in the relevant stdlib.

This is just setting up for future work and isn't doing anything interesting
beyond wiring it up/making sure that it is wired up correctly with tests.
2021-08-18 09:35:37 -07:00