Commit Graph

24822 Commits

Author SHA1 Message Date
Hamish Knight
312f7ddc50 Parse Swift decls in one shot
Instead of interleaving typechecking and parsing
for SIL files, first parse the file for Swift
decls by skipping over any intermixed SIL decls.
Then we can perform type checking, and finally SIL
parsing where we now skip over Swift decls.

This is an intermediate step to requestifying the
parsing of a source file for its Swift decls.
2020-02-04 13:04:50 -08:00
swift-ci
973405621c Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-04 13:03:59 -08:00
Hamish Knight
dfeb482bf4 NFC: Rename isStartOfDecl -> isStartOfSwiftDecl
Make it clear that this function doesn't deal with
SIL decls.
2020-02-04 13:00:41 -08:00
Dan Zheng
849bd62a26 [AutoDiff upstream] Add SIL differentiability witnesses. (#29623)
SIL differentiability witnesses are a new top-level SIL construct mapping
"original" SIL functions to derivative SIL functions.

SIL differentiability witnesses have the following components:
- "Original" `SILFunction`.
- SIL linkage.
- Differentiability parameter indices (`IndexSubset`).
- Differentiability result indices (`IndexSubset`).
- Derivative `GenericSignature` representing differentiability generic
  requirements (optional).
- JVP derivative `SILFunction` (optional).
- VJP derivative `SILFunction` (optional).
- "Is serialized?" bit.

This patch adds the `SILDifferentiabilityWitness` data structure, with
documentation, parsing, and printing.

Resolves TF-911.

Todos:
- TF-1136: upstream `SILDifferentiabilityWitness` serialization.
- TF-1137: upstream `SILDifferentiabilityWitness` verification.
- TF-1138: upstream `SILDifferentiabilityWitness` SILGen from
  `@differentiable` and `@derivative` attributes.
- TF-20: robust mangling for `SILDifferentiabilityWitness` names.
2020-02-04 12:53:27 -08:00
swift-ci
20124f3397 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-04 12:22:51 -08:00
Suyash Srijan
543d649278 [Diagnostics] Warn when the result of a Void-returning function is ignored (by assigning into '_') (#29576) 2020-02-04 20:19:37 +00:00
John McCall
319cc795d8 Add a simple TaggedUnion defined in terms of ExternalUnion. NFC. 2020-02-04 15:05:39 -05:00
swift-ci
712d7829d1 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-04 09:03:29 -08:00
Pavel Yaskevich
956b9f27b4 Merge pull request #29628 from owenv/condition_diags
[Diagnostics] Improve diagnostics for optional/integer as boolean condition
2020-02-04 08:49:36 -08:00
swift-ci
4324c7c5ce Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-03 22:43:48 -08:00
swift-ci
7e11809329 Merge pull request #29632 from gottesmm/pr-0071f3d29aed40bc5467e019b4191f7ce624e042 2020-02-03 22:43:16 -08:00
Owen Voorhees
166555c34f [Diagnostics] Better diagnostic for integer used as a boolean condition 2020-02-03 21:20:41 -08:00
Michael Gottesman
377b7b131e [pattern-match] Make sure that when we are extracting a tuple that we fail if we have a non-instruction result.
The specific problem here is this:

```
sil @builtin_array_opt_index_raw_pointer_to_index_addr_no_crash : $@convention(thin) (Builtin.RawPointer, Builtin.
Word) -> Builtin.Word {
bb0(%0 : $Builtin.RawPointer, %1 : $Builtin.Word):
  %2 = index_raw_pointer %0 : $Builtin.RawPointer, %1 : $Builtin.Word
  %3 = pointer_to_address %2 : $Builtin.RawPointer to [strict] $*Builtin.Word
  %4 = load %3 : $*Builtin.Word
  return %4 : $Builtin.Word
}
```

before this commit, we unconditionally called getDefiningInstruction when
looking at %1. This of course returned a null value causing the compiler to
crash in a dyn_cast<TupleExtractInst>().

rdar://59138369
2020-02-03 21:02:13 -08:00
Robert Widmann
676436640c Add SILGenSourceFileRequest
Replace SILGenModule::emitSourceFile with SILGenSourceFileRequest so we
have an explicit source file to associate any lookups with.
2020-02-03 18:26:19 -08:00
swift-ci
0fff1d6f4d Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-03 17:42:52 -08:00
Dan Zheng
0c0018fb9b [AutoDiff] Improve getConstrainedDerivativeGenericSignature helper. (#29620)
Move `getConstrainedDerivativeGenericSignature` under `autodiff` namespace.
Improve naming and documentation.
2020-02-03 17:40:49 -08:00
Owen Voorhees
4aca39e18e [Diagnostics] Provide a better fix-it when trying to boolean-negate an optional 2020-02-03 17:40:03 -08:00
swift-ci
782b4e1bfa Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-03 15:42:56 -08:00
swift-ci
9ca298a01b Merge pull request #29618 from CodaFi/constant-contact 2020-02-03 15:34:55 -08:00
Robert Widmann
4be78281c2 [Gardening] Const-qualify some PoundDiagnosticDecl members 2020-02-03 13:54:53 -08:00
Xi Ge
273500ec76 Driver: add an option to avoid emitting .swiftsourceinfo files 2020-02-03 13:05:23 -08:00
swift-ci
eb0755b311 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-02 23:43:50 -08:00
Michael Gottesman
6c5c853339 [ownership] Change guaranteed args from transformation terminators to not require end_borrows.
For those who are unaware, a transformation terminator is a terminator like
switch_enum/checked_cast_br that always dominate their successor blocks. Since
they dominate their successor blocks by design and transform their input into
the args form, we can validate that they obey guaranteed ownership semantics
just like a forwarding instruction.

Beyond removing unnecessary code bloat, this also makes it significantly more
easier to optimize/work with transformation terminators when converting @owned
-> @guaranteed since we do not need to find end_borrow points when the owned
value is consumed.

<rdar://problem/59097063>
2020-02-02 16:59:57 -08:00
swift-ci
28c1b2b698 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-02 15:42:54 -08:00
swift-ci
3c582f4c0e Merge pull request #29601 from gottesmm/pr-132affdd3523248eb7aada4eb4717867466c15f1 2020-02-02 15:34:25 -08:00
swift-ci
87ebe39aa3 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-02 14:42:56 -08:00
swift-ci
a33690456c Merge pull request #29599 from gottesmm/pr-762e321418ba69083a3400aa47cb65b0d34f5e37 2020-02-02 14:36:35 -08:00
Michael Gottesman
92864f1a60 [sil] Add SILArgument::getSingleTerminator() helper.
This is just like SILArgument::getSingleTerminatorOperand() except that it
returns the actual Terminator rather than the terminator's argument.
2020-02-02 13:54:18 -08:00
swift-ci
6c8c1bdd7c Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-02 13:42:52 -08:00
swift-ci
13072cf18e Merge pull request #29519 from gottesmm/pr-a38b5f72b7fe7f2e4482b0456b6e1cb080ec9540 2020-02-02 13:33:01 -08:00
Michael Gottesman
8f91b9e89a [ownership] Get rid of old entrypoint for creatingEndBorrow that takes the original value.
The original design was to make it so that end_borrow tied at the use level its
original/borrowed value. So we would have:

```
%borrowedVal = begin_borrow %original
...
end_borrow %borrowedVal from %original
```

In the end we decided not to use that design and instead just use:

```
%borrowedVal = begin_borrow %original
...
end_borrow %borrowedVal
```

In order to enable that transition, I left the old API for end_borrow that took
both original and borrowedVal and reimplemented it on top of the new API that
just took the borrowedVal (i.e. the original was just a dead arg).

Now given where we are in the development, it makes sense to get rid of that
transition API and move to just use the new API.
2020-02-02 12:57:58 -08:00
Michael Gottesman
70a417c3f5 [ownership] Refactor checked conversion from ArrayRef<SILInstruction *> -> ArrayRef<BranchPropagatedUser> onto BranchPropagatedUser.
A branch propagated user that isn't a cond_br is layout compatible with a
SILInstruction *. This helper function converts from ArrayRef<SILInstruction *>
-> ArrayRef<BranchPropagatedUser> but also in asserts builds checks that our
invariant (namely all of the 'SILInstruction *' are not cond_br.
2020-02-02 11:54:35 -08:00
Vlasov Anton
904bd0bf63 SR-5740 Refactoring action to convert if statement to switch 2020-02-02 12:44:48 +03:00
swift-ci
11f1cdca8f Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-31 13:44:28 -08:00
David Ungar
de9ffcb2ad Merge pull request #29551 from davidungar/type-fingerprints-on-by-default-5
[Incremental] Turn type-body-fingerprints on-by-default
2020-01-31 13:25:50 -08:00
swift-ci
b2583fd508 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-31 10:44:03 -08:00
Pavel Yaskevich
d24537f032 Merge pull request #29024 from xedin/diagnose-shadowing
[Diagnostics] Port name shadowing diagnostics
2020-01-31 10:39:58 -08:00
swift-ci
8d39f80af0 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-30 12:03:12 -08:00
David Ungar
38f599dcb7 Turn type-body-fingerprints on-by-default 2020-01-30 11:48:13 -08:00
David Ungar
d171b30d09 Allow fine-grained-dependency-include-intrafile in tests for compatibility with enabled type fingerprints. 2020-01-30 09:50:53 -08:00
swift-ci
86520fc853 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-29 19:03:10 -08:00
David Ungar
286781fc3e Add a unit test for an individual node change, & add ability to set fingerprints in unit tests. 2020-01-29 16:48:42 -08:00
David Ungar
2e1e4284ac Added ability to add fingerprint via # 2020-01-29 13:39:24 -08:00
swift-ci
efbfd13426 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-29 12:04:19 -08:00
Meghana Gupta
b8960133ff Add source annotation to SILPrinter under flag -sil-print-sourceinfo (#29444)
* Add source annotation to SILPrinter under flag -sil-print-sourceinfo

rdar://58365252
2020-01-29 11:45:58 -08:00
Adrian Prantl
4bd1ffc67f Serialize whether a VarDecl is a top-level global.
The current way that VarDecl::isLazilyInitializedGlobal() is implemented does
not work in the debugger, since the DeclContext of all VarDecls are deserialized
Swift modules. By adding a bit to the VarDecl we can recover the fact that a
VarDecl was in fact a global even in the debugger.

<rdar://problem/58939370>
2020-01-29 09:21:02 -08:00
Pavel Yaskevich
c9c20afe27 [Diagnostics] Port name shadowing diagnostics
Diagnose an attempt to reference a top-level name shadowed by
a local member e.g.

```swift
extension Sequence {
  func test() -> Int {
    return max(1, 2)
  }
}
```

Here `min` refers to a global function `min<T>(_: T, _: T)` in `Swift`
module and can only be accessed by adding `Swift.` to it, because `Sequence`
has a member named `min` which accepts a single argument.
2020-01-29 09:14:24 -08:00
swift-ci
3a1c28977d Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-29 08:04:01 -08:00
Pavel Yaskevich
dd094018de Merge pull request #29528 from xedin/anyobject-conversion-diagnostics
[Diagnostics] Port invalid conversion to AnyObject diagnostic
2020-01-29 08:03:50 -08:00
swift-ci
57393b28fa Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-29 01:44:04 -08:00