Commit Graph

24822 Commits

Author SHA1 Message Date
Hamish Knight
ab9b6d7e11 Requestify scoped import validation
Move the validation of scoped imports into a
request, and force the request when we're
type-checking a primary file. This has the nice
bonus of no longer running the validation for
secondary files.

The use of `ModuleDecl::getTopLevelModule` also
allows us to correctly retrieve the top-level
module for a Clang submodule, rather than
potentially retrieving the Swift module in a mixed
source project.

Resolves SR-12265.
2020-02-25 13:29:52 -08:00
Arnold Schwaighofer
f6651d6d45 IRGen: Enable TypeLayout based value witness generation
rdar://51988441
2020-02-25 12:31:30 -08:00
Xi Ge
8c2a041822 Front-end: add an option to not lock interface file when building module
This could help fix a flaky test.

Related to: rdar://58578342
2020-02-25 12:13:14 -08:00
Rintaro Ishizaki
571d09a8a2 Merge pull request #29955 from AnthonyLatsis/operator-diag-qoi
[Parse] Improve recovery from and diagnostics for invalid operator names
2020-02-25 10:11:26 -08:00
Joe Groff
0a318a39f1 Merge pull request #29644 from jckarter/subst-function-type-shakeout
Enable substituted SIL function types
2020-02-25 09:47:10 -08:00
Dmitri Gribenko
a9fc2658a7 Merge pull request #30029 from gribozavr/rm-algorithm
Replaced include/swift/Basic/Algorithm.h with calls to standard algorithms
2020-02-25 08:22:09 +01:00
Hamish Knight
d9182af63d [AST] Introduce ModuleDecl::getTopLevelModule
This can be used to retrieve the Swift module
wrapper for a Clang submodule's top-level module.
2020-02-24 20:10:13 -08:00
Xi Ge
853c0f545b Merge pull request #29974 from nkcsgexi/53776566
ABIChecker: ignore accessors with forced static dispatch
2020-02-24 14:25:06 -08:00
Xi Ge
c585fd6748 ABIChecker: contains only opaque accessors for ABI/API checking
rdar://53776566
2020-02-24 12:23:03 -08:00
Joe Groff
cf0e09d9c5 Preserve conformances for upper bound constraints when lowering SILFunctionTypes 2020-02-24 12:14:21 -08:00
Joe Groff
19770e6471 IRGen: Keep substituted function types out of debug info for now. 2020-02-24 12:14:21 -08:00
Joe Groff
dcd432a1bc Turn on substituted SILFunctionTypes by default 2020-02-24 12:14:21 -08:00
Joe Groff
96a5d2cae0 SILCombiner: Recognize convert_function patterns that only change substitutions
We can eliminate `convert_function`s that are immediately used as the callee of
an `apply` or `partial_apply`, as well as stacked `convert_function`s that may
arise from this transformation.
2020-02-24 12:14:21 -08:00
Joe Groff
1ffafbe77b SIL: Compute result ownership by substituting correct function type 2020-02-24 12:14:21 -08:00
Joe Groff
9c9bf567f7 SIL: Preserve upper bound constraints for substitutions into nominal types.
When extracting substitutions during type lowering, we can't discard protocol constraints
in positions where the substitution is for a nominal type's generic arguments, since associated
types on that protocol may affect the nominal type's ABI.
2020-02-24 12:14:21 -08:00
Joe Groff
5a15d1249c Parse SILFunctionType brackets using consumeStartingLess/Greater.
With the substituted function type syntax, it's easy to end up with multiple angle brackets,
so we should handle token splitting to parse things like `Optional<<A> in (A) -> () for <Int>>`
the expected way.
2020-02-24 12:14:21 -08:00
Arnold Schwaighofer
e35ae37366 Merge pull request #29999 from aschwaighofer/irgen_use_value_witness_instead_of_outlined_value_op
IRGen: Optionally use value witness instead of outlined value functions
2020-02-24 11:03:10 -08:00
Dmitri Gribenko
d4ff77550e Replaced include/swift/Basic/Algorithm.h with calls to standard algorithms
LLVM now requires C++14, and the header says the algorithms are
backported from C++14.
2020-02-24 14:52:48 +01:00
Jonathan Keller
620fba6a1f [SILOptimizer] fix KeyPathProjector memory management
I was inconsistently providing initialized or uninitialized memory
to the callback when projecting a settable address, depending on
component type. We should always provide an uninitialized address.
2020-02-21 15:34:17 -08:00
Jonathan Keller
44d211fa17 [SILOptimizer] Generalize optimization of static keypaths
We have an optimization in SILCombiner that "inlines" the use of compile-time constant key paths by performing the property access directly instead of calling a runtime function (leading to huge performance gains e.g. for heavy use of @dynamicMemberLookup). However, this optimization previously only supported key paths which solely access stored properties, so computed properties, optional chaining, etc. still had to call a runtime function. This commit generalizes the optimization to support all types of key paths.
2020-02-21 15:34:17 -08:00
Holly Borla
9f09add09b Merge pull request #29966 from hborla/type-check-type-eraser-attribute
[Sema] Implement type checking for the `_typeEraser` attribute
2020-02-21 14:12:59 -08:00
Joe Groff
83668f9e4e Merge pull request #29946 from apple/revert-28799-master
Revert "[SILOptimizer] Generalize optimization of static keypaths"
2020-02-21 12:47:08 -08:00
Arnold Schwaighofer
0dd8974dc1 Add a flag to disable type layout based lowering 2020-02-21 12:10:58 -08:00
Arnold Schwaighofer
b7a58c0f96 IRGen: Optionally use value witness instead of outlined value functions
... if type layout based value witness emission is enabled.

rdar://51988441
2020-02-21 12:10:58 -08:00
Dan Zheng
697c722a5f [AutoDiff] Type-checking support for inout parameter differentiation. (#29959)
Semantically, an `inout` parameter is both a parameter and a result.

`@differentiable` and `@derivative` attributes now support original functions
with one "semantic result": either a formal result or an `inout` parameter.

Derivative typing rules for functions with `inout` parameters are now defined.

The differential/pullback type of a function with `inout` differentiability
parameters also has `inout` parameters. This is ideal for performance.

Differential typing rules:
- Case 1: original function has no `inout` parameters.
  - Original:     `(T0, T1, ...) -> R`
  - Differential: `(T0.Tan, T1.Tan, ...) -> R.Tan`
- Case 2: original function has a non-wrt `inout` parameter.
  - Original:     `(T0, inout T1, ...) -> Void`
  - Differential: `(T0.Tan, ...) -> T1.Tan`
- Case 3: original function has a wrt `inout` parameter.
  - Original:     `(T0, inout T1, ...) -> Void`
  - Differential: `(T0.Tan, inout T1.Tan, ...) -> Void`

Pullback typing rules:
- Case 1: original function has no `inout` parameters.
  - Original: `(T0, T1, ...) -> R`
  - Pullback: `R.Tan -> (T0.Tan, T1.Tan, ...)`
- Case 2: original function has a non-wrt `inout` parameter.
  - Original: `(T0, inout T1, ...) -> Void`
  - Pullback: `(T1.Tan) -> (T0.Tan, ...)`
- Case 3: original function has a wrt `inout` parameter.
  - Original: `(T0, inout T1, ...) -> Void`
  - Pullback: `(inout T1.Tan) -> (T0.Tan, ...)`

Resolves TF-1164.
2020-02-21 09:47:53 -08:00
Arnold Schwaighofer
e8a7b1bd75 Merge pull request #29859 from aschwaighofer/irgen_typelayout_based_value_witness
IRGen: Type layout based value witness generation
2020-02-21 08:24:17 -08:00
Dan Zheng
d7ab0c1547 [AutoDiff] Fix "'alignof' to an incomplete type" error in AutoDiff.h. (#29983)
Using `DenseMap<SILAutoDiffDerivativeFunctionKey, ...>` in a file that includes
AutoDiff.h but not Types.h produced the following error:
```
error: invalid application of 'alignof' to an incomplete type 'swift::SILFunctionType'
```

Fix the error by:
- Including TypeAlignments.h in AutoDiff.h.
- Adding an alignment forward declaration for `SILFunctionType` to TypeAlignments.h.
2020-02-20 22:31:09 -08:00
Slava Pestov
b1c69bd115 ABI: Introduce TargetRelativeProtocolRequirementPointer 2020-02-20 22:23:52 -05:00
Slava Pestov
dd94d57504 Merge pull request #29972 from slavapestov/clean-up-metadata-relative-pointers
ABI: Clean up context and method descriptor pointers
2020-02-20 22:22:41 -05:00
Owen Voorhees
1b078531ca Merge pull request #29970 from owenv/remove-unused-diags-2
Remove some unused Sema diagnostic messages
2020-02-20 15:09:51 -08:00
Slava Pestov
a98f446f5f ABI: Clean up context and method descriptor pointers 2020-02-20 17:20:19 -05:00
Holly Borla
2185f431ad [TypeCheckAttr] Improve diagnostics and candidate notes for typeEraser in
the case where the type eraser has no viable initializers.
2020-02-20 12:50:04 -08:00
Anthony Latsis
1c0c397214 [Parse] Improve recovery from and diagnostics for invalid operator names 2020-02-20 22:11:18 +03:00
Holly Borla
3d18c07640 [TypeCheckAttr] Implement access control checking for the typeEraser
attribute.
2020-02-20 10:57:10 -08:00
David Ungar
e6bbb8d01f Merge pull request #29948 from davidungar/unit-test-users-v5a
[Incremental, NFC] Rearrange code creating `SourceFileDepGraph`
2020-02-20 08:18:21 -07:00
Dan Zheng
f5b40d6705 [AutoDiff upstream] Add SIL derivative function type caching. (#29953)
Upstream https://github.com/apple/swift/pull/29590:
cache `SILFunctionType::getAutoDiffDerivativeFunctionType` results.
2020-02-20 05:17:39 -08:00
swift-ci
5e030b57a2 Merge pull request #29918 from dan-zheng/derivative-attr-diagnostics 2020-02-19 23:26:54 -08:00
David Ungar
b367d2ebec Rename files and classes involved in SourceFileDepGraphConstruction 2020-02-19 23:57:23 -07:00
Holly Borla
f141b4da3c [TypeCheckAttr] Provide better error messages for a typeEraser that
has invalid init candidates.
2020-02-19 21:23:57 -08:00
Dan Zheng
e5e9fce8bf [AutoDiff upstream] Upstream attribute type-checking changes. (#29945)
- Support `@differentiable` and `@derivative` attributes for original
  initializers in final classes. Reject original initializers in non-final
  classes.
- Synchronize tests.
2020-02-19 21:17:45 -08:00
Owen Voorhees
2d1aa2d8ee Remove some unused Sema diagnostic messages 2020-02-19 20:50:59 -08:00
Joe Groff
f353c40ce9 Revert "[SILOptimizer] Generalize optimization of static keypaths" 2020-02-19 19:58:15 -08:00
Pavel Yaskevich
8af4f2ddb3 Merge pull request #29493 from LucianoPAlmeida/SR-11421-checked-cast-diag
[SR-11421][Diagnostics] Tailored diagnostic for checked downcast with literals
2020-02-19 17:29:30 -08:00
Holly Borla
ebb727c0a3 [TypeCheckAttr] Allow a type eraser initializer to have more than one
generic requirement.
2020-02-19 17:07:30 -08:00
Alexis Laferrière
0e7029dfb5 Use "SPI group" for the name used in an @_spi attribute 2020-02-19 14:18:11 -08:00
Alexis Laferrière
901392896d [Frontend] Output the private module interface with the SPI info 2020-02-19 14:17:14 -08:00
Alexis Laferrière
2e73cb44fd [Sema] Type-check the use and exposability of SPI decls 2020-02-19 14:17:14 -08:00
Alexis Laferrière
56880d7e70 [Sema] Diagnose the use of SPI on unsupported decls 2020-02-19 14:17:14 -08:00
Alexis Laferrière
501f458879 [AST] Intro service lookupImportedSPIs to find direct SPI imports of a module 2020-02-19 14:17:14 -08:00
Alexis Laferrière
3552f800a9 [Parser] Parse the SPI attribute 2020-02-19 14:17:14 -08:00