Commit Graph

3719 Commits

Author SHA1 Message Date
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
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
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
swift-ci
11550b4c0c Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-22 09:43:43 -08:00
Varun Gandhi
f6643af650 [Printer] Update printSIL to make sure LLDB doesn't break.
For more context, see:
1. https://github.com/apple/swift/pull/29239 - original PR which introduced
   the change, including an LLDB-side change.
2. The immediately preceding commit, which reverted this change.
3. https://github.com/apple/swift/pull/29350 which revealed some breakage
   caused by the changes in PR 29239 (unrelated to printing).
2020-01-22 09:05:39 -08:00
Varun Gandhi
d9a7a7d49e Revert "[Printer] Conditionally print Clang types in emitted SIL."
This reverts commit a27c5f0a16.
2020-01-22 09:04:52 -08:00
swift-ci
8d4bb2197f Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-22 09:03:43 -08:00
David Zarzycki
68b5505e89 [SIL] Fix -Wdocumentation warnings
In a27c5f0a16, these two parameters were
removed.
2020-01-22 07:15:51 -05:00
swift-ci
e28c558c72 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-21 09:43:46 -08:00
Varun Gandhi
f6e0db5bdc Merge pull request #29239 from varungandhi-apple/vg-clang-types-in-sil
Propagate Clang types through SIL
2020-01-21 09:42:37 -08:00
swift-ci
7c76036449 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-21 09:03:21 -08:00
Erik Eckstein
cabcecc97e IRGen: in multi-threaded compilation, create all specializations of a function in the same LLVM module.
This increases the chances that multiple specializations from the same function can be merged with LLVM's function merge pass.
2020-01-21 15:33:29 +01:00
Varun Gandhi
a27c5f0a16 [Printer] Conditionally print Clang types in emitted SIL.
Hopefully, this helps us debug Clang type mismatches better.
2020-01-17 16:22:39 -08:00
Erik Eckstein
1b312a85bd Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-16 10:39:20 +01:00
Robert Widmann
bd57f14661 [NFC] Push const IRGenOptions and SILOptions everywhere 2020-01-13 22:01:41 -08:00
swift-ci
b03560174a Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-13 15:04:05 -08:00
swift-ci
b890bcb3c2 Merge pull request #28899 from ravikandhadai/constexpr-checked-casts 2020-01-13 14:45:32 -08:00
swift_jenkins
3ad5fa6c7f Merge remote-tracking branch 'origin/master' into master-next 2020-01-06 10:38:53 -08:00
Slava Pestov
f0a1fb51b4 Merge pull request #29003 from slavapestov/fix-speculative-devirt
Fix speculative devirtualization to correctly use casted value
2020-01-06 13:25:50 -05:00
swift_jenkins
f27c28c85c Merge remote-tracking branch 'origin/master' into master-next 2020-01-03 12:59:03 -08:00
Slava Pestov
3997aa5754 SIL: Remove SILBuilder::tryCreateUncheckedRefCast() 2020-01-03 15:37:19 -05:00
Michael Gottesman
990af4bdd3 [sil] Change TermInst::getSuccessorBlockArguments() to yield SILArguments instead of SILPhiArgument since I am going to be adding SwitchEnumResult (which the API can vend as well). 2020-01-03 11:12:48 -08:00
swift_jenkins
96f5d97cf8 Merge remote-tracking branch 'origin/master' into master-next 2020-01-02 11:39:05 -08:00
Saleem Abdulrasool
ed920fe094 Merge pull request #28953 from compnerd/imvu
SIL: explicitly instantiate the `Operand` move ctor
2020-01-02 11:24:58 -08:00
swift_jenkins
81c0ed297a Merge remote-tracking branch 'origin/master' into master-next 2020-01-02 10:19:08 -08:00
Saleem Abdulrasool
bf37455312 Merge pull request #28954 from compnerd/brace-yourself
SIL: use `std::array` for `SILSuccessor` array
2020-01-02 10:08:25 -08:00
Saleem Abdulrasool
21ae72928e Merge pull request #28936 from compnerd/party-like-its-2017
remove VS2015 workaround (NFC)
2020-01-02 10:05:23 -08:00
swift_jenkins
79952615d1 Merge remote-tracking branch 'origin/master' into master-next 2020-01-02 09:39:11 -08:00
Saleem Abdulrasool
075a93a475 SIL: add an explicit move assignment operation instantiation 2020-01-01 13:16:45 -08:00
Saleem Abdulrasool
86ca0a1747 SIL: explicitly instantiate the Operand move ctor
GCC 7 does not like the missing move constructor and does not implicitly
synthesize one.  Explicitly indicate that this should be synthesized.
2020-01-01 13:15:55 -08:00
Michael Gottesman
321185e82f [sil] Rename TermInst::{getSuccessorBlockArguments,getSuccessorBlockArgumentLists}()
This method returns argument lists, not arguments! We should add in the future
an additional API that returns a flap mapped range over all such argument lists
to cleanup some of this code. But at least now the name is more accurate.
2019-12-28 15:33:30 -08:00
Saleem Abdulrasool
2b17d366b4 SIL: use std::array for SILSuccessor array
The `SILSuccessor` type does not permit copy or move initialization.
Direct initialization is required, however, GCC7 seems unable to cope
with the direct initialization of the array of non-copyable UDTs.  Use a
`std::array` which can be direct-initialized.  This enables building
with GCC7.
2019-12-27 10:24:08 -08:00
Saleem Abdulrasool
01d5652999 remove VS2015 workaround (NFC)
VS2015 had an issue with the deletion of an operator.  Since VS2017 is
the minimum version that LLVM uses, we can assume that VS2017+ is in use
(_MSC_VER >= 1910).  Clean up the now defunct workaround.
2019-12-23 11:55:10 -08:00
Ravi Kandhadai
ef254c0e9c [Constant Evaluator] Add support for evaluating checked_cast_br
instruction and store_borrow.
2019-12-20 09:29:20 -08:00
swift_jenkins
511931489c Merge remote-tracking branch 'origin/master' into master-next 2019-12-20 07:19:11 -08:00
Slava Pestov
8214e18850 SILGen: Clean up invariants around capture lists 2019-12-19 23:47:24 -05:00
swift_jenkins
eb0a077b6b Merge remote-tracking branch 'origin/master' into master-next 2019-12-18 13:40:09 -08:00
swift-ci
37c6be8070 Merge pull request #27521 from apple/marcrasi-patch-1 2019-12-18 13:20:31 -08:00
swift_jenkins
cc083af78f Merge remote-tracking branch 'origin/master' into master-next 2019-12-12 18:00:14 -08:00
Michael Gottesman
9efb49ac9a [applysite] Add new methods that ease insertion of code after FullApplySites.
Specifically:

1. I renamed the method insertAfter -> insertAfterInvocation and added an
ehaustive switch to ensure that we properly update this code if we add new apply
sites.

2. I added a new method insertAfterFullEvaluation that is like
insertAfterInvocation except that the callback is called with insertion points
after the end/abort apply instead of after the initial invocation of the
begin_apply.
2019-12-12 16:25:10 -08:00
swift_jenkins
516cda0b9c Merge remote-tracking branch 'origin/master' into master-next 2019-12-11 19:40:20 -08:00
Michael Gottesman
d815c603c2 [ownership] Change BorrowScopeIntroducerValue::areInstructionsWithinScope to take SILInstructions instead of BranchPropagatedUser.
All non cond_br SILInstructions are layout compatible with BranchPropagatedUser
since BPU just stores a PointerIntPair that leaves its low bits as zero unless
one adds a cond_br. Since in these cases, the SILInstructions are all not
cond_br, we can use this alternative API.

I also added some asserts to validate that the assumption that all such
SILInstructions are not cond_br is respected.
2019-12-11 16:55:13 -08:00