Commit Graph

11880 Commits

Author SHA1 Message Date
swift-ci
e1e6cb5311 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-23 03:23:49 -07:00
swift-ci
a7b4da6447 Merge remote-tracking branch 'origin/master' into master-next 2019-09-23 03:10:26 -07:00
David Zarzycki
a033d2b8a2 [AST] Fix debug typo 2019-09-23 11:58:09 +03:00
swift-ci
abcec82ca5 Merge remote-tracking branch 'origin/master' into master-next 2019-09-22 19:30:00 -07:00
swift-ci
25488fea80 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-22 19:24:20 -07:00
David Ungar
c25de6af75 Merge pull request #27221 from davidungar/A-9-17-astscope-off
[NFC, NameLookup, ASTScope] Bug fix for eager scope tree construction & better failure messages
2019-09-22 19:10:58 -07:00
David Ungar
5144341fe7 Count AST ancestor scopes instead of children when last expanded 2019-09-22 17:59:40 -07:00
David Ungar
b943a3987f Use separate bool to record expansion 2019-09-22 17:59:40 -07:00
David Ungar
7f834cdb54 renaming to ASTAncestor 2019-09-22 17:59:40 -07:00
David Ungar
10583f89c6 Ensure that reexpansion does not lose scopes. 2019-09-22 17:59:40 -07:00
David Ungar
5ca14099a1 Add comment 2019-09-22 17:59:40 -07:00
David Ungar
3c891f9532 Fully eager for printing, just eager enough for type-checking. 2019-09-22 17:59:40 -07:00
David Ungar
c17d9ae7bc Radar tagging 2019-09-22 17:59:40 -07:00
David Ungar
683310eb74 Ever expansion detection. WIP 2019-09-22 17:59:40 -07:00
David Ungar
c808eb5a27 Don't try to expand ASTSourceFileScope when eagerly building. 2019-09-22 17:59:40 -07:00
David Ungar
f33c4407dc Push range of extension scope after type, WIP 2019-09-22 17:59:39 -07:00
David Ungar
37b16e8b33 Tag cycles w/ radar 2019-09-22 17:59:39 -07:00
David Ungar
603cc05289 WIP lazy whole scopes 2019-09-22 17:59:39 -07:00
swift-ci
6afcaba05d Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-21 08:12:26 -07:00
swift-ci
7a21185ac1 Merge remote-tracking branch 'origin/master' into master-next 2019-09-21 08:11:08 -07:00
Robert Widmann
7f036f4fe4 Merge pull request #27289 from CodaFi/ah-well-on-to-the-next-one
Remove resolveExtension and validateExtension
2019-09-21 07:53:42 -07:00
swift-ci
5343bef360 Merge remote-tracking branch 'origin/master' into master-next 2019-09-21 02:29:31 -07:00
swift-ci
78ff7eae0f Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-21 02:23:44 -07:00
Michael Gottesman
b44158c704 Merge pull request #27284 from gottesmm/pr-492ee9b09850d10ed8d4b8bc54b10acc7c023ada
[polymorphic-builtins] Teach dataflow diagnostics how to emit an erro…
2019-09-21 02:10:23 -07:00
swift-ci
e42916176f Merge remote-tracking branch 'origin/master' into master-next 2019-09-20 22:29:40 -07:00
swift-ci
656afb783d Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-20 22:23:33 -07:00
Robert Widmann
b135928125 Drop CheckingWithValidSignature from the validation state machine
Now that the generic signature is computable on demand, this predicate is doubly useless.  All of the callers intended to ask "hasInterfaceType" anyways.
2019-09-20 22:22:49 -07:00
Robert Widmann
ae60618f3b Remove resolveExtension and validateExtension
Push the relevant work this was doing down into the callers.  Most of them didn't want to validate the entire extension and force its generic parameters, they just wanted to validate the nominal type.

We must eagerly validate the generic signature of extensions, though.  This avoids a class of cycles where non-generic members of an extension with a generic signaure will call through to getGenericSignatureOfContext and force the generic signature anyways.  When this calls through to protocol witness matching, the signature can be recursively computed.
2019-09-20 22:22:49 -07:00
Robert Widmann
e7fccde40c Directly detect the cyclic case while computing conditional requirement
The general class of cycle here is when validation asks for the generic signature which triggers requirement checking which forces us to ask for the generic signature of the extension again.  We should look into a more principled solution.

See rdar://55263708
2019-09-20 20:38:38 -07:00
swift-ci
5df0999ebc Merge remote-tracking branch 'origin/master' into master-next 2019-09-20 18:29:54 -07:00
swift-ci
9b7554bb2e Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-20 18:23:45 -07:00
Slava Pestov
b11e8ac95e Merge pull request #27280 from slavapestov/type-alias-sugar-prep
Preparations for subst() preserving sugared TypeAliasTypes
2019-09-20 21:22:47 -04:00
Owen Voorhees
6c5185f2e3 Improve diagnostic when attempting to pass an Array to a variadic argument
- Give a more specific diagnostic which indicates the parameter is variadic
- If the argument is an Array literal, offer to drop the brackets
2019-09-20 17:30:23 -07:00
Michael Gottesman
e90a68fa17 [polymorphic-builtins] Teach dataflow diagnostics how to emit an error if it sees an unspecialized polymorphic builtin.
This will ensure that if an expert user is using this feature and makes a
mistake as a result of tweaking their code, they get an error. This will ensure
they do not ship and look into why this is happening.

This is not intended to be used by anyone except for expert stdlib users.
2019-09-20 17:25:56 -07:00
swift-ci
a0025a6181 Merge remote-tracking branch 'origin/master' into master-next 2019-09-20 17:09:01 -07:00
swift-ci
d41eac4336 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-20 17:04:10 -07:00
Jordan Rose
27e881d97e [AST] Shrink CaptureInfo down to a PointerIntPair (#27261)
If there are any actual captures, a CaptureInfoStorage will be
allocated in the ASTContext, matching the previous behavior of
allocating the array of captures there.

No functionality change. I /tried/ to change the functionality to
assert everywhere capture info was used but hadn't explicitly been
computed, but it turns out we do that /all over the place/ for any
declaration that's been synthesized, imported, or deserialized. I
left in some groundwork for someone to make this more explicit (or
requestify it) in the future.
2019-09-20 17:01:44 -07:00
swift-ci
398ebd1992 Merge remote-tracking branch 'origin/master' into master-next 2019-09-20 16:49:51 -07:00
Brent Royal-Gordon
96e023d79b Merge pull request #27210 from brentdax/it-is-known
[NFC] Centralize lookup of NSCopying
2019-09-20 16:45:54 -07:00
swift-ci
71a99739b7 Merge remote-tracking branch 'origin/master' into master-next 2019-09-20 16:30:00 -07:00
swift-ci
92746ac538 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-20 16:23:30 -07:00
Pavel Yaskevich
81c7be86db Merge pull request #27107 from xedin/if-conditional-diag
[Diagnostics] Tailored diagnostic for "condition" expression
2019-09-20 16:15:49 -07:00
Slava Pestov
d395eb18ae AST: Remove LazyResolver::resolveProtocolEnvironment() 2019-09-20 17:59:56 -04:00
Pavel Yaskevich
72b61f55bf [Diagnostics] Tailored diagnostic for "condition" expression
Since all condition expressions supposed to be convertible
to `Bool`, let's use that type as contextual and produce a
tailored diagnostic.
2019-09-20 12:37:35 -07:00
taylorswift
87a6ba21a4 Merge remote-tracking branch 'upstream/master' into comparable-enums 2019-09-19 19:32:58 -05:00
swift-ci
1155f033a4 Merge remote-tracking branch 'origin/master' into master-next 2019-09-19 13:29:07 -07:00
swift-ci
f0d946690f Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-19 13:23:38 -07:00
Michael Gottesman
20c5dff4b5 [builtin] Implement polymorphic builtins for all BUILTIN_BINARY_OPERATIONs.
TLDR: This patch introduces a new kind of builtin, "a polymorphic builtin". One
calls it like any other builtin, e.x.:

```
Builtin.generic_add(x, y)
```

but it has a contract: it must be specialized to a concrete builtin by the time
we hit Lowered SIL. In this commit, I add support for the following generic
operations:

Type           | Op
------------------------
FloatOrVector  |FAdd
FloatOrVector  |FDiv
FloatOrVector  |FMul
FloatOrVector  |FRem
FloatOrVector  |FSub
IntegerOrVector|AShr
IntegerOrVector|Add
IntegerOrVector|And
IntegerOrVector|ExactSDiv
IntegerOrVector|ExactUDiv
IntegerOrVector|LShr
IntegerOrVector|Mul
IntegerOrVector|Or
IntegerOrVector|SDiv
IntegerOrVector|SRem
IntegerOrVector|Shl
IntegerOrVector|Sub
IntegerOrVector|UDiv
IntegerOrVector|Xor
Integer        |URem

NOTE: I only implemented support for the builtins in SIL and in SILGen. I am
going to implement the optimizer parts of this in a separate series of commits.

DISCUSSION
----------

Today there are polymorphic like instructions in LLVM-IR. Yet, at the
swift and SIL level we represent these operations instead as Builtins whose
names are resolved by splatting the builtin into the name. For example, adding
two things in LLVM:

```
  %2 = add i64 %0, %1
  %2 = add <2 x i64> %0, %1
  %2 = add <4 x i64> %0, %1
  %2 = add <8 x i64> %0, %1
```

Each of the add operations are done by the same polymorphic instruction. In
constrast, we splat out these Builtins in swift today, i.e.:

```
let x, y: Builtin.Int32
Builtin.add_Int32(x, y)
let x, y: Builtin.Vec4xInt32
Builtin.add_Vec4xInt32(x, y)
...
```

In SIL, we translate these verbatim and then IRGen just lowers them to the
appropriate polymorphic instruction. Beyond being verbose, these prevent these
Builtins (which need static types) from being used in polymorphic contexts where
we can guarantee that eventually a static type will be provided.

In contrast, the polymorphic builtins introduced in this commit can be passed
any type, with the proviso that the expert user using this feature can guarantee
that before we reach Lowered SIL, the generic_add has been eliminated. This is
enforced by IRGen asserting if passed such a builtin and by the SILVerifier
checking that the underlying builtin is never called once the module is in
Lowered SIL.

In forthcoming commits, I am going to add two optimizations that give the stdlib
tool writer the tools needed to use this builtin:

1. I am going to add an optimization to constant propagation that changes a
"generic_*" op to the type of its argument if the argument is a type that is
valid for the builtin (i.e. integer or vector).

2. I am going to teach the SILCloner how to specialize these as it inlines. This
ensures that when we transparent inline, we specialize the builtin automatically
and can then form SSA at -Onone using predictable memory access operations.

The main implication around these polymorphic builtins are that if an author is
not able to specialize the builtin, they need to ensure that after constant
propagation, the generic builtin has been DCEed. The general rules are that the
-Onone optimizer will constant fold branches with constant integer operands. So
if one can use a bool of some sort to trigger the operation, one can be
guaranteed that the code will not codegen. I am considering putting in some sort
of diagnostic to ensure that the stdlib writer has a good experience (e.x. get
an error instead of crashing the compiler).
2019-09-19 11:42:10 -07:00
swift-ci
c9703db769 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-18 20:03:44 -07:00
swift-ci
b76e9ec111 Merge remote-tracking branch 'origin/master' into master-next 2019-09-18 19:49:09 -07:00