Commit Graph

24822 Commits

Author SHA1 Message Date
Michael Gottesman
94cd804eed Merge pull request #29680 from gottesmm/pr-5cabc7ee4a3e006145b5d4716d59ba51ba0c547b
[builtin] Add a new SIL builtin convertStrongToUnsafeUnowned()
2020-02-07 14:52:55 -08:00
swift-ci
fda8e977e1 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-07 14:24:32 -08:00
Dan Zheng
a174243159 [AutoDiff upstream] Add SIL differentiability witness IRGen. (#29704)
SIL differentiability witnesses are a new top-level SIL construct mapping
an "original" SIL function and derivative configuration to derivative SIL
functions.

This patch adds `SILDifferentiabilityWitness` IRGen.

`SILDifferentiabilityWitness` has a fixed `{ i8*, i8* }` layout:
JVP and VJP derivative function pointers.

Resolves TF-1146.
2020-02-07 14:10:34 -08:00
Michael Gottesman
f7f98887d4 [builtin] Add a new SIL builtin convertUnownedUnsafeToGuaranteed()
(BaseT, @inout @unowned(unsafe) T) -> @guaranteed T

The reason for the weird signature is that currently the Builtin infrastructure
does not handle results well. Also, note that we are not actually performing a
call here. We are SILGening directly so we can create a guaranteed result.

The intended semantics is that one passes in a base value that guarantees the
lifetime of the unowned(unsafe) value. The builtin then:

1. Borrows the base.
2. Loads the trivial unowned (unsafe), converts that value to a guaranteed ref
   after unsafely unwrapping the optional.
3. Uses mark dependence to tie the lifetimes of the guaranteed base to the
   guaranteed ref.

I also updated my small UnsafeValue.swift test to make sure we get the codegen
we expect.
2020-02-07 13:08:34 -08:00
Michael Gottesman
1137c00196 [builtin] Add a new SIL builtin convertStrongToUnownedUnsafe()
The signature is:

(T, @inout @unowned(unsafe) Optional<T>) -> ()

The reason for the weird signature is that currently the Builtin infrastructure
does not handle results well.

The semantics of this builtin is that it enables one to store the first argument
into an unowned unsafe address without any reference counting operations. It
does this just by SILGening the relevant code. The optimizer chews through this
code well, so we get the expected behavior.

I also included a small proof of concept to validate that this builtin works as
expected.
2020-02-07 13:07:05 -08:00
Michael Gottesman
8841d6d703 [gardening] Add a comment to BUILTIN_MISC_OPERATION_WITH_SILGEN that explains how to use it/contrasts with BUILTIN_SIL_OPERATION. 2020-02-07 12:58:15 -08:00
swift-ci
f52e3735b1 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-07 12:03:35 -08:00
Saleem Abdulrasool
3fb1707fd1 SIL: add missing newline (NFC)
This fixes an accidental joining of lines.
2020-02-07 10:11:40 -08:00
swift-ci
d746375513 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-07 09:43:31 -08:00
Dan Zheng
7b064a6500 [AutoDiff upstream] Add SIL differentiability witness serialization. (#29642)
SIL differentiability witnesses are a new top-level SIL construct mapping
an "original" SIL function and derivative configuration to derivative SIL
functions.

This patch adds `SILDifferentiabilityWitness` serialization/deserialization.

Resolves TF-1136.
2020-02-07 09:35:16 -08:00
swift-ci
0cbfcbb517 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-06 21:44:26 -08:00
Robert Widmann
1ed846d852 Merge pull request #25696 from kelvin13/comparable-enums
synthesized comparable for enums
2020-02-06 21:38:36 -08:00
swift-ci
c8671f672b Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-06 21:04:42 -08:00
John McCall
b46938924f Merge pull request #29670 from rjmccall/ciliainig-teyepee-sieeriiieaileiizieaitieieoiniie
Implement Swift serialization and deserialization of Clang types
2020-02-07 00:04:30 -05:00
John McCall
faee21b626 Implement Swift serialization and deserialization of Clang types.
As part of this, we have to change the type export rules to
prevent `@convention(c)` function types from being used in
exported interfaces if they aren't serializable.  This is a
more conservative version of the original rule I had, which
was to import such function-pointer types as opaque pointers.
That rule would've completely prevented importing function-pointer
types defined in bridging headers and so simply doesn't work,
so we're left trying to catch the unsupportable cases
retroactively.  This has the unfortunate consequence that we
can't necessarily serialize the internal state of the compiler,
but that was already true due to normal type uses of aggregate
types from bridging headers; if we can teach the compiler to
reliably serialize such types, we should be able to use the
same mechanisms for function types.

This PR doesn't flip the switch to use Clang function types
by default, so many of the clang-function-type-serialization
FIXMEs are still in place.
2020-02-06 22:09:00 -05:00
swift-ci
ac3ce0d3c4 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-06 13:43:41 -08:00
Hamish Knight
2b8583581d Merge pull request #29664 from hamishknight/inout-decls
Create a new module and SourceFile for REPL completion
2020-02-06 13:43:00 -08:00
swift-ci
ce39ec797e Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-06 13:24:23 -08:00
swift-ci
94784f13de Merge pull request #29676 from nate-chandler/generic-metadata-prespecialization-components/swift-53 2020-02-06 13:08:41 -08:00
swift-ci
339fad4910 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-06 13:04:45 -08:00
Dan Zheng
9205758e00 [AutoDiff upstream] Add SILFunctionType utilities. (#29674)
Upstream AutoDiff-related `SILFunctionType` utilities:
- `SILFunctionType::getDifferentiabilityParameterIndices`
- `SILFunctionType::getWithDifferentiability`
- `SILFunctionType::getWithoutDifferentiability`

Resolves TF-1125.
2020-02-06 12:47:12 -08:00
Nate Chandler
4300f711b4 [metadata prespecialization] Available in 5.3. 2020-02-06 11:13:21 -08:00
swift-ci
23021d96fc Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-06 11:04:29 -08:00
Rintaro Ishizaki
ea1b18f2cc Merge pull request #29667 from rintaro/ide-completion-typerelation-rdar59201827
[CodeCompletion] Introduce 'NotApplicable' and 'Unknown' type relation
2020-02-06 11:00:01 -08:00
swift-ci
1a6ffc8b0e Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-06 09:24:55 -08:00
nate-chandler
4a97914196 Merge pull request #29488 from nate-chandler/generic-metadata-prespecialization-components/default-on
[metadata prespecialization] On by default.
2020-02-06 09:10:10 -08:00
John McCall
b3750a7c13 Add a PrettyStackTrace for working with Clang types. 2020-02-06 12:09:05 -05:00
Nate Chandler
0ae9e68607 [metadata prespecialization] On by default.
Previously, -Xfrontend -prespecialize-generic-metadata had to be passed
in order for generic metadata to be prespecialized.  Now it is
prespecialized unless -Xfrontend
-disable-generic-metadata-prespecialization is passed.
2020-02-05 17:53:09 -08:00
swift-ci
70ebdb7629 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-05 17:44:45 -08:00
Holly Borla
0cdaeb5708 Merge pull request #29649 from hborla/function-builder-syntactic-diags
[MiscDiagnostics] Walk into the body of a non single-statement closure if the closure had a function builder transform applied.
2020-02-05 17:43:03 -08:00
Ravi Kandhadai
bca5511fab Merge pull request #29643 from ravikandhadai/fix_dead_array_elim
[SIL Optimization] Make ArraySemantics.cpp aware of "array.uninitialized_intrinsic"
2020-02-05 17:41:36 -08:00
Rintaro Ishizaki
cc8d4965f8 [CodeCompletion] Ensure cached results have 'unknown' type relation 2020-02-05 17:05:23 -08:00
swift-ci
cf3c4aa3f5 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-05 16:06:28 -08:00
Ravi Kandhadai
a6bed21d9e [SIL Optimization] Make ArraySemantics.cpp aware of "array.uninitialized_intrinsic"
semantics attribute that is used by the top-level array initializer (in ArrayShared.swift),
which is the entry point used by the compiler to initialize array from array literals.
This initializer is early-inlined so that other optimizations can work on its body.

Fix DeadObjectElimination and ArrayCOWOpts optimization passes to work with this
semantics attribute in addition to "array.uninitialized", which they already use.

Refactor mapInitializationStores function from ArrayElementValuePropagation.cpp to
ArraySemantic.cpp so that the array-initialization pattern matching functionality
implemented by the function can be reused by other optimizations.
2020-02-05 14:28:34 -08:00
Rintaro Ishizaki
c31bfaeeed [CodeCompletion] Introduce 'Unknown' type relation
Now

* NotApplicable: The result is not relevant for type relation (e.g.
  keywords, and overloads)
* Unknown: the relation was not calculated (e.g. cached results), or the
  context type is unknown.
* Invalid: The result type is invalid for this context (i.e. 'Void' for
  non-'Void' context)
* Unrelated: The result type has no relation to the context type
* Convertible: The result type is convertible to the context type
* Identical: The result type is identical to the context type
2020-02-05 14:23:59 -08:00
Rintaro Ishizaki
17abedf1ef [CodeCompletion] Introduce 'NotApplicable' type relation
For keywords, and overrides.
2020-02-05 14:23:59 -08:00
Hamish Knight
9208f5bd88 Remove StartElem params from various entry points
Now that REPL code completion no longer injects
temporary decls into source files, this parameter
is no longer needed.
2020-02-05 14:01:21 -08:00
Hamish Knight
e5946227da Always mark the initial REPL file as typechecked
We were previously doing this for the REPL, but
not for swift-ide-test. Move the assignment into
the frontend to make sure its always applied, and
inline `createREPLFile` while we're here.
2020-02-05 14:01:20 -08:00
Hamish Knight
8037f2feb0 Merge pull request #29619 from hamishknight/a-buffet-of-tokens
Parse Swift decls in one shot
2020-02-05 13:58:31 -08:00
swift-ci
b713e90ffb Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-05 12:23:45 -08:00
Pavel Yaskevich
99856ed42c Merge pull request #29655 from xedin/rdar-41416758
[ConstraintSystem] Make variadics work with anonymous closure parameters
2020-02-05 12:10:25 -08:00
swift-ci
0709ae2ee6 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-05 10:44:37 -08:00
Robert Widmann
960b5a2d9d Merge pull request #29629 from CodaFi/big-generator
Add SILGenSourceFileRequest
2020-02-05 10:31:36 -08:00
Pavel Yaskevich
07a69c425f [ConstraintSystem] Make variadics work with anonymous closure parameters
Since opening closure body is now delayed until contextual type becomes
available it's possible to infer anonymous parameters as being variadic
based on context and propagate that information down to the closure body.

Resolves: rdar://problem/41416758
2020-02-05 09:35:49 -08:00
Kelvin
19a8759cee Merge branch 'master' into comparable-enums 2020-02-04 22:08:40 -06:00
Holly Borla
778f8941ee [MiscDiagnostics] Walk into the body of a non single-statement closure
if the closure had a function builder transform applied.

This way, function builder closures can have syntactic restrictions
diagnosed the same way as other expressions.
2020-02-04 16:29:02 -08:00
Robert Widmann
4570ba8426 Refactor GenerateSILRequest into WMO and per-SF SILGen Requests 2020-02-04 15:20:52 -08:00
swift-ci
9b78f57bd4 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-04 14:23:48 -08:00
John McCall
aaed720578 Merge pull request #29586 from rjmccall/tagged-union
Add a simple TaggedUnion defined in terms of ExternalUnion
2020-02-04 17:21:01 -05:00
Hamish Knight
3d3a2a5925 Remove redundant state from PersistentParserState
Now that we parse Swift decls in one pass, we no
longer need to track the parser's position across
multiple parser calls.
2020-02-04 13:04:50 -08:00