Commit Graph

39091 Commits

Author SHA1 Message Date
Doug Gregor
e46d6fd0ec Merge pull request #30590 from DougGregor/property-wrapper-backing-init-linkage
[Property wrappers] Fix property wrapper backing initializer linkage.
2020-03-24 11:32:11 -07:00
Mishal Shah
e7cd5ab17f Update master to build with Xcode 11.4 2020-03-24 11:30:45 -07:00
Dan Zheng
a1c4b68d3c [AutoDiff] Remove @differentiable(jvp:vjp:) parsing logic. (#30604)
Remove logic for parsing and diagnosing `jvp:` and `vjp:` arguments for
`@differentiable` attribute. No logic remains for handling those arguments.

Follow-up to TF-1001.
2020-03-24 11:21:10 -07:00
Nathan Hawes
fe12ab2067 [SourceKit/DocSupport][test] Test that the synthesized comments generated for cross-import overlay decls are ignored.
Unlike doc comments, they shouldn't be reported in the 'fully_annotated_decl' field.
2020-03-24 10:31:08 -07:00
Nathan Hawes
9aafadd090 [SourceKit/DocSupport] Report the required bystander modules on symbols from cross-import overlays.
Resolves rdar://problem/59446044
2020-03-24 10:31:08 -07:00
Nathan Hawes
7811f531cb Merge pull request #30521 from nathawes/cross-import-interface-gen
[SourceKit/InterfaceGen] Also print the cross-import overlays of a module in its interface.
2020-03-24 10:28:55 -07:00
Alexis Laferrière
4e0038f0df [Serialization] Recover from conformances with missing decls
Components of a requirement may be hidden behind an implementation-only
import. Attempts at deserializing them would fail on a 'module not
loaded' error. We only see failures in non-compilation paths, either in
indexing or with tools like ide-test as they try to deserialize
things that are private.
2020-03-24 10:25:02 -07:00
Arnold Schwaighofer
e344971de7 IRGen: Also unique selectors in extended method types list
rdar://60778637
2020-03-24 09:39:44 -07:00
eeckstein
2ca8b15b51 Merge pull request #30610 from eeckstein/fix-destroy-hoisting
DestroyHoisting: fix a bug which creates invalid SIL
2020-03-24 17:20:53 +01:00
Dan Zheng
a856d59623 [AutoDiff upstream] Add @differentiable attribute serialization. (#30605)
Serialize "is linear?" flag, differentiability parameter indices, and
differentiability generic signature.

Deserialization has some ad-hoc logic for setting the original declaration and
parameter indices for `@differentiable` attributes because
`DeclDeserializer::deserializeDeclAttributes` does not have access to the
original declaration.

Resolves TF-836.
2020-03-24 08:22:56 -07:00
eeckstein
0873622b4b Merge pull request #30445 from eeckstein/globalopt
GlobalOpt: don't speculatively execute initializers of global variables
2020-03-24 15:09:10 +01:00
Erik Eckstein
15f519f544 DestroyHoisting: fix a bug which creates invalid SIL
A dominance check was missing.
2020-03-24 15:07:37 +01:00
Dmitri Gribenko
5d53f93789 Use more precise terms in a test 2020-03-24 14:33:00 +01:00
marcrasi
1be86adbfc [AutoDiff] forbid derivative registration using @differentiable (#30001)
Delete `@differentiable` attribute `jvp:` and `vjp:` arguments for derivative
registration. `@derivative` attribute is now the canonical way to register
derivatives.

Resolves TF-1001.
2020-03-24 00:41:27 -07:00
Dan Zheng
a24ea90c95 [AutoDiff] NFC: garden tests. (#30598)
* Move muliti-functionality SIL tests to test/AutoDiff/SIL.

* Add `with_derivative` clause to `differentiable_function` instructions.

Otherwise, IRGen for test/AutoDiff/SIL/differentiable_function_inst.sil fails on
tensorflow branch because the differentiation transform cannot differentiate
external functions.
2020-03-23 20:29:33 -07:00
omochimetaru
e1cb1a2057 Merge pull request #30501 from omochi/fix-verify-range
[Diagnostics] Fix range of fix-its in verify mode
2020-03-24 11:25:15 +09:00
3405691582
4a36a4b6c5 [test] Setup testing for OpenBSD.
This commit focuses the basics: setting up the relevant stanzas in
lit.cfg and adding platform conditionals for importing Glibc. Future
commits will deal with other portability fixes.
2020-03-23 20:47:31 -04:00
Doug Gregor
a15a905425 [Property wrappers] Expand testing for backing initializer linkage change. 2020-03-23 15:59:29 -07:00
Anthony Latsis
8f306261ea Merge pull request #30574 from AnthonyLatsis/code-complete-broken-conf-no-static
[CodeCompletion] Add overlooked 'isDeclVisibleInLookupMode' check when collecting value requirements
2020-03-24 01:26:41 +03:00
Dan Zheng
6dd557a557 [AutoDiff] NFC: garden tests. (#30588)
Add test/AutoDiff/lit.local.cfg: run tests only when `differentiable_programming`
is enabled in lit. With this, individual tests no longer need
`REQUIRES: differentiable_programming`.

Move multi-functionality SIL tests from test/AutoDiff/SIL/Serialization to
test/AutoDiff/SIL.

Garden test filenames.
2020-03-23 15:22:27 -07:00
Robert Widmann
89b8163824 Merge pull request #30585 from CodaFi/untapped-potential
Register Conformances as Potential Member Constraints
2020-03-23 14:33:07 -07:00
Doug Gregor
8621a524ba [Property wrappers] Fix property wrapper backing initializer linkage.
Have property wrapper backing initializers determine their linkage in
the same way as stored property initializers, which need to match the linkage
of the enclosing type in cases where one can write an initializer
outside of the source file where that type is declared.

Fixes rdar://problem/59607192.
2020-03-23 14:27:25 -07:00
Nathan Hawes
a355a56dd4 [SourceKit/InterfaceGen][test] Test that doc comments are printed after the required bystanders comment. 2020-03-23 12:44:08 -07:00
Dan Zheng
62f6686da4 Merge pull request #30579 from dan-zheng/autodiff-upstream-sil
[AutoDiff upstream] [SIL] Add differentiable function instructions.
2020-03-23 12:18:19 -07:00
Hamish Knight
de4669055a Add direct operator lookup requests (#30584)
Add direct operator lookup requests
2020-03-23 12:09:23 -07:00
Joe Groff
b0ca53fcf3 Merge pull request #30546 from jckarter/mangle-any-protocol-conformance
Factor `appendAnyProtocolConformance` out of the conformance mangling.
2020-03-23 11:47:34 -07:00
Anthony Latsis
cf43a564a2 [CodeCompletion] Check visibility in lookup mode when collecting value requirements 2020-03-23 21:40:41 +03:00
Robert Widmann
bafd707429 Register Conformances as Potential Member Constraints
Unwind a hack whose stated purpose was to register a potential member
edge from an extension to the extended type. In reality, this only
registered a plain member dependency on 'deinit'. This edge is
insufficient in isolation to cause a rebuild of a dependent file in the
case where a type and its extension live in separate files. However, we
appear to have been saved by the redundancy in edge registration because the
lookup for the extended type will register a top-level or nominal
dependency (for an unqualified or qualified reference respectively). The
worry there is if a protocol conformance edge *should* flip a previously
private nominal dependency edge to a cascading edge. In such a case, the
old code would not have been able to make the cascading edge promotion,
and we would have potentially miscompiled by not rescheduling dependent
jobs.
2020-03-23 11:20:05 -07:00
Anthony Latsis
667bec0f21 Merge pull request #30578 from AnthonyLatsis/memb-fail-qoi
[DiagQoI] Improve fallback fixits for static member on instance errors
2020-03-23 19:31:10 +03:00
Hamish Knight
e5952ab7fe Fix a couple of invalid location diagnostics 2020-03-23 09:17:58 -07:00
Hamish Knight
f3708b29ec Add tests for operator lookup and redeclaration checking 2020-03-23 09:17:58 -07:00
Erik Eckstein
3ad7d548c2 LICM: hoist calls to global_init functions
Global initializers are executed only once.
Therefore it's possible to hoist such an initializer call to a loop pre-header - in case there are no conflicting side-effects in the loop before the call.
Also, the call must post-dominate the loop pre-header. Otherwise it would be executed speculatively.
2020-03-23 16:08:56 +01:00
Erik Eckstein
71eebaa720 CSE: remove redundant global initializer calls 2020-03-23 15:53:23 +01:00
Erik Eckstein
84e2a568ca GlobalOpt: don't speculatively execute global initializers
For example: hoist out of loops where the loop count could be 0.
We did this on purpose. But, if not wrong, it's at least very confusing if the initializer has observable side effects.
Instead let CSE and LICM do the job and handle initializer side-effects correctly.

rdar://problem/60292679
2020-03-23 15:53:22 +01:00
Erik Eckstein
526a0c8f33 GlobalOpt: fix global constant propagation of globals with multiple writes
Detect stores to globals which get the address from an addressor call (and not from global_addr).
This kind of SIL is currently not generated, so most likely this bug does not show up. But as soon as we CSE addressor calls, it can be a real problem.
2020-03-23 14:41:31 +01:00
Dan Zheng
7e10a507be Fix LLVM IR FileCheck for Linux. 2020-03-23 09:49:02 +00:00
Dan Zheng
cc7e9fc39e [AutoDiff upstream] [SIL] Add differentiable function instructions.
Add `differentiable_function` and `differentiable_function_extract`
instructions.

`differentiable_function` creates a `@differentiable` function-typed
value from an original function operand and derivative function operands
(optional).

`differentiable_function_extract` extracts either the original or
derivative function value from a `@differentiable` function.

The differentiation transform canonicalizes `differentiable_function`
instructions, filling in derivative function operands if missing.

Resolves TF-1139 and TF-1140.
2020-03-22 23:53:43 -07:00
Anthony Latsis
572f0544a2 [DiagQoI] Improve fallback fixits for static member on instance error 2020-03-23 08:27:55 +03:00
Dan Zheng
723b2d2cbe [AutoDiff upstream] Add derivative function witness/vtable entry SILGen. (#30569)
`@differentiable` attribute on protocol requirements and non-final class
members now produces derivative function entries in witness tables and vtables.

This enables `witness_method` and `class_method` differentiation.

Existing type-checking rules:

- Witness declarations of `@differentiable` protocol requirements must have a
  `@differentiable` attribute with the same configuration (or a configuration
  with superset parameter indices).
  - Witness table derivative function entries are SILGen'd for `@differentiable`
    witness declarations.

- Class vtable derivative function entries are SILGen'd for non-final
  `@differentiable` class members.
  - These derivative entries can be overridden or inherited, just like other
    vtable entries.

Resolves TF-1212.
2020-03-22 16:59:01 -07:00
Dan Zheng
aab622e913 [AutoDiff upstream] Add derivative function SILDeclRefs. (#30564)
`@differentiable` attribute on protocol requirements and non-final class members
will produce derivative function entries in witness tables and vtables.

This patch adds an optional derivative function configuration
(`AutoDiffDerivativeFunctionIdentifier`) to `SILDeclRef` to represent these
derivative function entries.

Derivative function configurations consist of:
- A derivative function kind (JVP or VJP).
- Differentiability parameter indices.

Resolves TF-1209.
Enables TF-1212: upstream derivative function entries in witness tables/vtables.
2020-03-22 11:50:29 -07:00
Brent Royal-Gordon
e7959a90cf Disable two failing opaque result type tests
See e.g. https://ci.swift.org/job/oss-swift_tools-RA_stdlib-DA_test-device-non_executable/29. The Interpeter test doesn’t actually crash in any Swift CI configuration, but its compilation step crashes in the same way with arm64e.
2020-03-21 23:17:36 -07:00
Owen Voorhees
768c4385cf [DiagnosticVerifier] More accurate wording when printing diagnostics from external sources 2020-03-21 15:11:46 -07:00
Dan Zheng
24445dd2e2 [AutoDiff upstream] Add differentiability witness SILGen. (#30545)
Generate SIL differentiability witnesses from `@differentiable` and
`@derivative` declaration attributes.

Add SILGen utilities for:
- Emiting differentiability witnesses.
- Creating derivative function thunks, which are used as entries in
  differentiability witnesses.

When users register a custom derivative function, it is necessary to create a
thunk with the expected derivative type computed from the original function's
type. This is important for consistent typing and consistent differentiability
witness entry mangling.

See `SILGenModule::getOrCreateCustomDerivativeThunk` documentation for details.

Resolves TF-1138.
2020-03-21 02:05:04 -07:00
Anthony Latsis
7c5b4d1fdf Merge pull request #30552 from AnthonyLatsis/assoc-coloring
[ASTWalker] Associated type defaults deserve syntax coloring
2020-03-21 10:22:19 +03:00
Doug Gregor
aacdd3a27d Merge pull request #30537 from DougGregor/roop-sr10950_prop_wrap_autoclosure
[Property wrappers] Fix handling of @autoclosure in init(wrappedValue:)
2020-03-20 23:12:18 -07:00
Anthony Latsis
7e21d7b5eb Merge pull request #30423 from AnthonyLatsis/se-0267-additions
[SE-0267] Improvements (Ep. 1)
2020-03-21 08:59:13 +03:00
Anthony Latsis
016d3bbfae [ASTWalker] Associated type defaults deserve syntax coloring 2020-03-21 08:37:53 +03:00
Nathan Hawes
a7e1cb3925 [SourceKit] Update cursor info to report symbols from cross-import overlays as coming from the underylying module.
Also refactor some of the interface generation cross-import support code to be
shared.
2020-03-20 21:49:51 -07:00
Anthony Latsis
280ce22376 Test reconstruction of non-generic nested types with contextual where clauses 2020-03-21 05:47:54 +03:00
Anthony Latsis
14d3687d3b [SILGen] Test vtable thunk emission for overrides with contextual where clauses 2020-03-21 05:46:47 +03:00