Commit Graph

1326 Commits

Author SHA1 Message Date
Becca Royal-Gordon
6143b8379f Generate IR for @_objcImpl stored properties
Only works for trivial types right now because features related to initialization and deinitialization are seriously busted.
2022-10-18 17:21:56 -07:00
Becca Royal-Gordon
ba1ec90419 Generate IR for @_objcImpls
This commit begins to generate correct metadata for @_objcImplementation extensions:

• Swift-specific metadata and symbols are not generated.
• For main-class @_objcImpls, we visit the class to emit metadata, but visit the extension’s members.
• Includes both IR tests and executable tests, including coverage of same-module @objc subclasses, different-module @objc subclasses, and clang subclasses.

The test cases do not yet cover stored properties.
2022-10-18 17:21:56 -07:00
Holly Borla
38a2c8218b [Requirement] Rename RequirementKind::SameCount to SameShape. 2022-10-06 20:48:40 -07:00
Arnold Schwaighofer
d810b0f7e4 IRGen: Pass the elementType of pointers through to operations
In preparation for moving to llvm's opaque pointer representation
replace getPointerElementType and CreateCall/CreateLoad/Store uses that
dependent on the address operand's pointer element type.

This means an `Address` carries the element type and we use
`FunctionPointer` in more places or read the function type off the
`llvm::Function`.
2022-10-03 15:27:12 -07:00
Slava Pestov
5c32f2136e AST: Introduce RequirementKind::SameCount 2022-08-23 11:12:00 -04:00
Egor Zhdan
e3a321721d [cxx-interop] Synthesize conformances to CxxSequence
This makes ClangImporter automatically conform C++ sequence types to `Cxx.CxxSequence` protocol.

We consider a C++ type to be a sequence type if it defines `begin()` & `end()` methods that return iterators of the same type which conforms to `UnsafeCxxInputIterator`.
2022-08-17 16:06:37 +01:00
swift-ci
1d8e328b58 Merge remote-tracking branch 'origin/main' into rebranch 2022-08-11 02:13:04 -07:00
Slava Pestov
87871d7347 AST: Rename getOpenedArchetypeSignature() to getOpenedExistentialSignature() 2022-08-10 23:44:36 -04:00
swift-ci
71c6bd422e Merge remote-tracking branch 'origin/main' into rebranch 2022-08-09 13:14:18 -07:00
Slava Pestov
9d96ed940f AST: Rename 'canonical wrt. generic signature' to 'reduced'
We had two notions of canonical types, one is the structural property
where it doesn't contain sugared types, the other one where it does
not contain reducible type parameters with respect to a generic
signature.

Rename the second one to a 'reduced type'.
2022-08-09 12:46:31 -04:00
swift-ci
69e5a83e7d Merge remote-tracking branch 'origin/main' into rebranch 2022-08-02 08:35:16 -07:00
Arnold Schwaighofer
6ce452b928 IRGen: Add a list of class_ro_t referenced from generic class metadata patterns to a section __swift_rodatas
Put pointers to class_ro_t referenced from generic class patterns in a section __swift_rodatas such that they are discoverable by the linker.
The linker can then make the method lists contained in the class_ro_t relative like it can for objective c class metadata from non-generic swift classes.

rdar://66634459
2022-07-29 11:38:20 -07:00
swift-ci
88ac734e3e Merge remote-tracking branch 'origin/main' into rebranch 2022-07-22 12:54:48 -07:00
Pavel Yaskevich
4b99067c4b [IRGen] Mark protocol requirement descriptor for distributed thunk as async
Fixes a bug where descriptor for protocol requirement associated with
distributed thunk wasn't marked as `async` that results in ptrauth failures
because discriminator would be misaligned between requirement and witness.

Resolves: rdar://96520492
2022-07-21 14:33:06 -07:00
swift-ci
5706f48a31 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-20 19:14:34 -07:00
Pavel Yaskevich
498721c9df [TypeChecker] SE-360: Add support for if #unavailable
Lift a temporary restriction and make `if #available`
and `if #unavailable` behave consistently.
2022-07-20 13:26:43 -07:00
Pavel Yaskevich
225341e3d2 [Decl] Start storing and serializing "unavailability" bit per condition 2022-07-20 13:26:43 -07:00
swift-ci
a5e7bd7dd3 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-20 07:53:55 -07:00
Egor Zhdan
d85d2e9e75 [cxx-interop] Synthesize conformances to UnsafeCxxInputIterator
This teaches ClangImporter to synthesize conformances of C++ iterator types to `UnsafeCxxInputIterator` protocol from the `Cxx` module.

We consider a C++ type to be an iterator if it defines a subtype (usually a typedef or a using decl) called `iterator_category` that inherits from `std::input_iterator_tag`.

rdar://96235368
2022-07-20 11:44:25 +01:00
swift-ci
16a8ce5251 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-01 12:13:40 -07:00
John McCall
175f74d38f Implement symbolic demangling for extended existential metadata
Fixes rdar://96268090.
2022-07-01 11:21:53 -04:00
swift-ci
aadd41f994 Merge remote-tracking branch 'origin/main' into rebranch 2022-06-21 22:34:35 -07:00
Konrad `ktoso` Malawski
53168355f0 [Distributed] Explicitly ban a class extending AnyActor as well 2022-06-22 09:21:55 +09:00
swift-ci
55000f53be Merge remote-tracking branch 'origin/main' into rebranch 2022-06-17 10:15:14 -07:00
zoecarver
bdc37c9b46 [nfc][cxx-interop] Create and use custom metadata builder, visitor for foreign reference types. 2022-06-16 15:14:47 -07:00
zoecarver
81181a0359 [nfc][cxx-interop] Add a few comments and asserts 2022-06-16 15:02:41 -07:00
zoecarver
f972f664d3 [cxx-interop] Runtime support for foreign reference types. 2022-06-14 12:18:05 -07:00
Ben Barham
b521dc7c42 [next] Handle new ObjectFormatTypes
LLVM has added two new object format types, add them as unhandled for
now.
2022-05-05 16:25:10 -07:00
Ben Barham
04035b43b7 [next] Temporarily use getPointerElementType
`PointerType::getElementType` has been removed entirely as part of the
opaque pointers migration. Update to `getPointerElementType` for now
until we've also migrated.
2022-05-05 16:25:10 -07:00
swift_jenkins
0a7f41ea77 Merge remote-tracking branch 'origin/main' into next 2022-04-22 01:01:17 -07:00
John McCall
bd77714537 Unique extended existential shapes using the generalized AST type.
I wrote out this whole analysis of why different existential types
might have the same logical content, and then I turned around and
immediately uniqued existential shapes purely by logical content
rather than the (generalized) formal type.  Oh well.  At least it's
not too late to make ABI changes like this.

We now store a reference to a mangling of the generalized formal
type directly in the shape.  This type alone is sufficient to unique
the shape:

- By the nature of the generalization algorithm, every type parameter
  in the generalization signature should be mentioned in the
  generalized formal type in a deterministic order.

- By the nature of the generalization algorithm, every other
  requirement in the generalization signature should be implied
  by the positions in which generalization type parameters appear
  (e.g. because the formal type is C<T> & P, where C constrains
  its type parameter for well-formedness).

- The requirement signature and type expression are extracted from
  the existential type.

As a result, we no longer rely on computing a unique hash at
compile time.

Storing this separately from the requirement signature potentially
allows runtimes with general shape support to work with future
extensions to existential types even if they cannot demangle the
generalized formal type.

Storing the generalized formal type also allows us to easily and
reliably extract the formal type of the existential.  Otherwise,
it's quite a heroic endeavor to match requirements back up with
primary associated types.  Doing so would also only allows us to
extract *some* matching formal type, not necessarily the *right*
formal type.  So there's some good synergy here.
2022-04-21 23:47:01 -04:00
swift_jenkins
31f3c479a3 Merge remote-tracking branch 'origin/main' into next 2022-04-21 14:33:57 -07:00
Josh Soref
9fa14ca215 Spelling irgen (#42470)
* spelling: abstractable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: across

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: clazz

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: command

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: components

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: current

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: declared

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: discrimination

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: entities

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: except

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: existential

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: generic

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: initialization

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: initialize

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: inserted

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: instantiate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: instantiation

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: interfere

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: interferes

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: intrinsic

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: metadata

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: might

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: multiple

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: necessary

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: objective

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: occurrences

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: outlined

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: parameters

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: payload

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: rearchitecting

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: replaceable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: reverse

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: rewritable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: shareably

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: specializations

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: speedup

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: template

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: that

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: the

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: transferred

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: uninitialized

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: witness

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-21 14:02:03 -07:00
swift_jenkins
713eb3e1ed Merge remote-tracking branch 'origin/main' into next 2022-04-18 17:20:44 -07:00
Zoe Carver
786d6ed53d Merge pull request #42427 from zoecarver/ufo-metadata 2022-04-18 17:16:07 -07:00
zoecarver
491f556b77 [cxx-interop] Add basic support for using UFOs as members, etc.
This does not add support for using UFOs in generic contexts, this just emits their struct/field metadata as opaque pointers.
2022-04-18 14:47:02 -07:00
swift_jenkins
53f277d3de Merge remote-tracking branch 'origin/main' into next 2022-04-12 16:40:41 -07:00
John McCall
6385934d7e Metadata emission for extended existential type shapes 2022-04-12 14:52:47 -04:00
swift_jenkins
7cdc0520e3 Merge remote-tracking branch 'origin/main' into next 2022-04-04 10:41:57 -07:00
Pavel Yaskevich
ece63bbdbb Merge pull request #42104 from xedin/irgen-part-of-multi-opaque
[IRGen] Augment opaque type descriptor to support limited availability underlying types
2022-04-04 10:31:32 -07:00
swift_jenkins
bd8ab4d291 Merge remote-tracking branch 'origin/main' into next 2022-04-04 03:00:24 -07:00
swift-ci
6af73245c6 Merge pull request #42136 from ktoso/wip-identifiable-synthesis-fix
[Distributed] ID synthesis must be eager, or we run into issues in real projects
2022-04-04 02:51:22 -07:00
Pavel Yaskevich
4fe16f5bf5 [IRGen] Augment opaque type descriptor to support limited availability underlying types
If particular opaque type descriptor has multiple conditionally available
underlying types, emit a special type and witness reference accessors that
would be called at runtime to determine actual underlying type.
2022-04-01 13:11:35 -07:00
Konrad `ktoso` Malawski
c88951354f [Distributed] ID synthesis must be eager, or we run into issues in real projects 2022-04-01 18:47:25 +09:00
swift_jenkins
36ebaa2377 Merge remote-tracking branch 'origin/main' into next 2022-03-31 10:20:42 -07:00
Joe Groff
15c21920a1 Merge pull request #42101 from jckarter/async-let-reabstraction
SILGen: Emit async let entry points at correct abstraction level.
2022-03-31 10:07:01 -07:00
swift_jenkins
79d03d3d46 Merge remote-tracking branch 'origin/main' into next 2022-03-31 08:01:10 -07:00
Yuta Saito
26ba09738e Merge pull request #42094 from kateinoigakukun/katei/wasm-uncond-abs-func-ptr
[Wasm][IRGen] Add initial support for unconditional absolute function pointer
2022-03-31 23:50:30 +09:00
Joe Groff
d451203b7f SILGen: Emit async let entry points at correct abstraction level.
Avoid a reabstraction thunk every time an async let entry point is emitted,
by setting the context abstraction level while we emit the implicit closure.
Adjust some surrounding logic that breaks when we do this:

- When lowering a non-throwing function type against a throwing abstraction
  pattern, include the error type in the lowered substituted type. Async
  throwing and nonthrowing functions would require another thunk to convert
  away the throwingness of the async context, which would defeat the purpose.
- Adjust the code in IRGen that pads the initial context size for `async let`
  entry points so that it works when the entry point has not yet emitted, by
  marking the async function pointer to be padded later if it isn't defined
  yet.
2022-03-30 14:51:46 -07:00
swift_jenkins
7db48f624f Merge remote-tracking branch 'origin/main' into next 2022-03-30 14:01:58 -07:00