Commit Graph

193 Commits

Author SHA1 Message Date
Michael Gottesman
573655d46c [ownership] Allow for objc_super_method to take a metatype as well as a non-trivial object.
rdar://29791263
2017-10-25 17:53:09 -07:00
swift-ci
7ad712de8e Merge remote-tracking branch 'origin/master' into master-next 2017-10-24 18:49:07 -07:00
Michael Gottesman
36a8d0d5c0 [sil] Add support for the destructure_{struct,tuple} instructions.
rdar://31521023
2017-10-24 18:36:37 -07:00
Michael Gottesman
6df5462ee2 [sil] Add support for multiple value instructions by adding MultipleValueInstruction{,Result}.
rdar://31521023
2017-10-24 18:36:37 -07:00
swift-ci
2fd5f7ad4c Merge remote-tracking branch 'origin/master' into master-next 2017-10-13 19:09:33 -07:00
Slava Pestov
0acf3ac8d9 SIL: Remove is_nonnull instruction 2017-10-13 17:38:32 -07:00
swift-ci
68cb01cc77 Merge remote-tracking branch 'origin/master' into master-next 2017-10-04 12:48:58 -07:00
swift-ci
7a2d0a8242 Merge remote-tracking branch 'origin/master' into master-next 2017-10-04 04:08:57 -07:00
Slava Pestov
e806b6248d SIL: Remove dynamic_method instruction 2017-10-04 03:53:16 -07:00
Slava Pestov
7bf3b90b62 SIL: Split off objc_method / objc_super_method from class_method / super_method
This replaces the '[volatile]' flag. Now, class_method and
super_method are only used for vtable dispatch.

The witness_method instruction is still overloaded for use
with both ObjC protocol requirements and Swift protocol
requirements; the next step is to make it only mean the
latter, also using objc_method for ObjC protocol calls.
2017-10-03 22:13:31 -07:00
swift-ci
980abcf525 Merge remote-tracking branch 'origin/master' into master-next 2017-10-02 16:18:33 -07:00
Jordan Rose
b6c28b02d0 [SIL] Remove the builtins related to UnknownObject.
No functionality change; nothing is using them.
2017-10-02 09:05:31 -07:00
swift-ci
135a4286b5 Merge remote-tracking branch 'origin/master' into master-next 2017-09-25 10:29:30 -07:00
John McCall
ab3f77baf2 Make SILInstruction no longer a subclass of ValueBase and
introduce a common superclass, SILNode.

This is in preparation for allowing instructions to have multiple
results.  It is also a somewhat more elegant representation for
instructions that have zero results.  Instructions that are known
to have exactly one result inherit from a class, SingleValueInstruction,
that subclasses both ValueBase and SILInstruction.  Some care must be
taken when working with SILNode pointers and testing for equality;
please see the comment on SILNode for more information.

A number of SIL passes needed to be updated in order to handle this
new distinction between SIL values and SIL instructions.

Note that the SIL parser is now stricter about not trying to assign
a result value from an instruction (like 'return' or 'strong_retain')
that does not produce any.
2017-09-25 02:06:26 -04:00
swift-ci
4135e9c841 Merge remote-tracking branch 'origin/master' into master-next 2017-09-21 16:09:54 -07:00
Mark Lacey
c0c848d2b3 Add Builtin.type_join* family of functions.
These will be used for unit-testing the Type::join functionality in the
type checker. The result of the join is replaced during constraint
generation with the actual type.

There is currently no checking for whether the arguments can be used to
statically compute the value, so bad things will likely happen if
e.g. they are type variables. Once more of the basic functionality of
Type::join is working I'll make this a bit more bullet-proof in that
regard.

They include:
  // Compute the join of T and U and return the metatype of that type.
  Builtin.type_join<T, U, V>(_: T.Type, _: U.Type) -> V.Type

  // Compute the join of &T and U and return the metatype of that type.
  Builtin.type_join_inout<T, U, V>(_: inout T, _: U.Type) -> V.Type

  // Compute the join of T.Type and U.Type and return that type.
  Builtin.type_join_meta<T, U, V>(_: T.Type, _: U.Type) -> V.Type

I've added a couple simple tests to start off, based on what currently
works (aka doesn't cause an assert, crash, etc.).
2017-09-21 14:43:26 -07:00
swift-ci
b51e2e6837 Merge remote-tracking branch 'origin/master' into master-next 2017-09-15 13:29:49 -07:00
Joe Groff
78d75428d6 SILGen: Lower key path subscript indexes.
And fill out SIL support for parsing, printing, and serializing key path
patterns with captured indexes.
2017-09-15 10:00:32 -07:00
swift-ci
77d9df9228 Merge remote-tracking branch 'origin/master' into master-next 2017-09-13 08:09:52 -07:00
Arnold Schwaighofer
8a85a9efd5 Use array copy runtime implementation instead of the array value witnesses
And add builtins for the added runtime functions (assign-take, assign-copy).

rdar://27412867
SR-3376
2017-09-12 12:43:26 -07:00
swift-ci
f8ce7b23c7 Merge remote-tracking branch 'origin/master' into master-next 2017-09-05 11:09:17 -07:00
Andrew Trick
c1e77bf893 [sil-opaque-values] Fix ownership of enum values.
This involved a bit of cleanup in both ownership classification and
verification. Trivial argument types now have trivial ownership. Also, the
verifier allows

- enums with non-trivial ownership to be passed to trivial arguments as long as
  it can verify that all payloads are trivial.

- enums with trivial ownership to be passed as owned arguments. Preventing this
  didn't make sense.
2017-09-03 21:34:44 -07:00
Andrew Trick
18004f8729 [sil-opaque-values] Fix SILGen and ownership of open_existential_box_value. 2017-09-02 19:37:57 -07:00
swift-ci
aed8be7d03 Merge remote-tracking branch 'origin/master' into master-next 2017-08-29 13:08:57 -07:00
Michael Gottesman
58fefc174c [sil-ownership] is_nonnull does not take trivial values, it takes classes and functions.
rdar://33358110
2017-08-29 11:19:30 -07:00
swift-ci
e98a736cbf Merge remote-tracking branch 'origin/master' into master-next 2017-08-24 12:29:44 -07:00
Andrew Trick
0a36f9dee7 Fix SIL ownership for open_existential_value.
CoW existentials means that we can't forward ownership.
2017-08-23 22:15:10 -07:00
Andrew Trick
59d3158981 Allow the SIL ownership verifier to distinguish between guaranteed vs. owned
forwarding.
2017-08-23 22:15:10 -07:00
swift-ci
aa700a9ca8 Merge remote-tracking branch 'origin/master' into master-next 2017-08-23 10:29:34 -07:00
Erik Eckstein
9c6fe76927 SIL, IRGen: add instructions "object" and "global_value” to support statically initialized objects.
This commit contains:
-) adding the new instructions + infrastructure, like parsing, printing, etc.
-) support in IRGen to generate global object-variables (i.e. "heap" objects) which are statically initialized in the data section.
-) IRGen for global_value which lazily initializes the object header and returns a reference to the object.

For details see the documentation of the new instructions in SIL.rst.
2017-08-23 09:15:49 -07:00
Erik Eckstein
1ab582e121 SIL: A new representation of static initializers for global variables.
Static initializers are now represented by a list of literal and aggregate instructions in a SILGlobalVariable.
For details see SIL.rst.

This representation is cleaner than what we did so far (point to the initializer function and do some pattern matching).

One implication of that change is that now (a subset of) instructions not necessarily have a parent function.
Regarding the generated code it's a NFC.
Also the swift module format didn't change because so far we don't serializer global variables.
2017-08-23 09:15:01 -07:00
John McCall
a5d328690d PointerLikeTypeTraits is now a struct, not a class.
We compile with a pedantic warning that complains about these things,
and the massive flood of warnings is actually causing problems for the
build infrastructure.
2017-08-17 17:01:17 -04:00
Michael Gottesman
ec44f55372 [sil-ownership] Reify the lifetime constraint of a use from a bool into UseLifetimeConstraint.
This is the first in a series of commits that cleans up the SILOwnershipVerifier
based off of discussions/feedback with other people who are now using it. The
next step is to split the checker from the declarative computation of what I
call the UseOwnershipRequirement.

rdar://33358110
2017-08-03 19:50:45 -07:00
Michael Gottesman
687aced054 [sil-ownership] When computing if a value is lifetime ending perform exact matching.
Otherwise, one can run into situations where an Any from a SILUndef results in
SSA values having destroying uses. Since we are dealing with an undef value,
from an ownership perspective, we can assume any form of ownership constraints
that we want. Thus we can treat the value as being eternal and thus from the
ownership verifier's perspective like a metatype.

rdar://33358110
2017-08-03 18:21:48 -07:00
Andrew Trick
314d48f055 Fix ownership of UnconditionalCheckedCastValue. 2017-08-02 16:26:41 -07:00
Kosuke Ogawa
2a18723b55 [gardening] Fix typos (#11245)
* [Gardening] Fix typo: getTopLeveDecls -> getTopLevelDecls

* [Gardening] Fix typo: silModue -> silModule

* [Gardening] Fix typo: Evaludate -> Evaluate

* [Gardening] Fix typo: OptioanlPayload -> OptionalPayload

* [Gardening] Fix typo: confromance -> conformance

* [Gardening] Fix typos

* [Gardening] Fix typo: tpye -> type

* [Gardening] Fix typo: resoved -> resolved

* [Gardening] Fix typo: ahve -> have

* Revert "[Gardening] Fix typo: silModue -> silModule"

This reverts commit ed8c4d0b71.
2017-07-28 10:14:21 -07:00
Andrew Trick
3bc6746840 [sil-opaque-values] Ownership support. open_existential_value forwards ownership.
Just like open_existential_ref.
2017-07-27 11:35:16 -07:00
Andrew Trick
9a770a9528 [sil-opaque-values] OwnershipVerifier support. 2017-07-27 11:35:16 -07:00
Erik Eckstein
6377cc095a SIL: Replace TransitivelyUnreachableBlocks with DeadEndBlocks
We had both utilities doing the same thing.
NFC
2017-07-24 09:50:42 -07:00
Andrew Trick
4db2a46cff Add SIL instruction: open_existential_box_value.
This has the same semantics as open_existential_box, but returns an object value
instead of an address.

This is used in SIL opaque values mode. Attempting to reuse open_existential_box
in this mode causes SIL type inconsistencies that are too difficult to work
around. Adding this instruction allows for consistent handling of opaque values.

The original versions of several of these currently redundant instructions will
be removed once the SIL representation stabilizes.
2017-07-17 23:46:41 -07:00
Andrew Trick
f657ad2d3a Rename *ExistentialOpaque instructions to *ExistentialValue.
These instructions have the same semantics as the *ExistentialAddr instructions
but operate directly on the existential value, not its address.

This is in preparation for adding ExistentialBoxValue instructions.
The previous name would cause impossible confusion with "opaque existentials"
and "opaque existential boxes".
2017-07-17 23:46:41 -07:00
Michael Gottesman
069ae8eed6 [ownership-verifier] The second argument to dealloc_partial_ref is a metatype so it must be trivial.
rdar://31880847
2017-07-12 16:53:01 -07:00
Michael Gottesman
cd7c96c050 [ownership-verifier] store_weak is a liveness use, not a consuming use of a value.
rdar://31880847
2017-07-12 16:51:56 -07:00
Michael Gottesman
1264cfa492 [semantic-sil] Add a semantic attribute "verify.ownership.sil.never".
This semantic attribute allows a user to disable ownership verification on
specific functions.

The intention is that once I turn on the sil ownership verifier for parts of the
stdlib, if an engineer exposes an ownership issue, they can disable ownership
verification on that specific function, file a bug, and continue with their
work.

rdar://31880847
2017-07-10 13:28:06 -07:00
Michael Gottesman
9be606ee29 [semantic-sil] Teach the verifier that an enum return value is a ValueOwnershipKind erasure point.
This means that a trivial enum case of a non-trivial enum can be returned @owned
even though it is trivial. We already follow this pattern with bb arguments.

rdar://31880847
2017-07-09 02:45:48 -07:00
Michael Gottesman
56acc6d82b [sil-ownership-verifier] Allow class_method to take a metatype or a non-trivial type.
rdar://31880847
2017-07-08 22:10:13 -07:00
Michael Gottesman
69393d59c7 [sil-ownership] Allow for checked_cast_br to take a guaranteed parameter.
rdar://31880847
2017-07-05 01:19:23 -07:00
Michael Gottesman
1db06d1154 [sil-ownership] Allow for switch_enum to take a guaranteed parameter.
This is needed to ensure that SILGenPattern propagates values at +0 instead of
+1.

I also improved our handling of terminators in general when it comes to having
"borrowed" arguments. The basic verification requirement is that the
end_borrow_argument is treated as a use of the parent borrow. This ensures that
the borrowed argument can not extend the lifetime of the borrowed value without
the verifier triggering.

rdar://31880847
2017-07-05 01:07:49 -07:00
swift-ci
a0d9f055d4 Merge pull request #10732 from gottesmm/callee_unowned_can_accept_unowned 2017-06-30 14:27:49 -07:00
Michael Gottesman
8750b7856d [sil-ownership-verifier] We can pass unowned, owned, and guaranteed callees to a call site that uses its callee as unowned.
rdar://31880847
2017-06-30 13:57:05 -07:00