Commit Graph

39091 Commits

Author SHA1 Message Date
Doug Gregor
6edc32568c [Driver] Adjust Mac Catalyst deployment target to >= iOS 13 for the linker
Mac Catalyst was introduced with an iOS deployment target of 13.0.
If given a deployment target before that, adjust the deployment target
to 13.0 for the linker.
2020-04-02 21:07:26 -07:00
Doug Gregor
336c0c2d54 [Driver] Use -platform_version to specify platform versions for the Darwin linker
Standardize the way in which we pass platform version information to
the Darwin linker, using the `-platform_version` option. In the case
of Mac Catalyst, there may be two such platform arguments.

The eventual point of this refactoring is to also pass information
about the SDK version, which `-platform_version` supports but the
mix of `-*_version_min` parameters do not. For now, the SDK
version is stubbed out to 0.0.0, which is this option's "unknown"
value.

Part of rdar://problem/55972144.
2020-04-02 21:07:26 -07:00
Dan Zheng
e2014e3366 Merge pull request #30781 from dan-zheng/differentiation-transform-skeleton 2020-04-02 21:01:53 -07:00
Ewa Matejska
f07ae89636 First pass at upstreaming Differentiable conformances and derivatives 2020-04-02 19:55:26 -07:00
Artem Chikin
b679fd8738 Add -Rcross-import option
It is an optional, user-accessible mechanism to have the compiler tell you what it’s cross-importing.

Resolves rdar://problem/60381893
2020-04-02 19:45:39 -07:00
Dan Zheng
4671dc5c0f [AutoDiff upstream] Add TBDGen for AutoDiff symbols.
Emit symbols for `@differentiable` and `@derivative` declaration attributes:
- Differentiability witness symbols.
- Derivative function (JVP/VJP) symbols.
- Linear map (differential/pullback) symbols.

Add TBDGen test.
2020-04-03 01:14:28 +00:00
Argyrios Kyrtzidis
f389bcd631 [test/SourceKit] Add a test case for a crash that is already fixed 2020-04-02 17:24:15 -07:00
Joe Groff
a87369b53c Merge pull request #30763 from jckarter/protocol-infer-objc-error-convention
Sema: Infer error convention from @objc protocol requirements.
2020-04-02 16:04:37 -07:00
Dan Zheng
aa66cce808 [AutoDiff upstream] Add differentiation transform.
The differentiation transform does the following:
- Canonicalizes differentiability witnesses by filling in missing derivative
  function entries.
- Canonicalizes `differentiable_function` instructions by filling in missing
  derivative function operands.
- If necessary, performs automatic differentiation: generating derivative
  functions for original functions.
  - When encountering non-differentiability code, produces a diagnostic and
    errors out.

Partially resolves TF-1211: add the main canonicalization loop.

To incrementally stage changes, derivative functions are currently created
with empty bodies that fatal error with a nice message.

Derivative emitters will be upstreamed separately.
2020-04-02 15:43:57 -07:00
Dan Zheng
c6f2d7ab0a [AutoDiff] Disable failing test with -O.
Disable test/AutoDiff/stdlib/differential_operators.swift, which currently fails
with `-O`.

SR-12493 tracks fixing the issue. Add negative test.
2020-04-02 13:06:35 -07:00
Michael Ilseman
30c92574ed [String] Concrete String/Substring overloads for ~=
Add concrete overloads for ~= for String/Substring
combinations. SR-12457 tracks making this generic after we understand
the expression type checker impact.
2020-04-02 10:37:30 -07:00
Dan Zheng
172d57fa93 [AutoDiff] Add @_exported import _Differentiation test. (#30769)
Verify that importing a module with `@_exported import _Differentiation`
enables differentiable programming. This behavior is desirable.
2020-04-02 10:19:56 -07:00
Ivan Smetanin
5f68f7a717 Make escaping_optional_type_argument to be an error, use it instead of original message when object type is a function type 2020-04-02 18:08:19 +03:00
swift-ci
b1b725ac83 Merge pull request #30761 from benrimmington/de-gybbed-file-headers 2020-04-02 04:14:50 -07:00
Dan Zheng
1308fc69c5 [AutoDiff] Simplify conditions enabling differentiable programming. (#30765)
Previously, two conditions were necessary to enable differentiable programming:
- Using the `-enable-experimental-differentiable-programming` frontend flag.
- Importing the `_Differentiation` module.

Importing the `_Differentiation` module is the true condition because it
contains the required compiler-known `Differentiable` protocol. The frontend
flag is redundant and cumbersome.

Now, the frontend flag is removed.
Importing `_Differentiation` is the only condition.
2020-04-02 03:24:03 -07:00
Dmitri Gribenko
e94f01d7e6 Merge pull request #30557 from owenv/verifier-wording-fix
[DiagnosticVerifier] More accurate wording when printing diagnostics from external sources
2020-04-02 11:54:19 +02:00
Erik Eckstein
5406a81d6c SILOptimizer: fix a crash in the keypath optimization
Use the correct type lowering.

rdar://problem/61122088
2020-04-02 10:44:18 +02:00
Joe Groff
90062f1839 Sema: Infer error convention from @objc protocol requirements.
When a Swift declaration witnesses an ObjC protocol requirement, its error convention needs to
match the requirement. Furthermore, if there are different protocol requirements that the
Swift method can witness, with different error conventions, we need to bail out because we
can't simultaneously match all of them. Fixes rdar://problem/59496036 | SR-12201.
2020-04-01 18:26:38 -07:00
Owen Voorhees
2c2850d7eb Merge branch 'master' into verifier-wording-fix 2020-04-01 17:05:24 -05:00
Ben Rimmington
682c1672b6 [stdlib] Update file headers of de-gybbed files 2020-04-01 22:14:03 +01:00
Slava Pestov
7b4786e723 Sema: Contextualize closures for function builder bodies also
The ContextualizeClosures walker re-parents and assigns discriminators to
autoclosures. We weren't doing this walk for function builder bodies,
which meant that proper invariants were not being established for the
implicit autoclosures synthesized for partially applied method references.

This is a recent regression from my change to build curry thunks for
unapplied method references in Sema.

Fixes <rdar://problem/61039516>.
2020-04-01 15:42:25 -04:00
swift-ci
cf608c0c9a Merge pull request #30752 from DougGregor/codable-iuo-crash 2020-04-01 11:54:13 -07:00
Pavel Yaskevich
d922041ac5 Merge pull request #30740 from xedin/rdar-61084565
[ConstraintSystem] Don't include self-recursive dynamic member result…
2020-04-01 10:27:53 -07:00
Doug Gregor
9a37a2a62c [Codable] Fix crash-on-invalid with codable synthesis and implicitly unwrapped optionals
Fixes rdar://problem/60985179.
2020-04-01 10:15:32 -07:00
Arnold Schwaighofer
4f2d2ddd72 Merge pull request #30748 from aschwaighofer/irgen_disable_typelayout_witness_at_onone
IRGen: Disable type layout based value witness generation at Onone
2020-04-01 10:12:02 -07:00
marcrasi
77fd034a0b Merge pull request #30711 from rxwei/differential-operators
[AutoDiff upstream] Add differential operators and some utilities.
2020-04-01 10:11:35 -07:00
Slava Pestov
61bf796e41 Merge pull request #30745 from slavapestov/final-static-property-wrapper-fix
Sema: Property wrapper storage wrappers ($foo) inherit 'final' bit from original property
2020-04-01 12:12:32 -04:00
Arnold Schwaighofer
1bde486a63 IRGen: Disable type layout based value witness generation at Onone
Type layout based witness generation can emit quite complex IR that will
lead to code bloat if the llvm optimizer is not run.

No need to use type layouts at Onone.

rdar://61155295
2020-04-01 07:18:23 -07:00
Erik Eckstein
287619445b LoopRotate: limit the size of the block to be duplicated.
This avoids significant code size regressions if the loop block to be duplicated is very large.

Also remove the ShouldRotate option. It's not needed anymore as disabling the pass can be done by -sil-disable-pass.

rdar://problem/33970453
2020-04-01 10:02:43 +02:00
eeckstein
122a084a40 Merge pull request #30731 from eeckstein/fix-destroy-hoisting
DestroyHoisting: correctly detect if debug_value_addr instructions need to be deleted.
2020-04-01 08:54:45 +02:00
Ivan Smetanin
3dacbed891 Add new error diagnostic for escaping optional closures 2020-04-01 08:57:48 +03:00
Slava Pestov
52c11c78d1 Sema: Property wrapper storage wrappers ($foo) inherit 'final' bit from original property
Otherwise, we would generate inconsistent vtable layouts for classes
with static properties that have attached wrappers. The reason is that
we normally force synthesis of the backing storage and storage wrapper
for each instance property wrapper as part of computing the lowered
stored properties.

However, there was no such forcing for static properties. But since a
static stored property (with an attached wrapper or otherwise) must be
'final', the real fix is to just ensure that the 'final' bit propagates
to the storage wrapper as well.

The backing storage property was already always final, so the issue
did not arise there.

Fixes <rdar://problem/59522703>, <https://bugs.swift.org/browse/SR-12429>.
2020-03-31 23:42:34 -04:00
Robert Widmann
aa0bf50323 Merge pull request #30723 from CodaFi/dependendable-dependencies
[Evaluator] Online Request-Based Incremental Dependency Tracking
2020-03-31 18:13:05 -07:00
Pavel Yaskevich
fdc535a691 [ConstraintSystem] Don't include self-recursive dynamic member results as "inaccessible"
Solver has to keep track of excluded dynamic member results while
performing lookup because otherwise, in diagnostic modem it might
include such results as inaccessible.

Resolves: rdar://problem/61084565
2020-03-31 16:20:20 -07:00
Robert Widmann
8c69814f5c Define Dependency Sinks
Convert most of the name lookup requests and a few other ancillary typechecking requests into dependency sinks.

Some requests are also combined sinks and sources in order to emulate the current scheme, which performs scope changes based on lookup flags. This is generally undesirable, since it means those requests cannot immediately be generalized to a purely context-based scheme because they depend on some client-provided entropy source. In particular, the few callers that are providing the "known private" name lookup flag need to be converted to perform lookups in the appropriate private context.

Clients that are passing "no known dependency" are currently considered universally incorrect and are outside the scope of the compatibility guarantees. This means that request-based dependency tracking registers strictly more edges than manual dependency tracking. It also means that once we fixup the clients that are passing "known private", we can completely remove these name lookup flags.

Finally, some tests had to change to accomodate the new scheme. Currently, we go out of our way to register a dependency edge for extensions that declare protocol conformances. However, we were also asserting in at least one test that extensions without protocol conformances weren't registering dependency edges. This is blatantly incorrect and has been undone now that the request-based scheme is automatically registering this edge.
2020-03-31 16:16:53 -07:00
Robert Widmann
a337b67f69 Stage In Flags To Fall Back To Manual Tracking
Request-based incremental dependencies are enabled by default. For the time being, add a flag that will turn them off and switch back to manual dependency tracking.
2020-03-31 16:16:53 -07:00
Suyash Srijan
95f0651cbb [Diagnostics] Emit a warning when an immutable decodable property has an initial value (#30218)
* [Diagnostics] Emit a warning when an immutable decodable property has an initial value

* [Sema] Use Decl::diagnose instead of Diags.diagnose

* [AST] Remove property name from 'decodable_property_will_not_be_decoded' diagnostic

* [Test] Update tests

* [Test] Update existing codable tests
2020-03-31 23:16:08 +01:00
Artem Chikin
8d68607681 Merge pull request #30734 from artemcm/OpaqueReturnProtocolObjc
[IRGen] Skip witness table query for protocols that do not require one
2020-03-31 14:47:57 -07:00
Mishal Shah
cf474db442 Revert "SILOptimizer: Peephole to eliminate closures which just apply a witness_method" 2020-03-31 12:12:40 -07:00
Robert Widmann
e839cd3ba9 Merge pull request #30685 from dabrahams/squish-warn
Squash warnings
2020-03-31 10:58:42 -07:00
Artem Chikin
1b11e8798c [IRGen] Skip witness table query for protocols that do not require one
Some protocols, such as protocols marked with 'objc', do not have a Witness Table.
The code before this patch assumes all protocols do have a Witness Table when generating the layout of an OpaqueTypeDescriptor, causing an assert to be triggered for opaque return types that conform to an 'objc' protocol.

Fixes SR-12257 / rdar://problem/59740179
2020-03-31 10:56:20 -07:00
Pavel Yaskevich
68b3965f27 Merge pull request #30728 from xedin/rdar-60832876
[ConstraintSystem] Allow sequence element mismatch fix to produce new…
2020-03-31 09:46:14 -07:00
Erik Eckstein
6d533e8913 DestroyHoisting: correctly detect if debug_value_addr instructions need to be deleted.
https://bugs.swift.org/browse/SR-12355
rdar://problem/60832805
2020-03-31 17:34:56 +02:00
Slava Pestov
56695a1ac1 Merge pull request #30689 from slavapestov/curry-thunk-peephole
SILOptimizer: Peephole to eliminate closures which just apply a witness_method
2020-03-31 11:18:02 -04:00
Slava Pestov
dcd6c6d9fa SILOptimizer: Peephole to eliminate closures which just apply a witness_method
A partial_apply of a function_ref whose body consists of just an
apply of a witness_method can be simplified down to a simple
partial_apply of the witness_method:

sil @foo:
  %fn = witness_method ...
  %result = apply %fn(...)
  return %result

sil @bar:
  %fn = function_ref @foo
  %closure = partial_apply %fn(...)

  ===>

sil @bar:
  %fn = witness_method ...
  %closure = partial_apply %fn(...)
2020-03-31 00:47:17 -04:00
Joe Groff
026b8b31c9 Merge pull request #30318 from ktoso/wip-mangledTypeName
Add _mangledTypeName to allow round trips T->mangledName->T
2020-03-30 18:13:56 -07:00
Pavel Yaskevich
f95cabb745 [ConstraintSystem] Allow sequence element mismatch fix to produce new holes
Type on the right-hand side of the element conversion/pattern match
should be allowed to have holes to be able to diagnose failures with
structurally incompatible types.

Resolves: rdar://problem/60832876
2020-03-30 17:48:46 -07:00
Robert Widmann
58e63f7185 Merge pull request #28313 from owenv/verifier-consumer
[DiagnosticVerifier] Make DiagnosticVerifier a DiagnosticConsumer
2020-03-30 17:46:30 -07:00
Marc Rasi
64d0e76dd9 improve differential operator tests 2020-03-30 14:57:59 -07:00
Dan Zheng
02188440b6 Fix differentiable function type demangling.
Handle differentiability kind (`@differentiable` and `@differentiable(linear)`)
in `ASTBuilder::createImplFunctionType`.

Resolves TF-1225.
2020-03-30 14:15:35 -07:00