Commit Graph

6754 Commits

Author SHA1 Message Date
Joe Groff
53e8e7b1d8 SILGen: Don't reference external property descriptors for @_alwaysEmitIntoClient properties.
Their definition is fully visible to clients to be copied into them, and there isn't necessarily
a symbol for the property descriptor in the defining module, so it isn't necessary or desirable to
try to use a property descriptor with them. Trying to reference the descriptor leads to missing
symbol errors at load time when trying to use keypaths with older versions of the defining dylib,
which goes against the purpose of `@_alwaysEmitIntoClient` meaning "no ABI liabilities for the
defining module". Fixes rdar://94049160.
2022-06-01 16:54:38 -07:00
swift-ci
d4749df921 Merge remote-tracking branch 'origin/main' into rebranch 2022-05-31 09:14:18 -07:00
Joe Groff
1cb1546c6c Merge pull request #59137 from jckarter/objc-async-defined-in-swift-type-bridge
SILGen: Use ObjC types to lower async completion handler arguments.
2022-05-31 08:58:12 -07:00
Pavel Yaskevich
b7860ea055 [TypeChecker] Split for-in sequence into parsed and type-checked versions 2022-05-30 23:17:41 -07:00
Pavel Yaskevich
2c8bfee225 [SILGen] Unify handling of for-in and async for-in statements 2022-05-30 23:17:41 -07:00
Pavel Yaskevich
86165291aa [TypeChecker] Change the way for-in statement in type-checked
Instead of asking SILGen to build calls to `makeIterator` and
`$generator.next()`, let's synthesize and type-check them
together with the rest of for-in preamble. This greatly simplifies
interaction between Sema and SILGen for for-in statements.
2022-05-30 23:17:41 -07:00
Joe Groff
a59686314b SILGen: Use ObjC types to lower async completion handler arguments.
An `@objc` interface defined from Swift may have a formal type in terms of its
Swift bridged types, but we want to lower the SIL-level completion handler
implementation according to the actual ObjC types that will be passed at runtime.
Fixes rdar://93112430
2022-05-27 18:07:22 -07:00
swift-ci
dba6b83fba Merge remote-tracking branch 'origin/main' into rebranch 2022-05-27 15:54:46 -07:00
Joe Groff
b4dceb616f Merge pull request #59122 from jckarter/result-conversion-fix
SILGen: Complete initialization of FinalContext in ConversionInitialization::tryPeephole
2022-05-27 15:38:29 -07:00
swift-ci
4ee528a886 Merge remote-tracking branch 'origin/main' into rebranch 2022-05-27 15:14:25 -07:00
Joe Groff
8db31d5804 SILGen: Complete initialization of FinalContext in ConversionInitialization::tryPeephole
The callers to ConversionInitialization::tryPeephole assume that, if the conversion peephole
succeeded, that the peepholed result was fully emitted into the initialization. However, if
the ConversionInitialization sat on top of an in-memory initialization, then tryPeephole would
only set the value of the ConversionInitialization, without forwarding the value into the underlying
initialization, causing code generation to proceed leaving the underlying memory uninitialized.
This problem becomes exposed now when literal closures are emitted with a return value that is
indirectly returned and also reabstracted, and the return expression undergoes a ping-pong reabstraction
pair: we see through the conversions and peephole away the reabstractions, but fail to emplace the
result in the indirect return slot.

Fixes rdar://92654098
2022-05-27 09:07:16 -07:00
Doug Gregor
b012270fca Adopt experimental-feature infrastructure for move-only feature 2022-05-26 14:21:26 -07:00
Ehud Adler
4267958d51 Mapping decl base name to imported name 2022-05-18 10:31:04 -04:00
swift-ci
dd72e1bd1e Merge remote-tracking branch 'origin/main' into rebranch 2022-05-16 10:33:29 -07:00
Meghana Gupta
3480eecc99 Fix SILGen to generate switch_enum at +1 for opaque value operand 2022-05-11 21:15:21 -07:00
Meghana Gupta
2398181b14 Fix SILGen for yields that are @guaranteed but of trivial type when opaque values are enabled 2022-05-11 21:15:21 -07:00
Meghana Gupta
d829614b09 Fix SILGen of AnyHashableErasureExpr when opaque values are enabled 2022-05-11 21:15:21 -07:00
swift-ci
6e01ba9b9e Merge remote-tracking branch 'origin/main' into rebranch 2022-05-11 01:44:09 -07:00
Meghana Gupta
f3870767b4 Fixes in SILGen for opaque value support in coroutines (#58696) 2022-05-11 01:01:09 -07:00
Ben Barham
4e1eb1abe8 Merge pull request #58620 from bnbarham/rebranch-fixes
[rebranch] Various fixes to get macos to a compiling state
2022-05-06 09:59:38 -07:00
Ben Barham
68296c9037 [next] Remove LLVM_ATTRIBUTE_DEPRECATED
`LLVM_ATTRIBUTE_DEPRECATED` was removed in llvm/llvm-project
903c30f4d1f3bc0d1aae9ca83af17c0062d02b40. Use `[[deprecated]]` directly.
2022-05-05 16:25:10 -07:00
Joe Groff
55cda87dac Merge pull request #58651 from jckarter/closure-literal-function-conversion-throws
SILGen: Emit a closure literal in a function conversion as the converted type.
2022-05-04 14:15:10 -07:00
Joe Groff
482cc8ae24 SILGen: Emit a closure literal in a function conversion as the converted type.
Closure literals are sometimes type-checked as one type then immediately converted to another
type in the AST. One particular case of this is when a closure body never throws, but the closure
is used as an argument to a function that takes a parameter that `throws`. Emitting this naively,
by emitting the closure as its original type, then converting to throws, can be expensive for
async closures, since that takes a reabstraction thunk. Even for non-async functions, we still want
to get the benefit of reabstraction optimization for the closure literal through the conversion too.
So if the function conversion just add `throws`, emit the closure as throwing, and pass down the
context abstraction pattern when emitting the closure as well.
2022-05-04 10:24:11 -07:00
Kavon Farvardin
89233914a3 enforce expectations with an assert in deferExecutorBreadcrumb
I do not expect anyone to defer multiple breadcrumbs in a single
result plan.
2022-05-03 16:51:51 -07:00
swift-ci
273a550ef6 Merge pull request #58515 from kavon/proper-fix-for-jump-to-null
Proper fix for ObjC async jump to null
2022-05-03 16:22:38 -07:00
Kavon Farvardin
814fb42554 fix nested suspension issue with objc async calls
when two objc async functions are composed with each other,
i.e., f(g()), then the clean-ups for g() would get emitted
at an unexpected time, namely, during the suspension for
the call to f(). This means that using a clean-up to emit
the executor-hop breadcrumb was incorrect. The hop could
appear between a get_async continuation and its matching
await_continuation, which is an unsupported nested suspension.

This commit fixes that by removing the use of the breadcrumb
clean-up in favor of providing that breadcrumb directly to
the result plan, so that it may be emitted later on when the
result plan sees fit.

Fixes rdar://91502776
2022-05-02 18:20:59 -07:00
Pavel Yaskevich
33f6c564a6 [Distributed/SILGen] NFC: Remove a couple of unused variables 2022-05-02 17:29:16 -07:00
Joe Groff
d2fad71328 Merge pull request #42589 from jckarter/begin-partial-apply-simplification-pass
[SIL] Initial work on PartialApplySimplification pass
2022-05-02 10:20:39 -07:00
Kavon Farvardin
cb952ed37e Revert "Revert "[SR-15703] Fix missing hop in error path of foreign async throws call""
This reverts commit 05214f0d00.
2022-04-27 14:11:44 -07:00
Kavon Farvardin
6f86e2980a Revert "Revert "Simplify lifetime extension for async ObjC calls.""
This reverts commit 8441e07c0b.
2022-04-27 14:11:36 -07:00
Kavon Farvardin
8441e07c0b Revert "Simplify lifetime extension for async ObjC calls."
This reverts commit 01d470ce32.

Just to be safe, I'm reverting this part of https://github.com/apple/swift/pull/41571
as well, until it can be reimplemented in light of issues where a hop
can appear between a get_continuation and an await_continuation

resolves rdar://91502776
2022-04-25 12:12:26 -07:00
Kavon Farvardin
05214f0d00 Revert "[SR-15703] Fix missing hop in error path of foreign async throws call"
This reverts commit afd26d3974 to solve
a critical miscompile caused by a hop_to_executor appearing between
a get_continuation and await_continuation instruction in SIL.

A reimplementation of SR-15703 will be forthcoming.

Fixes rdar://91502776
2022-04-25 11:00:37 -07:00
swift-ci
605889b9f3 Merge pull request #42557 from kavon/fix-distactor-null-system
[Distributed] clean up some of the initialization code to be more robust
2022-04-22 21:01:42 -07:00
Konrad `ktoso` Malawski
e01bcc470f [Distributed] SILGen must consistently use prop get requests 2022-04-23 07:49:54 +09:00
Doug Gregor
c9dcca4f5e Merge pull request #42577 from ktoso/wip-prevent-multiple-id-synthesis
[Distributed] Guard ID synthesis from happening multiple times
2022-04-22 15:25:33 -07:00
Meghana Gupta
67af3a1324 [SIL Opaque Value] Fix SILGen to not generate store_borrow for +0 opaque values (#42488) 2022-04-22 13:47:13 -07:00
Zoe Carver
b07f059f2c Merge pull request #42506 from zoecarver/ufo-with-base
[cxx-interop] Add support for calling members of base classes on UFOs.
2022-04-22 09:18:32 -07:00
Konrad `ktoso` Malawski
317fdd0740 [Distributed] Guard ID synthesis from synthesizing the property multiple times; e.g. during multi module builds 2022-04-22 23:18:16 +09:00
Kavon Farvardin
3243a87e47 clean up some of the initialization code to be more robust 2022-04-21 15:57:38 -07:00
zoecarver
336cd29333 [cxx-interop] Add support for calling members of base classes on UFOs. 2022-04-21 13:40:59 -07:00
Joe Groff
1e2bda9ea0 Extensions to SILBoxType to represent captures.
- Add a `[reflection]` bit to `alloc_box` instructions, to indicate that a box
  should be allocated with reflection metadata attached.
- Add a `@captures_generics` attribute to SILLayouts, to indicate a type layout
  that captures the generic arguments it's substituted with, meaning it can
  recreate the generic environment without additional ABI-level arguments, like
  a generic partial application can.
2022-04-21 12:51:46 -07:00
nate-chandler
45ec725e43 Merge pull request #42485 from nate-chandler/rdar85526916
[SILGen] Use opaque AP for ObjC-async returns.
2022-04-20 16:43:02 -07:00
Nate Chandler
4aff98ffb5 [SILGen] Use opaque AP for ObjC-async returns.
Previously, the AbstractionPattern that was used for the value
"returned" (i.e. via a completion handler) from ObjC mostly (but not
quite always) was "type".

The generated completion handler correctly (because this is required in
order to call _resumeUnsafeContinuation) reabstracted the block (e.g.
from @convention(block) to @substituted <T> () -> @out T for <()>).  The
callee of the ObjC function, however, loaded the function from the block
as if it were not reabstracted (e.g. () -> ()).

On most platforms, that happened to work.  On arm64e, that difference in
types caused in a difference in pointer signing, resulting in a failure
at runtime.

rdar://85526879
rdar://85526916
2022-04-20 10:42:45 -07:00
Anthony Latsis
934964d49d Use AbstractStorageDecl::isSettableInSwift to prohibit direct writes to optional requirements
Stop pretending that an optional requirement is immutable via the `StorageImplInfo` request.
This approach has lead astray the conformance checker and may have had a negative impact
on other code paths, and it doesn't work for imported declarations because they bypass the
request. Instead, use a forwarding `AbstractStorageDecl::isSettableInSwift` method
that special-cases optional requirements.
2022-04-20 14:27:15 +03:00
Andrew Trick
f35e5e87a2 Merge pull request #42333 from atrick/fix-cast-ownership
Fix cast ownership to use the new doesCastPreserveOwnership API
2022-04-13 10:36:50 -07:00
Andrew Trick
a7c6a94ceb CheckedBranchInst now uses doesCastPreserveOwnership.
Use the new API that determines whether a cast preserves
ownership. Remove an old hack.
2022-04-12 22:23:17 -07:00
John McCall
5519749ade [NFC] Collect protocol decls, not type, in ExistentialLayout
Another thing that will be necessary for correctness with
compositions of parameterized protocols.
2022-04-11 22:15:16 -04:00
Meghana Gupta
3b8656cada Create phi argument for only non-empty direct result in epilog bb 2022-04-06 22:29:01 -07:00
Meghana Gupta
f65dac9824 Use addresses to represent inout/inout_aliasable when using opaque values 2022-04-06 22:26:09 -07:00
Andrew Trick
1a9c2ad8a3 Add doesCastPreserveOwnershipForType() to SIL/Utils/DynamicCasts.cpp
Added an AST helper in Types.h:

- isPotentiallyAnyObject()

This formalizes logic for when cast operations forward
ownership. Various OSSA optimization rely on this for
correctness. This fixes latent bugs throughout the optimizer.

I was compelled to fix this now because we want to make OSSA
optimizations across dynamic casts more aggressive. For example, we
want to optimize retain/release across enum formation.
2022-04-05 20:28:19 -07:00