Commit Graph

4003 Commits

Author SHA1 Message Date
Michael Gottesman
1e0414df77 Merge pull request #23284 from gottesmm/pr-0b4de614fe103f8e5a161be5219ba2cb7148aa25
[ast]/[silgen] If a case stmt is a fallthrough source, tail allocate a pointer in the case stmt to the fallthrough case.
2019-03-14 14:03:47 -07:00
Michael Gottesman
7b27b4b502 [silgenpattern] Change SILGenPattern to use CaseStmt::hasFallthroughDest() instead of computing this itself.
rdar://47467128
2019-03-14 11:25:41 -07:00
Azoy
bc7cb332df Fix generic types
add tests

get parent init
2019-03-14 04:07:24 -05:00
Slava Pestov
fab1b036af SILGen: Use the best resilience expansion when lowering keypath indices 2019-03-13 22:08:23 -04:00
Slava Pestov
32208fa17b SILGen: Use maximal resilience expansion to decide if we need an ivar destroyer 2019-03-13 22:08:23 -04:00
Azoy
e8bc662b35 Cleanups from Slava's comments
update module format
2019-03-13 18:58:45 -05:00
Azoy
6f7d20b99e Synthesize default values for memberwise init
Introduce stored property default argument kind

Fix indent

Assign nil to optionals with no initializers

Don't emit generator for stored property default arg

Fix problem with rebase

Indentation

Serialize stored property default arg text

Fix some tests

Add missing constructor in test

Print stored property's initializer expression

cleanups

preserve switch

complete_constructor

formatting

fix conflict
2019-03-13 18:57:36 -05:00
Slava Pestov
50b1bae51f SILGen: Tidy up some code 2019-03-13 02:21:53 -04:00
Slava Pestov
c93ec45e62 SIL: Plumb resilience expansion through when lowering capture types
For now this is NFC.
2019-03-13 02:08:32 -04:00
Michael Gottesman
85ee550669 [silgenpattern] When we switch on an enum with an associated type that is empty, create a phi argument for it.
Previously we were handling this like we did not have any associated type. This
caused us to break the requirement in [ossa] that all switch_enum successors
associated with payloaded enums must have arguments. We still emit the empty
tuple value (or an undef tuple) if we do not have any associated type.
2019-03-12 14:59:50 -07:00
Slava Pestov
123fee960e Merge pull request #23228 from slavapestov/type-lowering-is-trivial
Replace SILType::isTrivial(SILModule) with isTrivial(SILFunction)
2019-03-12 13:44:10 -04:00
Michael Gottesman
65b3164726 Merge pull request #23216 from gottesmm/pr-b5814b8efc86c8b129ba890460837f88056d5c3d
[silgen] Fix a bug where when reabstracting T:P -> P we wrapped a +0 …
2019-03-12 00:49:59 -07:00
Slava Pestov
568816aa91 SILGen: Always use minimal resilience expansion for the calling convention 2019-03-12 03:06:32 -04:00
Slava Pestov
8915f96e3e SIL: Replace SILType::isTrivial(SILModule) with isTrivial(SILFunction) 2019-03-12 01:16:04 -04:00
Slava Pestov
c791c4a137 SIL: SILUndef must be aware of the resilience expansion
The ownership kind is Any for trivial types, or Owned otherwise, but
whether a type is trivial or not will soon depend on the resilience
expansion.

This means that a SILModule now uniques two SILUndefs per type instead
of one, and serialization uses two distinct sentinel IDs for this
purpose as well.

For now, the resilience expansion is not actually used here, so this
change is NFC, other than changing the module format.
2019-03-12 00:30:35 -04:00
Michael Gottesman
15c03b7b0a Fix potential use-after-free in emitFuncToBlock exposed by enabling ownership verification on PrintAsObjC/blocks.swift.
If the block is guaranteed, we need to be sure to copy here. This can happen for
instance with arguments (where this was caught). I added a SILGen test that
exposes this failure since this is not an actual bug in PrintAsObjC.
2019-03-11 14:23:44 -07:00
Michael Gottesman
7c9dfad65c [silgen] Fix a bug where when reabstracting T:P -> P we wrapped a +0 value in an init_existential_ref.
Found via the ownership verifier running on IRGen/outlined_copy_addr.swift.

We treat initialization of an existential as a +1 operation, so there is the
possibility that we would have double destroyed a value. In fixing this I
followed what manageOpaqueValue did on the first code path, since it is handling
this case correctly (and using the SGFContext to do so to boot!).

To ensure this is tested, I enabled ownership verification on the test and since
it seems to be exposing a SILGen code path that we aren't testing currently,
converted it into a SILGen test.
2019-03-11 13:40:26 -07:00
Michael Gottesman
87604fedc7 Merge pull request #23161 from gottesmm/pr-a5f2826a8beda8910e2b0dc7efba52dce1379f8d
[silgenpattern] Only emit a shared case if we have a fallthrough/mult…
2019-03-07 17:04:07 -08:00
Michael Gottesman
6113566089 [silgenpattern] Convert two Pattern::forEachVariables() to instead use Pattern::collectVariables().
This maps more cleanly onto CaseStmt::getCaseBodyVariables() and cleans up the
diff for changing to use said method instead.
2019-03-07 12:01:48 -08:00
Michael Gottesman
9f0375e3c9 [silgenpattern] Only emit a shared case if we have a fallthrough/multiple cast items.
There was a bug here where we were emitting a shared case if we had arguments.
That is why we needed the hacked in deletion of that block when we emitted
shared blocks. I was able to replace that with an assert to make sure that we do
not regress.

This additionally improved our code generation by eliminating a potential extra
copy when we had such a case. That is where the test updates come from.
2019-03-07 11:54:07 -08:00
Michael Gottesman
4fefea5cbf [silgenpattern] Reduce indentation and clean up code by inverting an if condition and using an early exit. 2019-03-06 12:45:03 -08:00
Michael Gottesman
99c62ea5da [silgenpattern] Extract out the large completion handler lambda into its own function.
This makes it easier to read/reason about SILGenPattern::emitSwitchStmt().
2019-03-06 12:33:58 -08:00
Michael Gottesman
c8cdc46f02 [silgenpattern] Reduce indentation by inverting a condition. 2019-03-06 11:28:05 -08:00
Slava Pestov
d04c335478 SIL: Remove default arguments from resilience expansion parameters
Each call site will soon have to think about passing in the right expansion
instead of just assuming the default will be OK. But there are now only a
few call sites left, because most have been refactored to use convenience
APIs that pass in the right resilience expansion already.
2019-03-05 21:04:30 -05:00
Slava Pestov
5847e163c1 SIL: Use better type lowering APIs in a couple of spots 2019-03-05 20:59:58 -05:00
Slava Pestov
a4f560dc73 SIL: Use getLoweredRValueType() in various places 2019-03-04 20:33:19 -05:00
Slava Pestov
2813912c48 Merge pull request #23010 from pschuh/s-5
FloatLiteralExpr now is lowered directly into SIL.
2019-03-01 17:32:23 -05:00
Parker Schuh
5160da6a2e FloatLiteralExpr now is lowered directly into SIL.
For context, String, Nil, Bool, and Int already behave this way.

Note: Swift can compile against 80 or 64 bit floats as the builtin
literal type. Thus, it was necessary to capture this bit somehow in the
FloatLiteralExpr. This was done as another Type field capturing this
info.
2019-03-01 09:01:30 -08:00
Slava Pestov
903721cdc5 SIL: Remove SILType::getMetatypeInstanceType() 2019-03-01 02:07:16 -05:00
Slava Pestov
1944254253 SIL: Use SILFunction type lowering APIs in various places 2019-03-01 02:07:16 -05:00
Slava Pestov
d1cf8c9cf6 SIL: Add type lowering APIs to SILFunction
For now these just forward to methods on the module's TypeLowering,
but soon they will use the SILFunction's resilience expansion.
2019-02-28 23:12:08 -05:00
Joe Groff
bb67cf815c Merge pull request #21355 from technicated/tuple-keypaths-2
Tuple KeyPaths
2019-02-25 12:56:05 -08:00
Argyrios Kyrtzidis
05893a8595 Merge pull request #22831 from compnerd/cmake-modernise-1
cmake: switch host libraries to use `target_link_libraries`
2019-02-23 10:57:07 -08:00
Saleem Abdulrasool
9934532e07 cmake: switch host libraries to use target_link_libraries
This is a follow up to the discussion on #22740 to switch the host
libraries to use the `target_link_libraries` rather than the
`LINK_LIBRARIES` special handling.  This allows the dependency to be
properly tracked by CMake and allows us to use the more modern syntax.
2019-02-22 15:28:07 -08:00
Slava Pestov
72c8e787ad SIL: Don't serialize imported conformances nested in non-public types
Apparently you can use a swift_name attribute in Clang to import types
as members of Swift types. If the Swift type is not public, we would
still try to serialize the witness thunks, which tripped SIL verifier
checks since the witnesses themselves were not serialized.

Note that the fix here is to just delete the special case of an
imported conformance; the regular "type is public and protocol is
public" condition suffices here.

Fixes <rdar://problem/48218483>.
2019-02-22 02:35:18 -05:00
Michael Gottesman
0f1510bfdf Merge pull request #22723 from gottesmm/pr-4c62ddbcb693de79222f5cd1f86a2a89f0d879bd
[silgen] Eliminate more unneeded indentation by inverting an if state…
2019-02-19 16:46:20 -08:00
Michael Gottesman
c04afbd4a6 [silgen] Eliminate more unneeded indentation by inverting an if statement. 2019-02-19 15:05:14 -08:00
Michael Gottesman
7989d3f48c Merge pull request #22720 from gottesmm/pr-92e66215cb00ac99f0a42ba2235807d017811217
[silgen] Remove some unnecessary indentation from SILGenPattern::emitSwitchStmt
2019-02-19 14:59:21 -08:00
Michael Gottesman
9b9d01ea5d [silgen] Eliminate another level of indentation by inverting an if statement and using a continue. 2019-02-19 13:31:52 -08:00
Michael Gottesman
cd2fbfcd81 [silgen] Use early exits and invert an if condition to reduce indentation. 2019-02-19 13:31:52 -08:00
Michael Gottesman
0b3aba4c82 [silgen] Eliminate another level of indentation by inverting an if condition in a for loop. 2019-02-19 13:04:28 -08:00
Michael Gottesman
af40fcfe6b [silgen] Use early breaks in an if-else-if block instead of having a break at the end.
Just reducing indentation more.
2019-02-19 13:04:28 -08:00
Michael Gottesman
9570384646 [silgen] Use an early exit to reduce indentation. NFC. 2019-02-19 13:04:28 -08:00
technicated
3615b0ee4b Inlined and removed a method from SILGenModule
There is no need for a 'emitKeyPathComponentForTupleElement' method because there is not so much work to do there
2019-02-18 10:19:42 +01:00
Andrea Tomarelli
8773f21cf5 Replaced an if statement with an assertion in SILGenExpr 2019-02-18 09:04:43 +01:00
Andrea Tomarelli
17cf1360c4 Very minimal POC of tuple KP feature 2019-02-18 09:04:43 +01:00
Andrea Tomarelli
ede47cafbd Partial AST & Sema implementation of TKP 2019-02-18 09:04:42 +01:00
Doug Gregor
d31ef61a28 Eliminate "sorting" of DeclContext-local protocols / conformances.
Sorting of DeclContext-local protocols and conformances shouldn't ever
be necessary, because the underlying data structures that produce
these lists should be deterministic. Sorting can hide any
non-determinism, so stop doing it and we can address the underlying
nondeterminism.
2019-02-15 14:16:48 -08:00
Slava Pestov
18f4500bc6 Merge pull request #22611 from pschuh/s-4
IntegerLiteralExpr now is lowered directly into SIL.
2019-02-14 21:05:15 -05:00
Parker Schuh
b12fcb50db IntegerLiteralExpr now is lowered directly into SIL.
For context, String, Nil, and Bool already behave this way.

Note: Before it used to construct (call, ... (integer_literal)), and the
call would be made explicit / implicit based on if you did eg: Int(3) or
just 3. This however did not translate to the new world so this PR adds
a IsExplicitConversion bit to NumberLiteralExpr. Some side results of
all this are that some warnings changed a little and some instructions are
emitted in a different order.
2019-02-14 11:54:16 -08:00