Commit Graph

58361 Commits

Author SHA1 Message Date
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
Hamish Knight
b179a3966b [CS] A couple of minor cleanups (#30582)
[CS] A couple of minor cleanups
2020-03-23 10:39:38 -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
cc9c851856 Add direct operator lookup requests
Introduce DirectOperatorLookupRequest &
DirectPrecedenceGroupLookupRequest that lookup
operator and precedence groups within a given
file or module without looking through imports.

These will eventually be used as the basis for the
new operator lookup implementation, but for now
just use them when querying lookup results from
serialized module files.
2020-03-23 09:17:58 -07:00
Hamish Knight
9656a0491e Allow OperatorLookupDescriptor to hold a file or module 2020-03-23 09:17:58 -07:00
Hamish Knight
a502246f34 [AST] Add OperatorFixity
Use this instead of DeclKind in a few places.
2020-03-23 09:17:58 -07:00
Hamish Knight
e5952ab7fe Fix a couple of invalid location diagnostics 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
e0c4fa2d92 SILOptimizer: add a LICM pass at mid-level in the pass pipeline.
It's needed to hoist global_init calls.
2020-03-23 15:53:23 +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
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
Dan Zheng
603db8c954 [AutoDiff upstream] Add @differentiable function IRGen.
Lower `@differentiable` and `@differentiable(linear)` functions as structs of
function pointers.
2020-03-22 23:52:28 -07:00
Hamish Knight
e71d921e43 [CS] Re-introduce some assertions
These FIXMEs appear to now be outdated.

This commit also adds an additional assertion in
`bindTypeVariable`.
2020-03-22 22:58:48 -07:00
Hamish Knight
c74a7512f7 [CS] NFC: Remove OverloadChoiceKind::BaseType
This doesn't appear to be used any more.
2020-03-22 22:51:58 -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
11551e13d0 [AutoDiff] NFC: formatting. (#30573)
Run `clang-format` on changes in https://github.com/apple/swift/pull/30564.
2020-03-22 21:30:33 -07:00
Michael Gottesman
51bc44e482 Merge pull request #30571 from gottesmm/pr-10e12f0db62b5bcf06e30b8e9ad3da073f2213e6
[passmanager] Move SILOptimizerRequests.cpp into ./lib/SILOptimizer/PassManager/*
2020-03-22 20:53:48 -07: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
Michael Gottesman
15da505b2e [passmanager] Move SILOptimizerRequests.cpp into ./lib/SILOptimizer/PassManager/*
I am doing this move for two reasons:

1. This file only works directly with parts of the PassManager.
2. In the SILOptimizer, we do not have files in the top level of the file tree
and instead group them in one of the subject subfolders.
2020-03-22 16:22:40 -07:00
Michael Gottesman
e9a3c7f26b Merge pull request #30497 from gottesmm/pr-71c57ac72c9ecc07f75dd86474bf57988d7aa006
[ownership] Convert a few small visitor methods to be const.
2020-03-22 16:18:50 -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
Robert Widmann
d4a0b673dd Merge pull request #30547 from CodaFi/a-quick-game-of-operation
[NFC] Remove SourceFile's Operator Lookup Entrypoints
2020-03-21 15:14:33 -07:00
Owen Voorhees
768c4385cf [DiagnosticVerifier] More accurate wording when printing diagnostics from external sources 2020-03-21 15:11:46 -07:00
Robert Widmann
425bd50f76 [Gardening] Remove some parameters obviated by OperatorLookup::map_ptr 2020-03-21 11:34:52 -07:00
Robert Widmann
c136a0b190 [NFC] Remove SourceFile's Operator Lookup Entrypoints
Now that this is requestified, the extra level of indirection serves no
purpose.
2020-03-21 11:19:46 -07:00
pi1024e
c8fa56600f Make booleans const 2020-03-21 12:56:56 -04:00
Robert Widmann
d3cade9300 Merge pull request #30534 from pi1024e/Optimizations
Remove redundant conditional check for true and false when the boolean is right there.
2020-03-21 08:19:35 -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
3825656261 [Sema] Tidy up checkContextualRequirements() 2020-03-21 05:47:54 +03:00
Anthony Latsis
1a4fe77af8 Remove some dead code from PrintAST 2020-03-21 05:31:50 +03:00
Anthony Latsis
a826da5979 [Sema] Fixits for assoc. type restatement hints should account for where clauses 2020-03-21 05:31:37 +03:00
Robert Widmann
076a24709b Merge pull request #30544 from CodaFi/standard-operating-procedure
[NFC] Define LookupOperatorRequest and Friends
2020-03-20 17:34:38 -07:00
Robert Widmann
6f0c54f3df Merge pull request #30535 from pi1024e/JSON
JSON trailing comma fix
2020-03-20 17:25:07 -07:00
swift-ci
41301c2597 Merge pull request #30542 from marcrasi/fix-autocomplete-crash-callasfunction 2020-03-20 16:57:49 -07:00
Doug Gregor
32be6f58f6 [Property wrappers] Handle composition and autoclosures.
Fixes the test case from rdar://problem/58986940.
2020-03-20 16:56:34 -07:00
pi1024e
647db46581 Remove redundant boolean checks 2020-03-20 19:44:57 -04:00
Dan Zheng
0374da60d1 [AutoDiff] Update SIL derivative function type calculation. (#30538)
Update SIL derivative function type calculation for substituted function types.
`SILFunctionType::getAutoDiff{Derivative,Transpose}FunctionType` now handle
substituted original function types.

The derivative type of a (un)substituted original function type is also
(un)substituted.
2020-03-20 15:56:13 -07:00
Robert Widmann
bfe23bba5b Define LookupOperatorRequest and Friends
Turn macro metaprogramming into template metaprogramming by defining a new kind of request that runs operator lookups.

This is the final piece of the puzzle for requestification of the current referenced name tracker system.
2020-03-20 15:50:12 -07:00
Robert Widmann
9d6d672494 Rename LookupPrecedenceGroupRequest to ValidatePrecedenceGroupRequest
Make way for a new kind of name lookup request for operators
2020-03-20 15:47:36 -07:00
Rintaro Ishizaki
0b1dbbda5f Merge pull request #30525 from rintaro/ide-completion-rdar57622639
[LookupVisibleDecls] Tweak unquialified lookup
2020-03-20 15:32:36 -07:00
Joe Groff
ee08197010 Factor appendAnyProtocolConformance out of the conformance mangling.
We want to be able to use mangled names to refer to protocol conformances in addition to type
metadata. Provide an ASTMangler method that can render an arbitrary abstract or concrete
`ProtocolConformanceRef`, factoring it out of the code used to emit conditional conformance arguments
in `appendProtocolConformance`.
2020-03-20 15:06:42 -07:00
pi1024e
fc3e4bed77 JSON trailing comma fix 2020-03-20 17:59:24 -04:00