Commit Graph

58361 Commits

Author SHA1 Message Date
Marc Rasi
7abf8ae305 actually set the lazy resolver 2020-04-07 15:05:27 -07:00
Andrew Trick
8da6b72757 Make -emit-verbose-sil print conformances for existential insts.
It is a correctness bug that textual SIL cannot parse these, but at
least we can somewhat debug the issue now.
2020-04-07 13:53:27 -07:00
Holly Borla
ece84b176c [Diagnostics] Adjust ConstraintFix::diagnoseForAmbiguity to take an array
ref of pairs rather than two parallel arrays.
2020-04-07 13:38:26 -07:00
Ravi Kandhadai
4264b39b23 Merge pull request #26969 from ravikandhadai/oslog-user-model
[Sema Diagnostics] Add Miscellaneous Sema diagnostics to enforce that the new os log APIs and atomics are passed constants for certain arguments
2020-04-07 13:23:10 -07:00
Dan Zheng
f9ef75ff34 Remove SourceFile::addVisibleDecl.
`SourceFile::addVisibleDecl` is an unnecessary API.
It was upstreamed in https://github.com/apple/swift/pull/30821.
2020-04-07 13:19:55 -07:00
Dan Zheng
5d8d8dab2d Merge pull request #30852 from dan-zheng/autodiff-cleanup
[AutoDiff] NFC: gardening.
2020-04-07 13:13:58 -07:00
Doug Gregor
78880ffc1a Merge pull request #27776 from owenv/catch_revamp_take_4
[SE-0276] Support multiple patterns in catch clauses
2020-04-07 12:31:33 -07:00
Nathan Hawes
4592c0ad2d [Index] Don't replace ' ' or '-' in group names when mapping them to a 'module' name.
The fake module names we create when indexing a Swift module divided into
'groups' (e.g. the stdlib) don't have to be valid Swift module names, but we
were manipulating them to be so. E.g. the stdlib "Lazy Views" group, became
"Lazy_Views". This name is displayed in some editors verbatim, and is also
used as input to some sourcekitd APIs (e.g. editor.open.interface) that only
work if the original group name is passed, rather than the processed one.

This patch stops mapping invalid module name characters like ' ' and '-' to '_'
so the original group name remains.

Resolves rdar://problem/57270811
2020-04-07 12:18:36 -07:00
Rintaro Ishizaki
31e7873704 Merge pull request #30767 from rintaro/sourcekit-completion-annotateddesc-rdar60801189
[SourceKit/CodeCompletion] Add an option to emit annotated description
2020-04-07 11:33:21 -07:00
Slava Pestov
2af7d8a1f0 Merge pull request #30847 from slavapestov/opaque-type-lowering-access-level-fix
AST: Fix accessibility checking in opaque type archetype substitution logic
2020-04-07 14:08:11 -04:00
Dan Zheng
77d0d99f81 [AutoDiff] NFC: move isDifferentiableProgrammingEnabled.
Move `isDifferentiableProgrammingEnabled` to AutoDiff.h so it's more accessible.
2020-04-07 11:01:00 -07:00
Dan Zheng
fe20afb917 [AutoDiff] NFC: gardening.
Remove `SILAutoDiffIndices` argument from `LinearMapInfo` methods.
Use the `SILAutoDiffIndices` stored in `LinearMapInfo` instead.
2020-04-07 11:01:00 -07:00
Dan Zheng
04686a091f [AutoDiff] NFC: add ASTMangler entry points for AutoDiff-generated decls.
Add `ASTMangler::mangleAutoDiffGeneratedDeclaration`.
2020-04-07 11:00:46 -07:00
Meghana Gupta
b1ea908e6d In TempRVO, be more explicit on handling non - onstack partial_apply (#30837)
We should not optimize away the copy_addr of a guaranteed parameter of a
non-onstack partial_apply.
This is not a bug currently, because TempRVO checks if the lifetime end
points of the temp object are destroy_addr's in
TempRValueOptPass::checkTempObjectDestroy.
This change makes it explicit on which partial_apply's are ok to
optimize.

rdar://61349083
2020-04-07 10:45:46 -07:00
Pavel Yaskevich
bd44fb3ef3 Merge pull request #30838 from xedin/rdar-61347993
[ConstraintSystem] Don't bind result type of an empty closure too early
2020-04-07 10:40:12 -07:00
Marc Rasi
78ac5eb0a3 add PointerUnion for parsed vs deserialized derivative attr 2020-04-07 10:25:30 -07:00
eeckstein
64c0bb85f9 Merge pull request #30849 from eeckstein/fix-compile-time
SIL Optimizer: Fix two compile time issues
2020-04-07 18:16:18 +02:00
Slava Pestov
dbaa61953e AST: Fix accessibility checking in opaque type archetype substitution logic
We were failing to replace opaque types with their underlying type
upon encountering an internal type from the current module. This
could happen when the internal type appeared in generic substitutions,
for example when calling a protocol extension method.

Fixes <rdar://problem/60951353>.
2020-04-07 12:13:38 -04:00
Arnold Schwaighofer
66ea6e6f38 Merge pull request #30839 from aschwaighofer/irgen_fix_partial_apply_on_stack_indirect
IRGen: Fix capture of indirect values in ``[onstack]`` closures
2020-04-07 06:09:00 -07:00
Erik Eckstein
756c7f9c49 SILOptimizer: fix a compile time problem in the inliner
When inlining many functions in a very large basic block, the splitting of the block at the call sites is quadratic, when traversing in forward order.
Traversing backwards, fixes the problem.

rdar://problem/56268570
2020-04-07 15:00:48 +02:00
Rintaro Ishizaki
28de43b7ca [CodeCompletion] Trim whitespaces around the content 2020-04-07 00:50:43 -07:00
Rintaro Ishizaki
c633da047d [CodeCompletion] Add IDE test case for annotated description 2020-04-07 00:50:43 -07:00
Rintaro Ishizaki
d54e70cd70 [CodeCompletion] Option to swift-ide-test to test annotated results 2020-04-07 00:50:43 -07:00
Rintaro Ishizaki
ad8415a5c2 [CodeCompletion] Include 'annotated' to cache key 2020-04-07 00:46:14 -07:00
Rintaro Ishizaki
773a464e83 [CodeCompletion] Add an option to emit annotated description 2020-04-07 00:46:14 -07:00
Slava Pestov
05352ceaab Merge pull request #30840 from slavapestov/dwarf-mangler-substitutions-fix
ASTMangler: Fix substitution round-tripping in the DWARF mangler
2020-04-06 23:37:09 -04:00
Ravi Kandhadai
b57a1d7c0e [Sema] Add miscellaneous sema diagnostics to check that the new os log
APIs and atomic operations are passed compile-time constants for
certain arguments.
2020-04-06 18:41:13 -07:00
Cyndy Ishida
9e916abf41 Merge pull request #30831 from cyndyishida/tbdv4-switch
[TBDGen] update tbd version
2020-04-06 18:38:25 -07:00
Holly Borla
6375481ea4 [Diagnostics] In DefineMemberBasedOnUse::diagnoseForAmbiguity, use
the base type from each solution instead of only the base type from
the first solution.
2020-04-06 17:35:31 -07:00
Marc Rasi
be9d35cece Merge branch 'master' into derivative-attr-serialization 2020-04-06 16:58:08 -07:00
Dan Zheng
fccfa29240 [AutoDiff upstream] Update LoadableByAddress. (#30825)
Update LoadableByAddress to handle AutoDiff-related instructions:
- `differentiable_function`
- `differentiable_function_extract`
- `linear_function`
- `linear_function_extract`
- `differentiability_witness_function`
2020-04-06 16:47:38 -07:00
Pavel Yaskevich
04e2795a03 [ConstraintSystem] Don't bind result type of an empty closure too early
Instead of setting empty closure (`{}`) result type to be `Void`
while generating constraints, let's allocate a new type variable
instead and let it be bound to `Void` once the body is opened.

This way we can support an interaction with function builders which
would return a type different from `Void` even when applied to empty closure.

Resolves: rdar://problem/61347993
2020-04-06 15:55:55 -07:00
Slava Pestov
3e4b95f234 ASTMangler: Fix substitution round-tripping in the DWARF mangler
When mangling sugared types for DWARF debug info, we would
occassionally mix generic parameter types from different
generic environments. Since the mangling for a generic
parameter type only recorded the depth and the index, even
for distinct sugared forms, the remangler would produce a
more 'compact' mangling, by folding together generic parameters
that have the same depth/index, but distinct sugarings in the
AST.

Prevent this from happening by desugaring DWARF types the
correct amount, substituting away generic parameters while
preserving everything else.

Also, re-enable the round-trip verification with the remangler.

Fixes <rdar://problem/59496022>, <https://bugs.swift.org/browse/SR-12204>.
2020-04-06 18:19:57 -04:00
Stephen Canon
248c554524 Add Float16 to stdlib (#30130)
Add Float16 (IEEE 754 binary16) to the standard library, plus assorted runtime support operations.

Swift Evolution thread: https://forums.swift.org/t/se-0277-float16/33546
2020-04-06 17:57:44 -04:00
Arnold Schwaighofer
5ab6df8f94 IRGen: Fix capture of indirect values in `[onstack]` closures
A [onstack] closure does not take ownership of its arguments. It is
therefore not correct to use an initWithTake copy of indirect arguments.

Instead we just capture the address of the indirect argument.

rdar://61261982
2020-04-06 13:23:34 -07:00
Hamish Knight
d6a6df2cf6 [CS] Fix invalid key path crasher (#30832)
[CS] Fix invalid key path crasher
2020-04-06 12:14:38 -07:00
Pavel Yaskevich
cbf3cab966 Merge pull request #30746 from ismetanin/fix-it-for-removing-escaping-from-optional-closure-parameter
Add new error diagnostic for escaping optional closures
2020-04-06 12:03:42 -07:00
Arnold Schwaighofer
c34739ce45 Merge pull request #30828 from aschwaighofer/irgen_fix_private_opaque_type_descriptor
Opaque type substitution also needs to take the access of a opaque ty…
2020-04-06 11:19:19 -07:00
Slava Pestov
549f630c40 Merge pull request #30809 from slavapestov/curry-thunk-source-range-fix
Sema: Fix source range for curry thunks
2020-04-06 13:37:01 -04:00
Luciano Almeida
08904ffe3f [SR-12242] Apply to Arg involving ConstraintLocator::GenericArgument diagnostics improvement (#30814)
* [CSDiagnostics] Handle arg to param generic when locator points to ConstraintLocator::GenericArgument

* [test] Add SR-12242 test case

* [CSDiagnostics] Handle arg to param on Generic mismatch as a fallback diagnostic

* [CSDiagnostics] Make assign diagnostics in GenericMismatchFailure handle more cases

* [test] Adding test cases for assign expr in GenericMismatch diagnostics

* [CSDiagnostics] Improving inout to pointer argument conversions with optionals diagnostics
2020-04-06 10:25:02 -07:00
Hamish Knight
3339ea4f91 [CS] Fix invalid key path crasher
Previously we were bailing early on encountering
an optional chain in the key path. However this
could cause us to miss invalid components further
down the line. Instead, set a flag and force the
key path to be read-only if we encountered an
optional chain.

Resolves SR-12519.
2020-04-06 10:14:19 -07:00
Arnold Schwaighofer
f887422a6c Opaque type substitution also needs to take the access of a opaque type decl into account.
Otherwise, we can access an opaque type descriptor that is private to a
translation unit.

rdar://60123853
2020-04-06 09:16:28 -07:00
Dan Zheng
83f6714334 [AutoDiff] Start fixing SR-12526.
Start fixing SR-12526: `@derivative` attribute cross-module deserialization
crash. Remove original `AbstractFunctionDecl *` from `DerivativeAttr` and store
`DeclID` instead, mimicking `DynamicReplacementAttr`.
2020-04-06 06:37:23 -07:00
Dan Zheng
0c1d4b5adf [AutoDiff] Enable cross-file derivative registration.
Lift temporary cross-file derivative registration restriction.

`@derivative` attribute type-checking simplications coming soon: TF-1099.
Original function and derivative function must have same access level, with one
exception: public original functions may have internal `@usableFromInline`
derivatives.
2020-04-06 02:36:02 -07:00
Dan Zheng
d93a818a37 [AutoDiff upstream] Add PullbackEmitter.
`PullbackEmitter` is a visitor that emits pullback functions. It implements
reverse-mode automatic differentiation, along with `VJPEmitter`.

Pullback functions take derivatives with respect to outputs and return
derivatives with respect to inputs. Every active value/address in an original
function has a corresponding adjoint value/buffer in the pullback function.

Pullback functions consume pullback structs and predecessor enums constructed
by VJP functions.
2020-04-05 20:35:35 -07:00
Dan Zheng
1775e8ae16 [AutoDiff upstream] Add VJPEmitter.
`VJPEmitter` is a cloner that emits VJP functions. It implements reverse-mode
automatic differentiation, along with `PullbackEmitter`.

`VJPEmitter` clones an original function, replacing function applications with
VJP function applications. In VJP functions, each basic block takes a pullback
struct (containing callee pullbacks) and produces a predecessor enum: these data
structures are consumed by pullback functions.
2020-04-05 20:35:35 -07:00
Dan Zheng
fa405e69c4 [AutoDiff upstream] Add LinearMapInfo.
`LinearMapInfo` contains information about linear map structs and branching
trace enums, which are auxiliary data structures created by the differentiation
transform.

These data structures are constructed in JVP/VJP functions and consumed in
differential/pullback functions.
2020-04-05 20:35:35 -07:00
Dan Zheng
55ac2c0e46 [AutoDiff upstream] Add common differentiation thunking utilities. 2020-04-05 20:35:35 -07:00
Dan Zheng
8081482b57 [AutoDiff upstream] Add common SIL differentiation utilities. 2020-04-05 20:35:35 -07:00
Dan Zheng
bb6d4ebd9f [AutoDiff upstream] Add differentiable activity analysis.
Differentiable activity analysis is a dataflow analysis which marks values in
a function as varied, useful, or active (both varied and useful).

Only active values need a derivative.
2020-04-05 20:35:30 -07:00