Commit Graph

46922 Commits

Author SHA1 Message Date
Pavel Yaskevich
886a8ab6b7 [Diagnostics] Improve diagnostics when passing async to a sync parameter
If `async` effect has been inferred from the body of the closure,
let's find out the first occurrence of `async` node and point it out
to make it clear why closure is `async`.

Resolves: rdar://70610141
2021-05-03 11:08:36 -07:00
eeckstein
e6c92889a6 Merge pull request #37166 from eeckstein/fix-keypath-optimization
SILCombine: fix keypath optimization with optional chaining and classes
2021-05-03 18:30:05 +02:00
Kavon Farvardin
1bdf006b1f Merge pull request #37190 from kavon/eff-prop-swiftinterface-ifguard-fix
fix feature guards in swiftinterface for eff. props
2021-05-03 08:52:21 -07:00
Arnold Schwaighofer
513774ea3a Merge pull request #37179 from aschwaighofer/fix_async_throwing_unnaturally_direct
IRGen: Don't ignore the error parameter in some async functions
2021-05-03 07:26:16 -07:00
swift-ci
a6915e7bfe Merge pull request #37197 from ktoso/wip-group-dont-require-sendble-yet 2021-05-02 21:37:20 -07:00
Konrad `ktoso` Malawski
1cd7180382 [Concurrency] don't require Sendable (yet) on groups and locals 2021-05-03 10:52:06 +09:00
Xi Ge
bbe5b83de9 Parser: teach canImport to take an additional parameter indicating the minimum module version
canImport should be able to take an additional parameter labeled by either version or
underlyingVersion. We need underlyingVersion for clang modules with Swift overlays because they
have separate version numbers. The library users are usually interested in checking the importability
of the underlying clang module instead of its Swift overlay.

Part of rdar://73992299
2021-05-02 17:47:44 -07:00
Saleem Abdulrasool
8da2c377da IRGen: add support for static linking on Windows
This adjusts the IRGen layer to accommodate the Windows linking model.
We assume dynamic linking by default.  The static linking is enabled by
passing `-static` to the driver, which forwards it to the frontend when
building the module statically.  This has already been required when
generating libraries, however, the non-Windows targets are more
forgiving and let it work.  On those platforms, using this hint would
allow for more efficient code generation, reducing load times and some
runtime penalties from the PLT and GOT references formed to symbols
which are module local.

This corrects static linking on Windows, which is one of the last few
items that are missing on Windows.  It also takes advantage of the hint
for the one peculiar difference between Windows and non-Windows:
protocol conformances that span module boundaries are not available as a
constant.  However, when statically linking, we can enable those
conformances to be statically resolved.  This should enable the last
known pattern to work when using static linking.

This support requires further work in the Swift Package Manager to
actually enable building libraries properly.  However, when building
with CMake, this should be sufficient to enable static linking.
2021-05-02 10:02:11 -07:00
Robert Widmann
d38b23346f Merge pull request #37184 from CodaFi/when-im-sixty-four-thirty-two
Mark an LTO Test Unsupported on arm64_32
2021-05-01 21:38:08 -07:00
Michael Gottesman
e670d2b4de [sil-combine] Canonicalize copies using canonicalizeOSSALifetimes when moving newly created instructions into the worklist.
To be more explicit, canonicalizeOSSALifetimes is a utility that
re-canonicalizes all at once a set of defs that the caller found by applying
CanonicalizeOSSALifetime::getCanonicalCopiedDef(copy)). The reason why I am
doing this is that when we RAUW in OSSA, we sometimes insert additional copies
to make the problem easier for a utility to handle. This lets us canonicalize
away any copies before we even leave the pass.
2021-05-01 16:02:21 -07:00
John McCall
20741e059b Disable this test on Windows; it seems to not progress. (#37200)
I assume there's a common underlying problem for this and a lot of
other concurrency tests that are disabled on Windows.
2021-05-01 10:12:11 -07:00
Dario Rexin
fd73d3425e Revert "Use target-cpu for Linux in lto_autolink test (#36999)" (#37193)
This reverts commit 605a9237b4.
2021-05-01 10:11:26 -07:00
Alexis Laferrière
955a572819 [Test] Fix line numbers in objc_swift3_deprecated_objc_inference.swift 2021-04-30 21:46:33 -07:00
Ben Barham
73d9f5b843 [SourceKit] Remove OptimizeForIDE global configuration
Have SourceKit return locations for symbols outside of the current
module as well. Callsites of location and comment information should
explicitly disable retrieving serialized information where performance
is a concern.

Resolves rdar://75582627
2021-05-01 11:37:23 +10:00
Ben Barham
bfb9205c7c [Serialization] Add warning when .swiftsourceinfo is malformed
Output a warning rather than ignoring a malformed .swiftsourceinfo
completely.

Resolves rdar://77350048
2021-05-01 11:31:24 +10:00
Kavon Farvardin
c5ec5bf5b1 fix feature guards in swiftinterface for eff. props 2021-04-30 17:07:18 -07:00
Ben Barham
828d12764c [SourceKit/CursorInfo] Add locations for external files to result
.swiftsourceinfo files contain the serialized location for declarations.
Use this when outputting locations in cursor info so that clients need
not perform an extra index lookup for external modules.
2021-05-01 09:38:58 +10:00
Hamish Knight
fba9d8342f Merge pull request #37174 from hamishknight/off-the-chain
[Refactoring] Unwrap optional chains in async transform
2021-04-30 23:45:38 +01:00
Alexis Laferrière
a232ebbf43 [Test] Disable ModuleInterface/ossa-modules/sdk-test-stdlib-ossa.swift for hangs 2021-04-30 15:36:02 -07:00
Alexis Laferrière
3899af91ab [Test] Disable test/IRGen/class_resilience_objc.swift on arm64 and arm64e 2021-04-30 15:36:02 -07:00
Alexis Laferrière
28e8149867 [Test] Disable objc_swift3_deprecated_objc_inference.swift for 32 bits watchOS 2021-04-30 15:36:00 -07:00
Robert Widmann
b28e5dfbc2 Mark an LTO Test Unsupported on arm64_32
The %target-cpu annotations here cause us to form the triple
arm64_32-unknown-linux-gnu which is not a valid triple. We don't need to
run these tests on arm64_32 platforms anyways.

rdar://77398372
2021-04-30 15:00:24 -07:00
Alex Hoppen
9916a6d5c7 [Refactoring] Add a drop-in replacement for swift-refactor which checks that the code compiles after refactoring 2021-04-30 23:48:23 +02:00
Xi Ge
c7b383c1e7 Merge pull request #37177 from nkcsgexi/73992299-1
ModuleInterface/Serialization: allow library authors to define a custom module version number
2021-04-30 14:43:16 -07:00
Alex Hoppen
36f1c34aa6 Merge pull request #37110 from ahoppen/pr/convert-completion-handler
[Refactoring] Convert completion handler when converting function to async
2021-04-30 23:17:58 +02:00
Alex Hoppen
e7d56037e8 Merge pull request #37133 from ahoppen/pr/serialize-text-module-symbolgraph
[SymbolGraph] Fix crasher when retrieving cursor info of method defined in ObjC
2021-04-30 23:13:15 +02:00
Erik Eckstein
bd5d4276cd SILCombine: fix keypath optimization with optional chaining and classes
For optional chaining a swift_enum is created.
If the sub-projection is ending a begin_access in the some-branch, it also needs to be ended in the none-branch.

Fixes a compiler crash and/or a miscompile.

https://bugs.swift.org/browse/SR-14534
rdar://77224220
2021-04-30 21:47:42 +02:00
Arnold Schwaighofer
0edbca04bf IRGen: Don't ignore the error parameter in some async functions
Calls that emit the result to memory follow a different path that we
missed to update with error handling code.

rdar://76599021
2021-04-30 12:22:50 -07:00
John McCall
cc2863c136 Merge pull request #36878 from rjmccall/custom-executors
Introduce basic support for custom executors
2021-04-30 13:54:02 -04:00
Xi Ge
043d492c65 Merge branch 'main' into 73992299-1 2021-04-30 10:19:57 -07:00
Argyrios Kyrtzidis
25c366d8c7 Merge pull request #37170 from hamishknight/take-two
Mark imported @completionHandlerAsync attrs as implicit
2021-04-30 10:18:08 -07:00
Xi Ge
fe5c7ef995 ModuleInterface/Serialization: allow library authors to define a custom module version number
This allows library authors to pass down a project version number so that library users can conditionally
import that library based on the available version in the search paths.

Needed for rdar://73992299
2021-04-30 10:00:45 -07:00
Doug Gregor
106002cdfc Merge pull request #37168 from DougGregor/async-import-mirroring
[Clang importer] Fix mirroring of protocol decls for 'async' imports.
2021-04-30 09:49:29 -07:00
Slava Pestov
7a15b7a453 Merge pull request #37157 from slavapestov/gsb-pre-cleanups-redundant-requirements-rewrite
GSB: Preliminary cleanups before redundant requirement algorithm rewrite
2021-04-30 10:19:18 -04:00
Hamish Knight
07cdc2029e [Refactoring] Unwrap optional chains in async transform
Remove an optional chain of a success parameter,
as it will no longer be optional, similar to how
we remove a force unwrap.

Note that while this is a locally valid transform
within the optional chain, e.g `foo?.x` -> `foo.x`,
it may change the type of the overall chain, which
could cause errors elsewhere in the code. However
this is generally more useful to the user than
just leaving `foo` as a placeholder. Note this is
only the case when no other optionals are involved
in the chain, e.g `foo?.x?.y` -> `foo.x?.y` is
completely valid.

Resolves rdar://74014826.
2021-04-30 14:34:31 +01:00
Alex Hoppen
b2378a401e [Refactoring] Convert completion handler when converting function to async
Convert function to async currently only adds "async" to the function and runs the convert call refactoring on the body.

This was intentional, but it turns out to be somewhat confusing. Instead, run the same refactoring as the add async alternative refactoring but just replace rather than add.

Resolves rdar://77103049
2021-04-30 12:53:22 +02:00
Hamish Knight
7e4b66e071 Merge pull request #37131 from hamishknight/out-of-the-void
[Refactoring] Improve Void handling for async conversion
2021-04-30 11:27:30 +01:00
Hamish Knight
fe3dbc2fd4 Fix typo in @completionHandlerAsync printing 2021-04-30 11:14:51 +01:00
Hamish Knight
f059713a79 [test] Add -print-implicit-attrs to a couple of tests
Now that @completionHandlerAsync is implicit for
imported decls, we need to enable implicit attrs in
a couple of tests that are testing its presence.
2021-04-30 11:14:50 +01:00
Hamish Knight
f439275380 Mark imported @completionHandlerAsync attrs as implicit
Mark imported `@completionHandlerAsync` attrs as
implicit, which avoids printing them in generated
interfaces. And for the sake of completion,
serialize the implicit bit in case it's used
elsewhere in the future.

To make sure we continue to print
`@completionHandlerAsync` attributes explicitly
written by the user in Swift, add a SourceKit
interface test.

Resolves rdar://76685011
2021-04-30 11:14:50 +01:00
swift-ci
39c80eea5b Merge pull request #37164 from DougGregor/actor-class-descriptor-metadata 2021-04-30 02:22:03 -07:00
swift-ci
e152c14c0a Merge pull request #37162 from DougGregor/spawn-let 2021-04-30 02:19:16 -07:00
Alex Hoppen
9def05370b Merge pull request #37128 from ahoppen/pr/crash-invalid-extenshion-symbol-graph
[SymbolGraph] Fix a crash for member in invalid extension
2021-04-30 10:27:22 +02:00
Doug Gregor
bf30b41e5b [Clang importer] Fix mirroring of protocol decls for 'async' imports.
The de-duplication checks to preventing redundant mirroring of protocol
declarations failed to consider that a given method could be
implemented as both 'async' and non-'async' declarations, and
therefore would fail to mirror the 'async' form. Account for this
distinction.

Fixes rdar://76799297.
2021-04-30 01:05:03 -07:00
John McCall
565198ebe3 Default actors carry a null witness-table pointer in Builtin.Executor.
Previously, they were storing a low-bit flag that indicated that they
were a default actor.  Using an extra inhabitant frees up the low bit
for future use without being conspicuously more expensive to check.
2021-04-30 03:11:56 -04:00
John McCall
ec5215bf4f Remove the implicit nil inhabitant of Builtin.Executor,
and traffic in Optional<Builtin.Executor> in various places.
2021-04-30 03:11:56 -04:00
John McCall
186c53000d Introduce basic support for custom executors.
- Introduce an UnownedSerialExecutor type into the concurrency library.
- Create a SerialExecutor protocol which allows an executor type to
  change how it executes jobs.
- Add an unownedExecutor requirement to the Actor protocol.
- Change the ABI for ExecutorRef so that it stores a SerialExecutor
  witness table pointer in the implementation field.  This effectively
  makes ExecutorRef an `unowned(unsafe) SerialExecutor`, except that
  default actors are represented without a witness table pointer (just
  a bit-pattern).
- Synthesize the unownedExecutor method for default actors (i.e. actors
  that don't provide an unownedExecutor property).
- Make synthesized unownedExecutor properties `final`, and give them
  a semantics attribute specifying that they're for default actors.
- Split `Builtin.buildSerialExecutorRef` into a few more precise
  builtins.  We're not using the main-actor one yet, though.

Pitch thread:
  https://forums.swift.org/t/support-custom-executors-in-swift-concurrency/44425
2021-04-30 03:11:56 -04:00
Doug Gregor
7a80c338a4 [ABI] Set a bit in the class context descriptor for actor types.
Allow runtime metadata queries to determine if a "class" (in the
runtime) is actually an actor by adding a bit to the class context
descriptor's type-specific kind flags.

Implements rdar://77073762.
2021-04-30 00:03:55 -07:00
Doug Gregor
1fa2d1656d [Concurrency] Don't complain about interpolation variables being mutated.
Implicitly-generated interpolation variables are mutated within the
autoclosures created by a `spawn let`. Don't complain about them being
concurrently accessed, because they aren't.

Fixes rdar://76020473.
2021-04-29 23:32:56 -07:00
Doug Gregor
41f42fabbf [Concurrency] Resyntax 'async let' as 'spawn let'.
This helps track the proposal.
2021-04-29 23:28:16 -07:00