Commit Graph

39091 Commits

Author SHA1 Message Date
Dan Zheng
a864a57c9a [AutoDiff upstream] Add Differentiable.withDerivative(_:). (#30945)
Add `Differentiable.withDerivative(_:)`, a "derivative surgery" API.

`Differentiable.withDerivative(_:)` is an identity function returning `self`.
It takes a closure and applies it to the derivative of the return value, in
contexts where the return value is differentiated with respect to.
2020-04-10 12:22:56 -07:00
Slava Pestov
cabb657caa Merge pull request #30937 from slavapestov/fix-property-wrapper-vtable-layout-with-subclass
Sema: Force property wrappers in EmittedMembersRequest::evaluate()
2020-04-10 15:15:23 -04:00
Slava Pestov
41ccedc999 AST: Fix opaque type mangling used by type reconstruction
Make sure we mangle opaque types using the same settings as the
debugger mangling (with OptimizeProtocolNames = false) to ensure
that we can reconstruct those names again.
2020-04-10 15:05:54 -04:00
Slava Pestov
2b93b5b5e5 Sema: Force property wrappers in EmittedMembersRequest::evaluate()
Fixes <rdar://problem/61229365>.
2020-04-10 15:05:54 -04:00
Michael Ilseman
38fce16254 [string] Convert IR tests to SIL tests 2020-04-10 11:39:22 -07:00
Saleem Abdulrasool
26c61f5183 AutoDiff: repair the cross-module-differentiation on Windows
Make the cross-module differentiation test work on Windows by converting
to a shared library to run the test.
2020-04-10 11:25:40 -07:00
Artem Chikin
efdfceeb9b [Sema] Diagnose use of implementation-only property wrappers
We already ban all structs from declaring storage that comes from implementation-only imports. Until now we missed property wrappers, they were just dropped in deserialization.

Resolves rdar://problem/59403617
2020-04-10 11:19:42 -07:00
Erik Eckstein
f83bd2885d tests: fix the timeout.py script and move it to a more central place
A string->float conversion for the command line argument was missing
2020-04-10 20:10:24 +02:00
Erik Eckstein
1de19a1b32 SimplifyCFG: fix a compile time problem with block merging
When merging many blocks to a single block (in the wrong order), instructions are getting moved over and over again.
This is quadratic and can result in very long compile times for large functions.
To fix this, always move the instruction to smaller block to the larger block.

rdar://problem/56268570
2020-04-10 20:10:24 +02:00
Saleem Abdulrasool
de9aa59b74 test: repair the AutoDiff test on Windows
`-lm` is not portable, it is only needed on certain platforms (e.g.
Linux, not BSD).  Remove the explicit link.

Avoid using a static library as that is not supported on all platforms
(e.g. Windows).  Use the helper macros to generate the library.

Repairs the Windows tests.
2020-04-10 10:58:22 -07:00
Saleem Abdulrasool
0444df6f50 Merge pull request #30952 from compnerd/autodiff-vs-differential-programming
AutoDiff: repair the test on Windows
2020-04-10 10:56:46 -07:00
Saleem Abdulrasool
d09c0f85bf Merge pull request #30949 from compnerd/fp80-android
AutoDiff: Android, Windows does not support FP80
2020-04-10 10:32:42 -07:00
Hamish Knight
d69a42d656 [CS] Preserve compatibility for collection coercions
Previously we could allow some invalid coercions to
sneak past Sema. In most cases these would either
cause crashes later down the pipeline or
miscompiles. However, for coercions between
collections, we emitted somewhat reasonable code
that performed a force cast.

This commit aims to preserve compatibility with
those collection coercions that previously
compiled, and emits a warning telling the user to
use either 'as?' or 'as!' instead.
2020-04-10 10:16:07 -07:00
Hamish Knight
47541d86f7 [CS] Visit all fixed bindings for constraint re-activation
Start visiting transitive fixed bindings for type
variables, and stop visiting adjacencies for
`gatherConstraint`'s `AllMentions` mode.

This improves performance and fixes a correctness
issue with the old implementation where we could
fail to re-activate a coercion constraint, and
then let invalid code get past Sema, causing
either miscompiles or crashes later down the
pipeline.

Unfortunately this change requires us to
temporarily drop the non-ephemeral fix for a couple
of fairly obscure cases where the overload hasn't
yet been resolved. The logic was previously relying
on stale adjacency state in order to re-activate
the fix when the overload is bound, but it's not
connected on the constraint graph. We need to find
a way to connect constraints to unresolved
overloads they depend on.

Resolves SR-12369.
2020-04-10 10:16:07 -07:00
Michael Gottesman
c7b671ab33 Merge pull request #30930 from gottesmm/pr-e789a43b68653b4658b5c65d1d836ee36a1074e2
[polymorphic-builtins] Enable test during optimize builds.
2020-04-10 10:06:23 -07:00
Robert Widmann
9269143154 Merge pull request #30735 from owenv/verifier-edu-notes
[DiagnosticVerifier] Support asserting edu notes are emitted
2020-04-10 09:15:55 -07:00
Saleem Abdulrasool
ccdc8efa95 AutoDiff: repair the test on Windows
The name of the module is encoded into the type name.  The module name
is not `null` on Windows, which would fail to match the name.  It is
possible to make the test less overly-constricted, but setting the
module name to null is simpler and avoids more regex matching.
2020-04-10 08:14:54 -07:00
Saleem Abdulrasool
3528e7e1fa AutoDiff: disable the test cases for FP80
The FP80 tests should not be built on Android or Windows.  This fixes
the Windows run of the test.
2020-04-10 08:11:47 -07:00
Saleem Abdulrasool
4b67e95299 AutoDiff: Android, Windows does not support FP80
Correct the condition for FP80.  This should have no real impact on
Android as the tests are not currently executed.
2020-04-10 08:09:35 -07:00
Dan Zheng
e9ed2d50cf [AutoDiff] Fix @derivative attribute type-checking crash. (#30936)
Fix `@derivative` attribute type-checking crash, so far reproducible only via
`-parse-stdlib`.

The crash occurs because it is not sufficient for type-checking to check for
`Differentiable` conformances. We must also check for invalid `TangentVector`
associated types.

Resolves SR-12559.
2020-04-10 02:14:02 -07:00
Dan Zheng
b4fa7e0027 [AutoDiff] Support direct init reference differentiation.
Support `@differentiable` function conversion for `init` references, in
addition to `func` references and literal closures. Minor usability improvement.

Resolves SR-12562.
2020-04-10 01:26:34 -07:00
swift-ci
9a6ae6e400 Merge pull request #30943 from atrick/fix-assert-termoper 2020-04-10 01:13:15 -07:00
Andrew Trick
18c4cdf68e Fix an assert in OwnershipUtils.
checked_cast_br may take an additional operands for the source and
target types. I'm sure the compiler forgets to check this in many
places. In this case, it was just a harmless assert.

Fixes <rdar://61122253> Assertion failed:
(termInst->getNumOperands() == 1 && "Transformation terminators should only have single operands")
2020-04-09 23:30:10 -07:00
Dan Zheng
3ef8360f3e [AutoDiff] Add AnyDifferentiable. (#30928)
Add `AnyDifferentiable`, a type-erased wrapper for `Differentiable`-conforming types.
2020-04-09 22:49:55 -07:00
Owen Voorhees
77aa5642c3 [Diagnostics] Expand test coverage of existing edu notes 2020-04-09 18:18:25 -07:00
Owen Voorhees
cfbedd81c4 [DiagnosticVerifier] Add support for asserting presence of edu notes 2020-04-09 18:18:25 -07:00
Slava Pestov
8ee5d2931f Sema: Force property wrappers in EmittedMembersRequest::evaluate()
Fixes <rdar://problem/61229365>.
2020-04-09 19:57:12 -04:00
Holly Borla
65105f3a26 [Property Wrappers] Introduce a new Expr node for the property wrapper
wrapped value placeholder in an init(wrappedValue:) call that was previously
injected as an OpaqueValueExpr. This commit also restores the old design of
OpaqueValueExpr.
2020-04-09 16:00:57 -07:00
omochimetaru
a07b35ab03 [Diagnostics] Improve {{none}} fix-it verifier (#30791)
* [Diagnostics] Improve {{none}} fix-it verifier

* split two conditions

* define "none" constant

* support plural

* use Twine and add comment for replacement range

* check if {{none}} is at the end

* use noneMarkerStartLoc

* update second {{none}} error message

Co-Authored-By: Owen Voorhees <owenvoorhees@gmail.com>

* update test case for second {{none}}

* fix test case for new {{none}} check

* Use named struct

* set const

Co-authored-by: Owen Voorhees <owenvoorhees@gmail.com>
2020-04-09 15:32:14 -07:00
Suyash Srijan
82a163e68b [Test] Add an executable test 2020-04-09 23:21:19 +01:00
Michael Gottesman
ac51ce3fc7 [polymorphic-builtins] Enable test during optimize builds.
The confusion here was around a test that was testing the behavior when one
/does not/ guard a polymorphic builtin with a _isConcrete. Specifically, without
_isConcrete, one gets weird behavior where in debug we crash, but in release we
may not due to further inlining/specialization. With _isConcrete, we never
crashand get the appropriate behavior.

This commit works by changing the current run of the polymorphic builtin test to
force -Onone and adds an extra -O run that way we validate both behaviors.
2020-04-09 14:44:45 -07:00
marcrasi
ddef9292a6 [AutoDiff upstream] DifferentiationUnittest and some e2e tests (#30915)
Adds 2 simple e2e tests and some lit subsitutions and unittest libraries
necessary to support them.
2020-04-09 14:25:31 -07:00
Saleem Abdulrasool
1d7b3a5ba8 Merge pull request #30925 from compnerd/30875
test: repair the Android CI after #30875
2020-04-09 14:16:52 -07:00
Dan Zheng
109e8088a5 Merge pull request #30926 from dan-zheng/autodiff-stdlib
[AutoDiff upstream] Upstream `_Differentiation` APIs.
2020-04-09 14:08:17 -07:00
Nathan Hawes
8e527ed7fa Merge pull request #30894 from nathawes/avoid-multiline-string-indent
[SourceKit/CodeFormat] Don't modify multiline string indentation regardless of it being column-aligned or not.
2020-04-09 12:48:10 -07:00
Dan Zheng
d4ff5847d0 [AutoDiff upstream] Add AnyDerivative.
Add `AnyDerivative`, a type-erased wrapper for `Differentiable.TangentVector`
associated type implementations.
2020-04-09 11:52:59 -07:00
Saleem Abdulrasool
6f28e54505 test: repair the Android CI after #30875
The added test was not correctly indicated as a running test.
2020-04-09 11:36:41 -07:00
Dan Zheng
65ab642b1a [AutoDiff upstream] Add Differentiable.zeroTangentVector.
Add `Differentiable.zeroTangentVectorInitializer` protocol requirement and
`Differentiable.zeroTangentVector` default implementation.
2020-04-09 11:15:18 -07:00
Saleem Abdulrasool
790e1a109a Merge pull request #30921 from compnerd/python2
test: lit still requires python2, explicitly use that
2020-04-09 11:00:12 -07:00
Dan Zheng
5b943963cc Merge pull request #30918 from dan-zheng/autodiff-forward-mode
[AutoDiff] Enable forward-mode differentiation tests.
2020-04-09 10:01:06 -07:00
marcrasi
d99d8da956 [AutoDiff upstream] handle differentiable_function in DiagnoseInvalidEscapingCaptures (#30909) 2020-04-09 09:34:24 -07:00
Saleem Abdulrasool
b8bc8c2b05 test: lit still requires python2, explicitly use that
This updates the invocation to use `Python2::Interpreter` rather than
relying on the custom `PYTHON_EXECUTABLE`.  This is much easier to
identify where we are falling back to the python2 code paths and where
we can start moving towards Python3.
2020-04-09 08:39:49 -07:00
Saleem Abdulrasool
0678aa6392 Merge pull request #30911 from compnerd/long-paths
test: support long paths in `rewrite-module-triples`
2020-04-09 08:02:14 -07:00
tbkka
110e5136c1 Float16 optimal formatting (#30862)
Extend SwiftDtoa to provide optimal formatting for Float16 and use that for `Float16.description` and `Float16.debugDescription`.

Notes on signaling NaNs: LLVM's Float16 support passes Float16s on x86
by legalizing to Float32.  This works well for most purposes but incidentally
loses the signaling marker from any NaN (because it's a conversion as far
as the hardware is concerned), with a side effect that the print code never
actually sees a true sNaN.  This is similar to what happens with Float and
Double on i386 backends.  The earlier code here tried to detect sNaN in a
different way, but that approach isn't guaranteed to work so we decided to
make this code use the correct detection logic -- sNaN printing will just be
broken until we can get a better argument passing convention.

Resolves rdar://61414101
2020-04-09 09:37:38 -04:00
Dan Zheng
3f06912fd9 [AutoDiff] Enable forward-mode differentiation tests.
Resolves TF-1237 TODO comments.
2020-04-09 01:49:25 -07:00
Dan Zheng
2f50c859c0 [test] Add config.target_run_simple_swiftgyb_parameterized.
Support `%target-run-simple-swiftgyb(...)` taking compiler arguments.
Copies existing support for `%target-run-simple-swift(...)`.
2020-04-09 01:47:53 -07:00
Dan Zheng
f22d923340 [AutoDiff] Remove obsolete TODO comments. 2020-04-09 01:10:43 -07:00
Dan Zheng
3999b8b23f Merge pull request #30912 from dan-zheng/fix-synthesized-file-unit
Fix SynthesizedFileUnit serialization and TBDGen issues.
2020-04-09 00:30:26 -07:00
swift-ci
83e176bd5e Merge pull request #30913 from atrick/fix-assert-termoper 2020-04-08 23:41:42 -07:00
Dan Zheng
75548c30be Merge pull request #30875 from apple/autodiff-upstream-stdlib-differentiation
[AutoDiff upstream] Add stdlib `Differentiable` conformances and derivatives.
2020-04-08 22:31:47 -07:00