Commit Graph

218 Commits

Author SHA1 Message Date
swift-ci
51fd06dda7 Merge remote-tracking branch 'origin/master' into master-llvm-swift5-transition 2018-02-13 07:58:32 -08:00
Joe Shajrawi
102b6f0b61 Merge pull request #14587 from shajrawi/newinstr
Optimizer peephole for tagged BridgeObjects
2018-02-13 07:38:53 -08:00
Arnold Schwaighofer
48b3737404 SIL: Add support for trivial @noescape function types
- @noescape functions are trivial types
That makes @noescape functions incompatible with escaping functions.
- Forward ownership of mark_dependence %3 : callee_guaranteed () -> () on %0 : noescape @callee_guaranteed () -> ()
- SIL: Add ABIEscapeToNoEscapeConversion to SILFunctionType::ABICompatibilityCheckResult
- SIL: A thin_to_thick_function with a @noescape result type has trivial ownership
- SIL: thin_to_thick_function can create noescape function types

Part of:
SR-5441
rdar://36116691
2018-02-13 04:19:58 -08:00
Joe Shajrawi
6538d543f7 Builtins: add StringObjectOr and use it in the standard library 2018-02-13 11:12:55 +02:00
Joe Shajrawi
f732ea66ef Builtins: add ValueToBridgeObject instruction 2018-02-12 13:27:59 +02:00
swift-ci
7ca497aedd Merge remote-tracking branch 'origin/master' into master-llvm-swift5-transition 2018-02-12 00:18:39 -08:00
Michael Gottesman
1476f8f033 [ownership-verifier] Allow owned enum arguments to be passed as guaranteed function arguments.
Enums require special handling in the ownership verifier since an enum is a sum
type whose triviality or non-triviality is erased at function arguments. When
the ownership verifier was changed to allow for owned values to be passed as
guaranteed objects via instantaneous borrowing, this code was not updated.

rdar://34222540
2018-02-11 22:43:59 -08:00
swift-ci
9097df627e Merge remote-tracking branch 'origin/master' into master-llvm-swift5-transition 2018-02-07 05:18:18 -08:00
Arnold Schwaighofer
d51053b003 Add convert_escape_to_noescape instruction for converting escaping to noescape functions
@noescape function types will eventually be trivial. A
convert_escape_to_noescape instruction does not take ownership of its
operand. It is a projection to the trivial value carried by the closure
-- both context and implementation function viewed as a trivial value.

A safe SIL program must ensure that the object that the project value is based
on is live beyond the last use of the trivial value. This will be
achieve by means of making the lifetimes dependent.

For example:

  %e = partial_apply [callee_guaranteed] %f(%z) : $@convention(thin) (Builtin.Int64) -> ()
  %n = convert_escape_to_noescape %e : $@callee_guaranteed () -> () to $@noescape @callee_guaranteed () -> ()
  %n2 = mark_dependence %n : $@noescape @callee_guaranteed () -> () on %e : $@callee_guaranteed () -> ()
  %f2 = function_ref @use : $@convention(thin) (@noescape @callee_guaranteed () -> ()) -> ()
  apply %f2(%n2) : $@convention(thin) (@noescape @callee_guaranteed () -> ()) -> ()
  release_value %e : $@callee_guaranteed () -> ()

Note: This is not yet actually used.

Part of:
SR-5441
rdar://36116691
2018-02-06 18:01:23 -08:00
swift-ci
c552df85f8 Merge remote-tracking branch 'origin/master' into master-llvm-swift5-transition 2018-01-12 11:39:41 -08:00
Michael Gottesman
9f8df425de Revert "[+0-all-args] Accept guaranteed arguments to unsafe guaranteed."
This reverts commit 0bc964801b.

This turned out to be a bad idea and just add more complication than is
necessary.
2018-01-12 10:09:49 -08:00
swift-ci
cc373f9c30 Merge remote-tracking branch 'origin/master' into master-llvm-swift5-transition 2018-01-08 12:27:47 -08:00
Andrew Trick
4bba7685d5 Comment SIL ownership checker for the @guaranteed case. 2018-01-08 11:26:56 -08:00
Andrew Trick
0da82bfaa2 SIL ownership: treat guaranteed args like normal uses. 2018-01-08 11:26:56 -08:00
swift-ci
ed1cf3bc48 Merge remote-tracking branch 'origin/master' into master-next 2018-01-02 15:29:18 -08:00
Chris Lattner
415cd50ba2 Reduce array abstraction on apple platforms dealing with literals (#13665)
* Reduce array abstraction on apple platforms dealing with literals

Part of the ongoing quest to reduce swift array literal abstraction
penalties: make the SIL optimizer able to eliminate bridging overhead
 when dealing with array literals.

Introduce a new classify_bridge_object SIL instruction to handle the
logic of extracting platform specific bits from a Builtin.BridgeObject
value that indicate whether it contains a ObjC tagged pointer object,
or a normal ObjC object. This allows the SIL optimizer to eliminate
these, which allows constant folding a ton of code. On the example
added to test/SILOptimizer/static_arrays.swift, this results in 4x
less SIL code, and also leads to a lot more commonality between linux
and apple platform codegen when passing an array literal.

This also introduces a couple of SIL combines for patterns that occur
in the array literal passing case.
2018-01-02 15:23:48 -08:00
swift-ci
9ae11b7cff Merge remote-tracking branch 'origin/master' into master-next 2017-12-02 18:58:23 -08:00
Michael Gottesman
5263e9e74e [sil] Eliminate redundant method SILFunction::hasUnqualifiedOwnership().
We can just !SILFunction::hasQualifiedOwnership(). Plus as Andy pointed out,
even ignoring the functional aspects, having APIs with names this close can
create confusion.
2017-12-02 17:42:34 -08:00
swift-ci
d3ebb4b288 Merge remote-tracking branch 'origin/master' into master-next 2017-11-30 22:10:01 -08:00
Michael Gottesman
0bc964801b [+0-all-args] Accept guaranteed arguments to unsafe guaranteed.
rdar://34222540
2017-11-30 22:04:53 -08:00
swift-ci
90cc83fabc Merge remote-tracking branch 'origin/master' into master-next 2017-11-13 02:09:19 -08:00
John McCall
045998544f Add begin_apply, abort_apply, and end_apply instructions to allow
yield_once coroutines to be executed.
2017-11-13 04:03:54 -05:00
swift-ci
4b5fce50e7 Merge remote-tracking branch 'origin/master' into master-next 2017-11-07 03:29:00 -08:00
John McCall
14d6390352 Add "yield" and "unwind" instructions to SIL. 2017-11-07 03:51:54 -05:00
swift-ci
8a681dbef9 Merge remote-tracking branch 'origin/master' into master-next 2017-10-25 19:29:32 -07:00
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