Commit Graph

2441 Commits

Author SHA1 Message Date
Joe Groff
4eb68596af SIL: Tweak ownership of continuation instructions.
Treating a trivial type as having ownership seems only to confuse the ownership verifier.
The structural property we're trying to enforce here (that a continuation is always
consumed by an `await` locally) can be enforced by flow-sensitive verification without
ownership.
2020-10-30 11:38:05 -07:00
swift_jenkins
fa32dc6ba7 Merge remote-tracking branch 'origin/main' into next 2020-10-30 00:09:25 -07:00
John McCall
e35f077a9b Merge pull request #33349 from ellishg/master
[IRGen] Call objc_direct methods correctly
2020-10-30 03:03:54 -04:00
swift_jenkins
78488e165a Merge remote-tracking branch 'origin/main' into next 2020-10-29 20:18:45 -07:00
Doug Gregor
33452e1074 Merge pull request #34503 from DougGregor/async-type-lower-void
[async type lowering] Handle Void return from @objc async methods.
2020-10-29 20:13:31 -07:00
swift_jenkins
d73adae0f2 Merge remote-tracking branch 'origin/main' into next 2020-10-29 18:01:19 -07:00
Alejandro Alonso
424802fb34 Revert SE-0283 (#34492)
Reverted despite build failures.
2020-10-29 17:32:06 -07:00
Doug Gregor
f30778ff8c [async type lowering] Handle Void return from @objc async methods. 2020-10-29 17:03:21 -07:00
swift_jenkins
8ce22b7cba Merge remote-tracking branch 'origin/main' into next 2020-10-29 08:56:22 -07:00
Joe Groff
096828e5ab Merge pull request #34358 from jckarter/imported-async-type-lowering
Type lowering and SILGen for imported ObjC async decls.
2020-10-29 08:46:16 -07:00
swift_jenkins
d4228b4192 Merge remote-tracking branch 'origin/main' into next 2020-10-29 00:56:20 -07:00
Erik Eckstein
f18a9b8ee8 [Concurrency] SIL: add hop_to_executor instruction
This instructions ensures that all instructions, which need to run on the specified executor actually run on that executor.
For details see the description in SIL.rst.
2020-10-28 18:17:43 +01:00
swift_jenkins
e1929b6042 Merge remote-tracking branch 'origin/main' into next 2020-10-28 02:51:42 -07:00
Erik Eckstein
e8e613bd6a RCIdentity: fix another case of not-RC-identity-preserving casts.
When casting from existentials to class - and vice versa - it can happen that a cast is not RC identity preserving (because of potential bridging).
This also affects mayRelease() of such cast instructions.
For details see the comments in SILDynamicCastInst::isRCIdentityPreserving().

This change also includes some refactoring: I centralized the logic in SILDynamicCastInst::isRCIdentityPreserving().

rdar://problem/70454804
2020-10-28 08:10:41 +01:00
David Smith
0180aca9fc Merge branch 'main' into david/fix-merge-conflict 2020-10-27 13:05:20 -07:00
Joe Groff
577f83a260 SIL: Type lowering for imported ObjC async decls.
When lowering the type for `@objc` entry points of async declarations, restore
the original ObjC signature with the completion handler argument in the lowered
SIL type.
2020-10-27 09:00:45 -07:00
Alejandro Alonso
84e5fd2137 Merge pull request #28833 from Azoy/void-is-equatable
[SE-0283] Implement Equatable, Comparable, and Hashable conformance for Tuples
2020-10-26 13:53:29 -04:00
Slava Pestov
527fb5dd31 SIL: Enum protocol witness thunks should be [serializable] 2020-10-24 03:09:40 -04:00
Slava Pestov
442fc68453 Merge pull request #34419 from slavapestov/type-of-self-protocol-convenience-init
DI: Fix crash when value_metatype was used with a non-class 'self' type
2020-10-24 02:12:35 -04:00
Slava Pestov
360e406d3a SIL: Rename SILFunction::hasSelfMetadataParam()/getSelfMetadataArgument()
These are only for class types and are related to the usage of the
DynamicSelfType, so rename them to {has,get}DynamicSelfMetadata().
2020-10-23 21:35:11 -04:00
Michael Gottesman
8c5737d1d5 [ownership] Change thin_to_thick function to always produce a none value.
It can already only accept values with none ownership and the merging of
ownership around ownership phis ensure that if we phi this with a partial_apply
or the like, we get the appropriate ownership on any such ownership phi values.

We are now out of SILGen emitting fewer destroy_value unnecessarily on
thin_to_thick functions. This changed some codegen and also forced me to update
some tests/fix AutoDiff.

I also deleted the DebugInfo test mandatoryinlining-wrongdebugscope.swift since:

1. It was depending on these destroys being there.

2. Given the need to improve the test @aprantl suggested I just eliminate it
solving the test failure for me.
2020-10-23 17:49:12 -07:00
Ellis Hoag
3aa081c56e [IRGen] Call objc_direct methods correctly 2020-10-23 11:54:07 -05:00
Azoy
e60ef84bd2 Implement Tuple Equatable Conformance 2020-10-22 18:24:28 -04:00
Azoy
f21a306ae5 [AST] Introduce BuiltinProtocolConformance 2020-10-22 18:24:27 -04:00
Andrew Trick
f31296d63b Fix isRCIdentityPreservingCast to handle trivial-to-reference casts
And add assertions.
2020-10-20 16:57:24 -07:00
swift-ci
7e16e3b4d2 Merge pull request #30630 from martinboehme/cxx-constructors 2020-10-20 14:37:29 -07:00
Joe Groff
aef8f503d8 Merge pull request #34210 from jckarter/async-await-sil-verifier
SIL: Verify invariants of async_continuation instructions.
2020-10-19 15:06:55 -07:00
Andrew Trick
fd8f723f60 Merge pull request #34126 from atrick/add-accesspath
Add an AccessPath abstraction and formalize memory access
2020-10-19 10:17:27 -07:00
Andrew Trick
b272dc5e1a Cache 'isLet' within AccessedStorage.
Compute 'isLet' from the VarDecl that is available when constructing
AccessedStorage so we don't need to recover the VarDecl for the base
later.

This generally makes more sense and is more efficient, but it will be
necessary when we look past class casts when finding the reference root.
2020-10-16 15:00:10 -07:00
Andrew Trick
85ff15acd3 Add indexTrieRoot to the SILModule to share across Analyses.
...and avoid reallocation.

This is immediately necessary for LICM, in addition to its current
uses. I suspect this could be used by many passes that work with
addresses. RLE/DSE should absolutely migrate to it.
2020-10-16 15:00:09 -07:00
Erik Eckstein
9a10ec7d58 SILBuilder: add an API to insert _after_ an instruction.
... and use that API in FullApplySite::insertAfterInvocation.

Also change FullApplySite::insertAfterInvocation/insertAfterFullEvaluation to directly pass a SILBuilder instead of just an insertion point to the callback.
This makes more sense (given the function names) and simplifies the usages.

It's a NFC.
2020-10-16 17:25:08 +02:00
swift_jenkins
25160da347 Merge remote-tracking branch 'origin/main' into next 2020-10-14 13:47:25 -07:00
Alexis Laferrière
e509d6883a Revert "[Sema] Fix availability checking in inlinable code" 2020-10-14 10:52:11 -07:00
swift_jenkins
8fddbcef4d Merge remote-tracking branch 'origin/main' into next 2020-10-13 09:16:15 -07:00
Alexis Laferrière
9249186b15 Merge pull request #33855 from xymus/availability-inlinable
[Sema] Fix availability checking in inlinable code
2020-10-13 09:14:57 -07:00
swift_jenkins
ac24c24279 Merge remote-tracking branch 'origin/main' into next 2020-10-13 08:06:23 -07:00
Arnold Schwaighofer
d6d79c66aa Merge two fields into a PointerUnion in SILDeclRef to save space 2020-10-12 09:19:29 -07:00
Arnold Schwaighofer
2a2cf91dcd Add support for marking a _specialize attribute as SPI
```
  @_specialize(exported: true, spi: SPIGroupName, where T == Int)
  public func myFunc() { }
```

The specialized entry point is only visible for modules that import
using `_spi(SPIGroupName) import ModuleDefiningMyFunc `.

rdar://64993425
2020-10-12 09:19:29 -07:00
Arnold Schwaighofer
b994bf3191 Add support for _specialize(exported: true, ...)
This attribute allows to define a pre-specialized entry point of a
generic function in a library.

The following definition provides a pre-specialized entry point for
`genericFunc(_:)` for the parameter type `Int` that clients of the
library can call.

```
@_specialize(exported: true, where T == Int)
public func genericFunc<T>(_ t: T) { ... }
```

Pre-specializations of internal `@inlinable` functions are allowed.

```
@usableFromInline
internal struct GenericThing<T> {
  @_specialize(exported: true, where T == Int)
  @inlinable
  internal func genericMethod(_ t: T) {
  }
}
```

There is syntax to pre-specialize a method from a different module.

```
import ModuleDefiningGenericFunc

@_specialize(exported: true, target: genericFunc(_:), where T == Double)
func prespecialize_genericFunc(_ t: T) { fatalError("dont call") }

```

Specially marked extensions allow for pre-specialization of internal
methods accross module boundries (respecting `@inlinable` and
`@usableFromInline`).

```
import ModuleDefiningGenericThing
public struct Something {}

@_specializeExtension
extension GenericThing {
  @_specialize(exported: true, target: genericMethod(_:), where T == Something)
  func prespecialize_genericMethod(_ t: T) { fatalError("dont call") }
}
```

rdar://64993425
2020-10-12 09:19:29 -07:00
Joe Groff
3364c51b1d SIL: Verify invariants of async_continuation instructions.
- Enforce types of continuations and resume/error BBargs for await
- Can't access the continuation again or exit the function mid-suspend
2020-10-09 14:57:38 -07:00
zoecarver
5774610eaf [cxx-interop] Fix patch formatting with clang-format.
Fix all formatting of the changes made by this patch.
2020-10-09 10:42:55 -07:00
zoecarver
f04de9f128 [cxx-interop] Skip metatypes when lowering C++ constructor SIL function type.
When lowering a C++ constructor's function type to a SIL function type,
skip over the "self" metatype parameter.
2020-10-09 10:42:54 -07:00
Martin Boehme
a5e953b690 Add support for calling C++ constructors.
Because C++ constructors always take a `this` pointer to the object to
be initialized, we mark the SIL function return type with the `@out`
attribute.

On the IRGen side, we retrofit support for formal indirect return values as
well as thin metatypes.
2020-10-09 10:42:46 -07:00
Alexis Laferrière
39ee5916bd [SIL] Don't print availability for unreachable/unavailable functions 2020-10-09 10:40:21 -07:00
swift_jenkins
eeb14d44d3 Merge remote-tracking branch 'origin/main' into next 2020-10-06 08:03:33 -07:00
nate-chandler
515f0db4ed Merge pull request #34141 from nate-chandler/concurrency/irgen/signature
[Concurrency] Async CC, part 1.
2020-10-06 07:43:02 -07:00
swift_jenkins
9093b7eab8 Merge remote-tracking branch 'origin/main' into next 2020-10-05 07:57:58 -07:00
Arnold Schwaighofer
913543e065 Merge pull request #34077 from aschwaighofer/fix_hasOpaqueArchetypePropertiesOrCases
Fix TypeBase::hasOpaqueArchetypePropertiesOrCases for recursive types
2020-10-05 07:07:15 -07:00
Nate Chandler
59bb1fc235 [Concurrency] Pass "async" into SILFunctionTypes.
This reverts commit 3a48396110d2639d7b90970bc0369a559adbc0c1.
2020-10-02 13:54:05 -07:00
swift_jenkins
519fcf2dfa Merge remote-tracking branch 'origin/main' into next 2020-10-02 13:20:14 -07:00