Commit Graph

257 Commits

Author SHA1 Message Date
Pavel Prokofyev
f8baffafc8 [NFC][AutoDiff] Pass AutoDiffConfig by const ref. (#37074) 2021-04-27 13:40:18 -07:00
Ben Barham
c54c9c7079 [Gardening] Extract basic source info structs from RawComment.h 2021-04-14 10:05:27 +10:00
Holly Borla
21a86b5d2f [NFC][Property Wrappers] Split PropertyWrapperBackingPropertyInfoRequest into
two separate requests - one to synthesize the auxiliary declarations, and
another to compute how the backing storage is initialized.
2021-03-19 13:03:13 -07:00
Holly Borla
13692fefde [Property Wrappers] Store property wrapper "init from projection" expressions
in PropertyWrapperBackingPropertyInfo.
2021-02-25 18:35:14 -08:00
Richard Wei
e494df2ee6 [AutoDiff] Add differentiability kind to differentiability witnesses and mangle them.
Differentiability witnesses are now keyed by the original function name, the differentiability kind, and the autodiff config.

Updated SIL syntax:
```
differentiability-kind ::= 'forward' | 'reverse' | 'normal' | 'linear'
sil-differentiability-witness ::=
    'sil_differentiability_witness'
    sil-linkage?
    '[' differentiability-kind ']'
    '[' 'parameters' sil-differentiability-witness-function-index-list ']'
    '[' 'results' sil-differentiability-witness-function-index-list ']'
    generic-parameter-clause?
    sil-function-name ':' sil-type
    sil-differentiability-witness-body?
sil-instruction ::=
    'differentiability_witness_function'
    '[' sil-differentiability-witness-function-kind ']'
    '[' differentiability-kind ']'
    '[' 'parameters' sil-differentiability-witness-function-index-list ']'
    '[' 'results' sil-differentiability-witness-function-index-list ']'
    generic-parameter-clause?
    sil-function-name ':' sil-type
```
```console
sil_differentiability_witness [reverse] [parameters 0 1] [results 0] <T where T: Differentiable> @foo : <T> $(T) -> T
differentiability_witness_function [vjp] [reverse] [parameters 0] [results 0] <T where T: Differentiable> @foo : $(T) -> T
```

New mangling:
```swift
  global ::= global generic-signature? 'WJ' DIFFERENTIABILITY-KIND INDEX-SUBSET 'p' INDEX-SUBSET 'r' // differentiability witness
```
```console
$s13test_mangling3fooyS2f_S2ftFWJrSpSr ---> reverse differentiability witness for test_mangling.foo(Swift.Float, Swift.Float, Swift.Float) -> Swift.Float with respect to parameters {0} and results {0}
```

Resolves rdar://74380324.
2021-02-17 18:27:42 -05:00
Steven Wu
02c41656be swift-api-extract to generate JSON API information
Add a new swift-frontend driver option that extract APIs in the swift
module and print in JSON format. This is to allow tooling to understand
and process swift APIs without the need to be a swift compiler or
understand swift module/AST.
2021-02-15 15:04:52 -08:00
Doug Gregor
2493dc9f0f Eliminate more ABI vestigates of marker protocols 2021-02-03 00:09:21 -08:00
swift-ci
4358548c93 Merge remote-tracking branch 'origin/main' into rebranch 2021-01-28 10:12:31 -08:00
Cyndy Ishida
4e1987fdf4 [TBDGen] don't add "_" when adding objc classes to swift TBD (#35621)
This entry is incorrect and causes tapi pedantic check to fail.
<rdar://problem/73664795>
2021-01-28 10:04:33 -08:00
swift-ci
89c8005a80 Merge remote-tracking branch 'origin/main' into rebranch 2021-01-27 15:52:25 -08:00
Slava Pestov
c79de40225 IRGen: Emit async function pointers for resilient class and protocol dispatch thunks
This adds new kinds of link entities corresponding to the three
dispatch thunk link entity kinds:

- DispatchThunkAsyncFunctionPointer
- DispatchThunkInitializerAsyncFunctionPointer
- DispatchThunkAllocatorAsyncFunctionPointer
2021-01-27 15:21:22 -05:00
swift-ci
95097d8402 Merge remote-tracking branch 'origin/main' into rebranch 2021-01-19 20:12:19 -08:00
Nate Chandler
2e880af6a0 [TBDGen] Use effective linkage for class member async function pointers.
Previously, the "bare" linkage of a link entity was used to determine
whether to put an async function pointer into the tbd.  That did not
match the mechanism by which the linkage was determined in IRGen.
There, the linkage is the "_effective_" linkage (i.e. the value returned
from SILFunction::getEffectiveSymbolLinkage).

Here, whether to put the async function pointer corresponding to a class
method is determined on the basis of that effective linkage.

rdar://problem/73203508
2021-01-19 08:45:04 -08:00
swift_jenkins
797e165962 Merge remote-tracking branch 'origin/main' into next 2021-01-07 09:31:18 -08:00
Richard Wei
ffe6064101 Mangle derivative functions and linear maps.
- `Mangle::ASTMangler::mangleAutoDiffDerivativeFunction()` and `Mangle::ASTMangler::mangleAutoDiffLinearMap()` accept original function declarations and return a mangled name for a derivative function or linear map. This is called during SILGen and TBDGen.
- `Mangle::DifferentiationMangler` handles differentiation function mangling in the differentiation transform. This part is necessary because we need to perform demangling on the original function and remangle it as part of a differentiation function mangling tree in order to get the correct substitutions in the mangled derivative generic signature.

A mangled differentiation function name includes:
- The original function.
- The differentiation function kind.
- The parameter indices for differentiation.
- The result indices for differentiation.
- The derivative generic signature.
2021-01-07 02:21:10 -08:00
swift_jenkins
60c7eaecdd Merge remote-tracking branch 'origin/main' into next 2021-01-05 15:17:44 -08:00
Slava Pestov
e675bee26c AST: Split off DependencyCollector.h from EvaluatorDependencies.h
Also remove some unnecessary #includes from DependencyCollector.h,
which necessitated adding #includes in various other files.
2020-12-23 00:00:25 -05:00
swift_jenkins
3c300ebc33 Merge remote-tracking branch 'origin/main' into next 2020-12-15 14:01:19 -08:00
Nate Chandler
4a515c6dd5 [TBDGen] @asyncHandlers don't have public async function pointers.
Previously, an async function pointer symbol was being emitted into the
TBD for all AbstractFunctionDecls which returned true for
"hasAsynContext", i.e. both those that were async and those which were
asnycHandlers.  That was not correct because the async function portion
of an asyncHandler is not ABI.  Here, that mistake is fixed by only
emitting this symbol for functions which are annotated async (i.e. those
for which "hasAsync" returns true).

rdar://problem/72329062
2020-12-15 10:24:42 -08:00
swift_jenkins
d5e763ae26 Merge remote-tracking branch 'origin/main' into next 2020-11-20 05:50:55 -08:00
Xiaodi Wu
59f1f10b77 Merge pull request #34799 from kkshinkai/main
Fix misspellings
2020-11-20 08:25:54 -05:00
Kk Shinkai
a0f0747283 Fix misspellings 2020-11-18 11:47:16 +08:00
swift_jenkins
c3c8e6dd18 Merge remote-tracking branch 'origin/main' into next 2020-11-13 09:58:56 -08:00
Nate Chandler
ed9efa2a89 [TBDGen] Add async function pointers.
In order to call async functions, instances of the AsyncFunctionPointer
struct must be used.  If those functions are exported from a module, the
AsyncFunctionPointer by means of which the function is to be called must
be exported as well.

For now, the symbol is exported by manually appending the relevant
suffix to the mangled name of the function.
2020-11-12 18:20:10 -08:00
swift_jenkins
f2f39ea23d Merge remote-tracking branch 'origin/main' into next 2020-11-10 12:13:53 -08:00
Saleem Abdulrasool
7c968c6ccf AST: support availability on Windows
Enable Windows specific availability annotations in Swift.
2020-11-09 20:03:52 -08:00
swift_jenkins
ac24c24279 Merge remote-tracking branch 'origin/main' into next 2020-10-13 08:06:23 -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
swift_jenkins
296baa5fc3 Merge remote-tracking branch 'origin/master' into master-next 2020-09-10 11:34:23 -07:00
3405691582
b59910ef5b Add OpenBSD to PlatformKinds.def.
In #31686 changes were introduced to ensure that capacity was stored in
the ManagedBuffer allocation, and @lorentey sugested that as a stopgap
measure for addressing the lack of platform malloc introspection on
OpenBSD, we use Swift availability attributes instead on the relevant
parts of ManagedBuffer and friends.

Since platform availability symbols must be specifically set up to be
used, this commit does so in advance of the above change.
2020-09-09 18:57:26 -04:00
Nathan Hawes
c453ddf758 Manually merge remote-tracking branch 'upstream/master' into HEAD
Conflicts:
	include/swift/AST/PrettyStackTrace.h
2020-08-17 09:45:56 -07:00
Hamish Knight
aa868085cd Allow TBDGenVisitor to visit non-public symbols
Add a `PublicSymbolsOnly` option to TBDGenOptions
that controls whether to include public-only
symbols. This is `true` by default, but will be
disabled for symbol mapping.
2020-08-13 10:21:38 -07:00
Hamish Knight
96f3b8759d Introduce SymbolSourceMapRequest
Add a request that leverages the TBDGenVisitor to
produce a mapping from a mangled symbol name to
the SIL or IR entity that emits it. This will be
used to enable lazy compilation where only a
specific set of symbols need to be emitted.
2020-08-13 10:21:38 -07:00
Hamish Knight
f6976d8620 Have TBDGenDescriptor take ownership of TBDGenOptions
This is necessary for caching TBD requests.
2020-08-13 10:21:37 -07:00
Nathan Hawes
898c20ee2b Manually merge remote-tracking branch 'upstream/master' into github-m-to-mn 2020-07-28 10:37:01 -07:00
Hamish Knight
c5cd19a5cb [TBDGen] Split off symbol collection from TBD file generation
Refactor `TBDGenVisitor` to accept a callback for
when it discovers a symbol, and split off public
symbol gathering into `PublicSymbolsRequest` such
that we don't need to unnecessarily also build a
TBD file which we immediately throw away.
2020-07-24 15:49:07 -07:00
Hamish Knight
c74057a20d [TBDGen] Factor out some visiting logic
Factor out the visiting logic for `FileUnit` and
`TBDGenDescriptor` onto the `TBDGenVisitor`.
2020-07-24 15:49:07 -07:00
swift_jenkins
3d48f4cec5 Merge remote-tracking branch 'origin/master' into master-next 2020-07-21 23:06:39 -07:00
marcrasi
493b4a8ef8 Merge pull request #32916 from marcrasi/remove-gen-sig-more-places
[AutoDiff] remove all-concrete gen sig from more places
2020-07-21 22:51:41 -07:00
swift_jenkins
f7a1baff06 Merge remote-tracking branch 'origin/master' into master-next 2020-07-21 13:30:27 -07:00
Slava Pestov
4a47190335 AST: Allow @_fixed_layout protocols
A @_fixed_layout protocol exposes its witness table layout to
clients, which prevents re-ordering of requirements or adding
new requiremenst with a default.

When library evolution is enabled, we still emit method
descriptors even for @_fixed_layout protocols; this allows a
previously-resilient protocol to become @_fixed_layout as long
as the published layout matches the resilient layout in all
previously-shipped versions of the library.
2020-07-20 23:53:41 -04:00
Varun Gandhi
ee10198e9a Manually merge master into master-next.
Fixed merge conflicts in:
- lib/ClangImporter/ClangImporter.cpp
- lib/ClangImporter/ImportType.cpp
- lib/Frontend/CompilerInvocation.cpp
- lib/Serialization/ModuleFile.cpp
- lib/TBDGen/TBDGen.cpp
2020-07-15 21:36:13 -07:00
Hamish Knight
b012165356 Add missing std::string conversion 2020-07-15 18:03:27 -07:00
Hamish Knight
56929fdaaa [TBDGen] Return a vector of symbols instead of set
A couple of clients are iterating over the result,
so switch to a vector to ensure we don't
accidentally introduce any non-determinism.
2020-07-15 17:48:51 -07:00
Hamish Knight
0e97ecedd6 [TBDGen] Make enumeratePublicSymbols more functional
Instead of taking an out parameter, have it return
the set directly. Also coalesce the two overloads
into a single overload that takes a
`TBDGenDescriptor`.
2020-07-15 17:45:56 -07:00
Marc Rasi
7191c9c21d [AutoDiff] remove all-concrete gen sig from more places 2020-07-15 17:28:14 -07:00
Hamish Knight
c354b0faa1 [TBDGen] Return a vector of symbols instead of set
A couple of clients are iterating over the result,
so switch to a vector to ensure we don't
accidentally introduce any non-determinism.
2020-07-13 20:42:54 -07:00
Hamish Knight
b5f9e05255 [TBDGen] Make enumeratePublicSymbols more functional
Instead of taking an out parameter, have it return
the set directly. Also coalesce the two overloads
into a single overload that takes a
`TBDGenDescriptor`.
2020-07-13 20:42:53 -07:00
Nathan Hawes
244dc4a768 [AST] Rename PlatformKind::OSX to PlatformKind::macOS
Because the names are coming from a .def file used for printing too, this
simplifies the printing logic as well.
2020-07-08 16:29:31 -07:00
Dan Zheng
7b54e8b14e [TBDGen] NFC: print duplicate symbol name before assertion. (#32649)
This facilitates debugging.
2020-07-05 14:28:58 -07:00