Commit Graph

726 Commits

Author SHA1 Message Date
Ellie Shin
72ee150982 Add -package-name flag
De/serialize package name in module binary
Resoles rdar://103531218, rdar://103531208
2022-12-19 14:33:44 -08:00
Michael Gottesman
9e44011e4d [sil] Add a new attribute called @closureCaptured to SILFunctionArguments that are closure capture arguments.
I am adding this to make it easy to determine if a SILFunction that is not inout
aliasable is captured. This is useful when emitting certain types of
diagnostics like I need to emit with move only.
2022-12-14 15:16:43 -08:00
Slava Pestov
38169afc06 SIL: Simplify SubstFunctionTypePatternVisitor 2022-12-08 20:07:16 -05:00
Doug Gregor
4ce0834c51 [Macros] Serialization support for macro declarations. 2022-11-28 18:33:09 -08:00
Xi Ge
29504bdd5f Merge branch 'main' into allowable-serialization 2022-11-28 12:36:52 -08:00
Holly Borla
c225fc428b Merge pull request #62228 from hborla/pack-element-generic-environment
[GenericEnvironment] Include original parameter packs in opened pack element signatures.
2022-11-28 15:34:35 -05:00
Xi Ge
5987654b3a Merge branch 'main' into allowable-serialization 2022-11-28 09:36:04 -08:00
Xi Ge
67bbab7e02 serialization: encode allowable client names in binary module format 2022-11-25 18:43:40 -08:00
Holly Borla
8ec5405a30 [GenericEnvironment] Store a substitution map for the outer generic parameters
of an opened pack element generic environment.
2022-11-23 11:17:05 -05:00
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
Allan Shortlidge
3da18b6e68 SIL: Serialize and deserialize has_symbol instructions. 2022-11-16 16:07:59 -08:00
Allan Shortlidge
0a24042cdd SIL: Introduce the has_symbol SIL instruction. 2022-11-16 16:07:26 -08:00
Pavel Yaskevich
9a02c79cbb [Serialization] Bump module format version due to @runtimeMetadata attribute 2022-11-15 21:06:34 -08:00
Slava Pestov
1e00c3107a Serialization: Support PackType and PackExpansionType 2022-11-12 02:13:54 -05:00
Alexis Laferrière
2854c1b3cb [Serialization] Write in the swiftmodule if it's built from a swiftinterface
This information will allow us to distinguish swiftmodule built from
source vs swiftinterface.
2022-10-27 18:51:28 -07:00
Slava Pestov
68514b10b5 AST: Introduce ElementArchetypeType 2022-10-21 21:55:35 -04:00
Becca Royal-Gordon
f2a0ab79c7 Add basic Sema support for @_objcImplementation
Does not validate members yet; nor does it emit different metadata.
2022-10-18 17:21:56 -07:00
Hamish Knight
6aa44a1754 [AST] Remove @_typeSequence attribute
This is no longer needed now that we have the
ellipsis spelling.
2022-10-14 15:40:13 +01:00
Slava Pestov
36c01e80cc Merge pull request #61537 from hborla/variadic-generics-terminology
[AST] Use consistent variadic generics terminology.
2022-10-13 16:20:43 -04:00
Nate Chandler
ab35362056 [SIL] Added new test_specification instruction.
The new instruction exists only to be used in tests.  The idea is to
specify tests that ought to be run "in the context" of the containing
function.
2022-10-11 17:15:13 -07:00
Holly Borla
c4b946195e [AST] Replace the "type sequence" terminology with "parameter pack". 2022-10-10 16:28:13 -07:00
Holly Borla
9bb837a241 [AST] Rename SequenceArchetype to PackArchetype. 2022-10-10 16:25:26 -07:00
Holly Borla
38a2c8218b [Requirement] Rename RequirementKind::SameCount to SameShape. 2022-10-06 20:48:40 -07:00
Erik Eckstein
66f07fe3da Swift SIL: rework function effects and add function side-effects
So far, function effects only included escape effects.
This change adds side-effects (but they are not computed, yet).
It also involves refactoring of the existing escape effects.
Also the SIL effect syntax changed a bit. Details are in docs/SIL.rst
2022-10-05 07:38:11 +02:00
Dario Rexin
210c68d8aa [SILOptimizer] Add prespecialization for arbitray reference types (#58846)
* [SILOptimizer] Add prespecialization for arbitray reference types

* Fix benchmark Package.swift

* Move SimpleArray to utils

* Fix multiple indirect result case

* Remove leftover code from previous attempt

* Fix test after rebase

* Move code to compute type replacements to SpecializedFunction

* Fix ownership when OSSA is enabled

* Fixes after rebase

* Changes after rebasing

* Add feature flag for layout pre-specialization

* Fix pre_specialize-macos.swift

* Add compiler flag to benchmark build

* Fix benchmark SwiftPM flags
2022-09-22 16:29:01 -07:00
Michael Gottesman
c54acc83e2 [move-only] Add the ability to specify a deinit at the SIL level for a move only type.
Specifically, we get an additional table like thing called sil_moveonlydeinit. It looks as follows:

sil_moveonlydeinit TYPE {
  @FUNC_NAME
}

It always has a single entry.
2022-09-20 15:19:31 -07:00
Pavel Yaskevich
bb4b29568c [Serialization] Bump module format due to new @typeWrapperIgnored attr 2022-09-14 17:14:24 -07:00
Erik Eckstein
8e2e7a73c5 SIL: make argument effects more readable in textual SIL
So far, argument effects were printed in square brackets before the function name, e.g.
```
sil [escapes !%0.**, !%1, %1.c*.v** => %0.v**] @foo : $@convention(thin) (@guaranteed T) -> @out S {
bb0(%0 : $*S, %1 : @guaranteed $T):
...
```

As we are adding more argument effects, this becomes unreadable.
To make it more readable, print the effects after the opening curly brace, and print a separate line for each argument. E.g.
```
sil [ossa] @foo : $@convention(thin) (@guaranteed T) -> @out S {
[%0: noescape **]
[%1: noescape, escape c*.v** => %0.v**]
bb0(%0 : $*S, %1 : @guaranteed $T):
...
```
2022-09-12 09:14:54 +02:00
Erik Eckstein
97b2354be6 SIL: add needsStackProtection flags for address_to_pointer and index_addr instructions.
Also add new "unprotected" variants of the `addressof` builtins:
* `Builtin.unprotectedAddressOf`
* `Builtin.unprotectedAddressOfBorrow`
2022-09-08 08:42:22 +02:00
Hamish Knight
b12015c343 [SIL] Introduce the increment_profiler_counter instruction
This is a dedicated instruction for incrementing a
profiler counter, which lowers to the
`llvm.instrprof.increment` intrinsic. This
replaces the builtin instruction that was
previously used, and ensures that its arguments
are statically known. This ensures that SIL
optimization passes do not invalidate the
instruction, fixing some code coverage cases in
`-O`.

rdar://39146527
2022-09-07 17:55:13 +01:00
QuietMisdreavus
f674b473ec introduce a @_documentation(...) attribute to influence SymbolGraphGen (#60242)
* add @_documentation(...) attribute to influence SymbolGraphGen

rdar://79049241
2022-09-06 14:12:42 -06:00
Pavel Yaskevich
38765fbd9a [AST] Add a new @typeWrapper attribute 2022-08-26 12:25:22 -07:00
Alex Lorenz
8de79390be [interop][SwiftToCxx] add @_expose(Cxx) attribute support
This attribute instructs the compiler that this declaration should be included in the generated C++ bindings
2022-08-24 10:14:07 -07:00
Slava Pestov
5c32f2136e AST: Introduce RequirementKind::SameCount 2022-08-23 11:12:00 -04:00
Nate Chandler
dc3106f3f2 [Serialization] Explicit function arg lifetimes. 2022-08-21 21:44:51 -07:00
Michael Gottesman
3e52007562 [builtin] Remove "unsafeGuaranteed" and related code since Unmanaged now has an Ownership SSA based implementation that works completely in SILGen.
This isn't used in the stdlib anymore as well.
2022-08-21 01:22:36 -07:00
Allan Shortlidge
40eb1422bb IRGen/SIL: Fix IR linkage computation for inlined function references from modules imported @_weakLinked.
Include the parent `ModuleDecl` when serializing a `SILFunction` so that it is available on deserialized functions even though the full `DeclContext` is not present. With the parent module always available we can reliably compute whether the `SILFunction` comes from a module that was imported `@_weakLinked`.

Serialize the `DeclContext` member of `SILFunction` so that it can be used to look up the module that a function belongs to in order to compute weak import status.

Resolves rdar://98521248
2022-08-19 09:56:45 -07:00
Slava Pestov
b36f37cc72 Serialization: Preserve identity of opened generic environments
We used to create a new environment for each opened archetype, which is
incorrect when deserializing a nested type of another opened archetype.
2022-08-15 13:59:12 -04:00
Michael Gottesman
5baf2af88a [sil] Add a new instruction called explicit_copy_addr.
This is exactly like copy_addr except that it is not viewed from the verifiers
perspective as an "invalid" copy of a move only value. It is intended to be used
in two contexts:

1. When the move checker emits a diagnostic since it could not eliminate a copy,
we still need to produce valid SIL without copy_addr on move only types since we
will hit canonical SIL eventually even if we don't actually codegen the SIL. The
pass can just convert said copy_addr to explicit_copy_addr and everyone is
happy.

2. To implement the explicit copy function for address only types.
2022-08-11 11:40:53 -07:00
Artem Chikin
4e2c1d16f6 Add '@_alwaysEmitConformanceMetadata' protocol attribute
This attribute will, in the near future, be used to inform IRGen that a nominal type that conforms to such protocol must have its type metadata always emitted into the binary, regardless of whether it is used/public.
2022-08-04 14:19:33 -07:00
Pavel Yaskevich
8185db433a [Serialization] Add a "unavailable" bit to conditional substitution record
A step towards supporting different opaque result type produced by a
`if #unavailable` block.
2022-07-20 13:26:41 -07:00
Slava Pestov
ac5b1df5aa ASTMangler: Don't consider @_originallyDefinedIn when mangling local type discriminators
Local types are not ABI, and the only time we care about the mangling here is
when we look them up using the DWARF mangling in debug info, which doesn't
respect @_originallyDefinedIn either.

Fixes https://github.com/apple/swift/issues/59773.
2022-07-19 12:22:29 -04:00
Michael Gottesman
198b974622 Merge pull request #59859 from gottesmm/pr-276c4e4220a25490659a285e8b94a36bd28ffede
[no-implicit-copy] Rename SILMoveOnlyType -> SILMoveOnlyWrappedType.
2022-07-01 23:17:43 -07:00
Michael Gottesman
8f3fe63fed [no-implicit-copy] Rename SILMoveOnlyType -> SILMoveOnlyWrappedType.
Since I am beginning to prepare for adding real move only types to the language,
I am renaming everything that has to do with copyable types "move only wrapped"
values instead of move only. The hope is this reduces/prevents any confusion in
between the two.
2022-07-01 17:26:13 -07:00
Pavel Yaskevich
b2b1efd268 [Distributed] Decl: Add a new distributed-thunk bit
The flag is used to distinguish between regular functions/accessors
and synthesized distributed thunks.
2022-06-29 14:49:10 -07:00
Holly Borla
429488f6c9 [Sema] Use ExistentialType for Any and AnyObject. 2022-06-17 18:29:15 -07:00
Becca Royal-Gordon
9b5f89963b [NFC] Serialize ObjC selectors for protocols
The ObjCMethodLookupTable for protocols was not being serialized and rebuilt on load, so NominalTypeDecl::lookupDirect() on selectors was not working correctly for deserialized types. Correct this oversight.
2022-06-16 14:07:49 -07:00
Doug Gregor
25a7988982 Teach witness thunks to hop to the actor when needed.
When a synchronous, actor-isolated declaration witnesses an
asynchronous, not-similarly-isolated requirement, emit an actor hop
within the witness thunk to ensure that we properly enter the context
of the actor.

Fixes #58517 / rdar://92881539.
2022-06-14 16:45:28 -07:00
Michael Gottesman
c66061a783 [moveOnly] Add a new SIL specific AST type called SILMoveOnly.
It can only be used in SIL contexts to express that a wrapped type is
MoveOnly.
2022-06-03 11:27:16 -07:00
Mike Ash
979afddb94 [Serialization] Bump SWIFTMODULE_VERSION_MINOR to avoid conflict with SDK's swiftmodule. 2022-05-18 14:55:51 -07:00